source: trunk/target/linux/omap24xx/patches-2.6.38/535-cbus-retu-wdt-cleanup.patch @ 25832

Last change on this file since 25832 was 25832, checked in by mb, 6 years ago

cbus-retu-wdt: Some fixes

File size: 5.1 KB
  • drivers/cbus/retu-wdt.c

    old new static DEFINE_MUTEX(retu_wdt_mutex); 
    5252 
    5353/* Current period of watchdog */ 
    5454static unsigned int period_val = RETU_WDT_DEFAULT_TIMER; 
    55 static int counter_param = RETU_WDT_MAX_TIMER; 
    5655 
    5756struct retu_wdt_dev { 
    5857        struct device           *dev; 
    static void retu_wdt_ping_work(struct wo 
    109108        retu_wdt_ping_enable(wdev); 
    110109} 
    111110 
    112 static ssize_t retu_wdt_period_show(struct device *dev, 
    113                                 struct device_attribute *attr, char *buf) 
    114 { 
    115         /* Show current max counter */ 
    116         return sprintf(buf, "%u\n", (u16)period_val); 
    117 } 
    118  
    119 /* 
    120  * Note: This inteface is non-standard and likely to disappear! 
    121  * Use /dev/watchdog instead, that's the standard. 
    122  */ 
    123 static ssize_t retu_wdt_period_store(struct device *dev, 
    124                                 struct device_attribute *attr, 
    125                                 const char *buf, size_t count) 
    126 { 
    127         unsigned int new_period; 
    128         int ret; 
    129  
    130 #ifdef CONFIG_WATCHDOG_NOWAYOUT 
    131         retu_wdt_ping_disable(retu_wdt); 
    132 #endif 
    133  
    134         if (sscanf(buf, "%u", &new_period) != 1) { 
    135                 printk(KERN_ALERT "retu_wdt_period_store: Invalid input\n"); 
    136                 return -EINVAL; 
    137         } 
    138  
    139         ret = retu_modify_counter(new_period); 
    140         if (ret < 0) 
    141                 return ret; 
    142  
    143         return strnlen(buf, count); 
    144 } 
    145  
    146 static ssize_t retu_wdt_counter_show(struct device *dev, 
    147                                 struct device_attribute *attr, char *buf) 
    148 { 
    149         u16 counter; 
    150  
    151         /* Show current value in watchdog counter */ 
    152         counter = retu_read_reg(dev, RETU_REG_WATCHDOG); 
    153  
    154         /* Only the 5 LSB are important */ 
    155         return snprintf(buf, PAGE_SIZE, "%u\n", (counter & 0x3F)); 
    156 } 
    157  
    158 static DEVICE_ATTR(period, S_IRUGO | S_IWUSR, retu_wdt_period_show, \ 
    159                         retu_wdt_period_store); 
    160 static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL); 
    161  
    162111static int retu_wdt_open(struct inode *inode, struct file *file) 
    163112{ 
    164113        if (test_and_set_bit(0, &retu_wdt->users)) 
    static int retu_wdt_release(struct inode 
    175124        struct retu_wdt_dev *wdev = file->private_data; 
    176125 
    177126#ifndef CONFIG_WATCHDOG_NOWAYOUT 
    178         retu_wdt_ping_enable(retu_wdt); 
     127        retu_wdt_ping_enable(wdev); 
    179128#endif 
    180         clear_bit(0, &retu_wdt->users); 
     129        clear_bit(0, &wdev->users); 
    181130 
    182131        return 0; 
    183132} 
    static long retu_wdt_ioctl(struct file * 
    232181        return 0; 
    233182} 
    234183 
    235 /* Start kicking retu watchdog until user space starts doing the kicking */ 
    236 static int __devinit retu_wdt_ping(void) 
    237 { 
    238 #ifdef CONFIG_WATCHDOG_NOWAYOUT 
    239         retu_modify_counter(RETU_WDT_MAX_TIMER); 
    240 #else 
    241         retu_wdt_ping_enable(retu_wdt); 
    242 #endif 
    243  
    244         return 0; 
    245 } 
    246  
    247184static const struct file_operations retu_wdt_fops = { 
    248185        .owner          = THIS_MODULE, 
    249186        .write          = retu_wdt_write, 
    static const struct file_operations retu 
    252189        .release        = retu_wdt_release, 
    253190}; 
    254191 
    255 /*----------------------------------------------------------------------------*/ 
    256  
    257192static int __init retu_wdt_probe(struct platform_device *pdev) 
    258193{ 
    259194        struct retu_wdt_dev *wdev; 
    static int __init retu_wdt_probe(struct 
    265200 
    266201        wdev->dev = &pdev->dev; 
    267202 
    268         ret = device_create_file(&pdev->dev, &dev_attr_period); 
    269         if (ret) { 
    270                 dev_err(&pdev->dev, "Error creating sysfs period\n"); 
    271                 goto free1; 
    272         } 
    273  
    274         ret = device_create_file(&pdev->dev, &dev_attr_counter); 
    275         if (ret) { 
    276                 dev_err(&pdev->dev, "Error creating sysfs counter\n"); 
    277                 goto free2; 
    278         } 
    279  
    280203        platform_set_drvdata(pdev, wdev); 
    281204        retu_wdt = wdev; 
    282205        wdev->retu_wdt_miscdev.parent = &pdev->dev; 
    static int __init retu_wdt_probe(struct 
    286209 
    287210        ret = misc_register(&(wdev->retu_wdt_miscdev)); 
    288211        if (ret) 
    289                 goto free3; 
     212                goto err_free_wdev; 
    290213 
    291214        INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work); 
    292215 
    293         /* passed as module parameter? */ 
    294         ret = retu_modify_counter(counter_param); 
    295         if (ret == -EINVAL) { 
    296                 ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER); 
    297                 dev_dbg(&pdev->dev, "Initializing to default value\n"); 
    298         } 
    299  
    300         /* Kick the watchdog for kernel booting to finish */ 
     216        /* Kick the watchdog for kernel booting to finish. 
     217         * If nowayout is not set, we start the ping work. */ 
     218#ifdef CONFIG_WATCHDOG_NOWAYOUT 
    301219        retu_modify_counter(RETU_WDT_MAX_TIMER); 
    302  
    303         ret = retu_wdt_ping(); 
    304         if (ret < 0) { 
    305                 dev_err(&pdev->dev, "Failed to ping\n"); 
    306                 goto free4; 
    307         } 
     220#else 
     221        retu_wdt_ping_enable(retu_wdt); 
     222#endif 
    308223 
    309224        return 0; 
    310225 
    311 free4: 
    312         misc_deregister(&wdev->retu_wdt_miscdev); 
    313  
    314 free3: 
    315         device_remove_file(&pdev->dev, &dev_attr_counter); 
    316  
    317 free2: 
    318         device_remove_file(&pdev->dev, &dev_attr_period); 
    319  
    320 free1: 
     226err_free_wdev: 
    321227        kfree(wdev); 
    322228 
    323229        return ret; 
    static int __devexit retu_wdt_remove(str 
    329235 
    330236        wdev = platform_get_drvdata(pdev); 
    331237        misc_deregister(&wdev->retu_wdt_miscdev); 
    332         device_remove_file(&pdev->dev, &dev_attr_period); 
    333         device_remove_file(&pdev->dev, &dev_attr_counter); 
    334238        cancel_delayed_work_sync(&wdev->ping_work); 
    335239        kfree(wdev); 
    336240 
    static void __exit retu_wdt_exit(void) 
    356260 
    357261module_init(retu_wdt_init); 
    358262module_exit(retu_wdt_exit); 
    359 module_param(counter_param, int, 0); 
    360263 
    361264MODULE_DESCRIPTION("Retu WatchDog"); 
    362265MODULE_AUTHOR("Amit Kucheria"); 
    363266MODULE_LICENSE("GPL"); 
    364  
Note: See TracBrowser for help on using the repository browser.