Loading drivers/watchdog/mixcomwd.c +63 −70 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ * - support for one more type board * * Version 0.5 (2001/12/14) Matt Domsch <Matt_Domsch@dell.com> * - added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * - added nowayout module option to override * CONFIG_WATCHDOG_NOWAYOUT * * Version 0.6 (2002/04/12): Rob Radez <rob@osinvestor.com> * - make mixcomwd_opened unsigned, Loading @@ -53,8 +54,8 @@ #include <linux/init.h> #include <linux/jiffies.h> #include <linux/timer.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/uaccess.h> #include <linux/io.h> /* * We have two types of cards that can be probed: Loading Loading @@ -108,7 +109,9 @@ static char expect_close; static int nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, int, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static void mixcomwd_ping(void) { Loading @@ -119,7 +122,6 @@ static void mixcomwd_ping(void) static void mixcomwd_timerfun(unsigned long d) { mixcomwd_ping(); mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); } Loading @@ -129,19 +131,19 @@ static void mixcomwd_timerfun(unsigned long d) static int mixcomwd_open(struct inode *inode, struct file *file) { if(test_and_set_bit(0,&mixcomwd_opened)) { if (test_and_set_bit(0, &mixcomwd_opened)) return -EBUSY; } mixcomwd_ping(); if (nowayout) { if (nowayout) /* * fops_get() code via open() has already done * a try_module_get() so it is safe to do the * __module_get(). */ __module_get(THIS_MODULE); } else { else { if (mixcomwd_timer_alive) { del_timer(&mixcomwd_timer); mixcomwd_timer_alive = 0; Loading @@ -154,14 +156,15 @@ static int mixcomwd_release(struct inode *inode, struct file *file) { if (expect_close == 42) { if (mixcomwd_timer_alive) { printk(KERN_ERR PFX "release called while internal timer alive"); printk(KERN_ERR PFX "release called while internal timer alive"); return -EBUSY; } mixcomwd_timer_alive = 1; mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); } else { printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); } } else printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); clear_bit(0, &mixcomwd_opened); expect_close = 0; Loading @@ -169,10 +172,10 @@ static int mixcomwd_release(struct inode *inode, struct file *file) } static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { if(len) static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { if (len) { if (!nowayout) { size_t i; Loading @@ -192,7 +195,7 @@ static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t return len; } static int mixcomwd_ioctl(struct inode *inode, struct file *file, static long mixcomwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; Loading @@ -204,26 +207,17 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file, .identity = "MixCOM watchdog", }; switch(cmd) { switch (cmd) { case WDIOC_GETSTATUS: status = mixcomwd_opened; if (!nowayout) { if (!nowayout) status |= mixcomwd_timer_alive; } if (copy_to_user(p, &status, sizeof(int))) { return -EFAULT; } break; return put_user(status, p); case WDIOC_GETBOOTSTATUS: if (copy_to_user(p, &status, sizeof(int))) { return -EFAULT; } break; return put_user(0, p); case WDIOC_GETSUPPORT: if (copy_to_user(argp, &ident, sizeof(ident))) { if (copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; } break; case WDIOC_KEEPALIVE: mixcomwd_ping(); Loading @@ -238,7 +232,7 @@ static const struct file_operations mixcomwd_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = mixcomwd_write, .ioctl = mixcomwd_ioctl, .unlocked_ioctl = mixcomwd_ioctl, .open = mixcomwd_open, .release = mixcomwd_release, }; Loading @@ -253,9 +247,8 @@ static int __init checkcard(int port, int card_id) { int id; if (!request_region(port, 1, "MixCOM watchdog")) { if (!request_region(port, 1, "MixCOM watchdog")) return 0; } id = inb_p(port); if (card_id == MIXCOM_ID) Loading @@ -270,9 +263,7 @@ static int __init checkcard(int port, int card_id) static int __init mixcomwd_init(void) { int i; int ret; int found=0; int i, ret, found = 0; for (i = 0; !found && mixcomwd_io_info[i].ioport != 0; i++) { if (checkcard(mixcomwd_io_info[i].ioport, Loading @@ -283,19 +274,21 @@ static int __init mixcomwd_init(void) } if (!found) { printk(KERN_ERR PFX "No card detected, or port not available.\n"); printk(KERN_ERR PFX "No card detected, or port not available.\n"); return -ENODEV; } ret = misc_register(&mixcomwd_miscdev); if (ret) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", if (ret) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto error_misc_register_watchdog; } printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n", printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n", VERSION, watchdog_port); return 0; Loading Loading
drivers/watchdog/mixcomwd.c +63 −70 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ * - support for one more type board * * Version 0.5 (2001/12/14) Matt Domsch <Matt_Domsch@dell.com> * - added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * - added nowayout module option to override * CONFIG_WATCHDOG_NOWAYOUT * * Version 0.6 (2002/04/12): Rob Radez <rob@osinvestor.com> * - make mixcomwd_opened unsigned, Loading @@ -53,8 +54,8 @@ #include <linux/init.h> #include <linux/jiffies.h> #include <linux/timer.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/uaccess.h> #include <linux/io.h> /* * We have two types of cards that can be probed: Loading Loading @@ -108,7 +109,9 @@ static char expect_close; static int nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, int, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static void mixcomwd_ping(void) { Loading @@ -119,7 +122,6 @@ static void mixcomwd_ping(void) static void mixcomwd_timerfun(unsigned long d) { mixcomwd_ping(); mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); } Loading @@ -129,19 +131,19 @@ static void mixcomwd_timerfun(unsigned long d) static int mixcomwd_open(struct inode *inode, struct file *file) { if(test_and_set_bit(0,&mixcomwd_opened)) { if (test_and_set_bit(0, &mixcomwd_opened)) return -EBUSY; } mixcomwd_ping(); if (nowayout) { if (nowayout) /* * fops_get() code via open() has already done * a try_module_get() so it is safe to do the * __module_get(). */ __module_get(THIS_MODULE); } else { else { if (mixcomwd_timer_alive) { del_timer(&mixcomwd_timer); mixcomwd_timer_alive = 0; Loading @@ -154,14 +156,15 @@ static int mixcomwd_release(struct inode *inode, struct file *file) { if (expect_close == 42) { if (mixcomwd_timer_alive) { printk(KERN_ERR PFX "release called while internal timer alive"); printk(KERN_ERR PFX "release called while internal timer alive"); return -EBUSY; } mixcomwd_timer_alive = 1; mod_timer(&mixcomwd_timer, jiffies + 5 * HZ); } else { printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); } } else printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n"); clear_bit(0, &mixcomwd_opened); expect_close = 0; Loading @@ -169,10 +172,10 @@ static int mixcomwd_release(struct inode *inode, struct file *file) } static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { if(len) static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { if (len) { if (!nowayout) { size_t i; Loading @@ -192,7 +195,7 @@ static ssize_t mixcomwd_write(struct file *file, const char __user *data, size_t return len; } static int mixcomwd_ioctl(struct inode *inode, struct file *file, static long mixcomwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; Loading @@ -204,26 +207,17 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file, .identity = "MixCOM watchdog", }; switch(cmd) { switch (cmd) { case WDIOC_GETSTATUS: status = mixcomwd_opened; if (!nowayout) { if (!nowayout) status |= mixcomwd_timer_alive; } if (copy_to_user(p, &status, sizeof(int))) { return -EFAULT; } break; return put_user(status, p); case WDIOC_GETBOOTSTATUS: if (copy_to_user(p, &status, sizeof(int))) { return -EFAULT; } break; return put_user(0, p); case WDIOC_GETSUPPORT: if (copy_to_user(argp, &ident, sizeof(ident))) { if (copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; } break; case WDIOC_KEEPALIVE: mixcomwd_ping(); Loading @@ -238,7 +232,7 @@ static const struct file_operations mixcomwd_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = mixcomwd_write, .ioctl = mixcomwd_ioctl, .unlocked_ioctl = mixcomwd_ioctl, .open = mixcomwd_open, .release = mixcomwd_release, }; Loading @@ -253,9 +247,8 @@ static int __init checkcard(int port, int card_id) { int id; if (!request_region(port, 1, "MixCOM watchdog")) { if (!request_region(port, 1, "MixCOM watchdog")) return 0; } id = inb_p(port); if (card_id == MIXCOM_ID) Loading @@ -270,9 +263,7 @@ static int __init checkcard(int port, int card_id) static int __init mixcomwd_init(void) { int i; int ret; int found=0; int i, ret, found = 0; for (i = 0; !found && mixcomwd_io_info[i].ioport != 0; i++) { if (checkcard(mixcomwd_io_info[i].ioport, Loading @@ -283,19 +274,21 @@ static int __init mixcomwd_init(void) } if (!found) { printk(KERN_ERR PFX "No card detected, or port not available.\n"); printk(KERN_ERR PFX "No card detected, or port not available.\n"); return -ENODEV; } ret = misc_register(&mixcomwd_miscdev); if (ret) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", if (ret) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto error_misc_register_watchdog; } printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n", printk(KERN_INFO "MixCOM watchdog driver v%s, watchdog port at 0x%3x\n", VERSION, watchdog_port); return 0; Loading