Loading drivers/watchdog/w83977f_wdt.c +111 −114 Original line number Diff line number Diff line Loading @@ -26,10 +26,10 @@ #include <linux/watchdog.h> #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/uaccess.h> #include <linux/io.h> #include <asm/io.h> #include <asm/system.h> #include <asm/uaccess.h> #define WATCHDOG_VERSION "1.00" #define WATCHDOG_NAME "W83977F WDT" Loading @@ -53,13 +53,17 @@ static char expect_close; static DEFINE_SPINLOCK(spinlock); module_param(timeout, int, 0); MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); module_param(testmode, int, 0); MODULE_PARM_DESC(testmode, "Watchdog testmode (1 = no reboot), default=0"); 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) ")"); /* * Start the watchdog Loading Loading @@ -103,8 +107,7 @@ static int wdt_start(void) */ outb_p(DEVICE_REGISTER, IO_INDEX_PORT); outb_p(0x07, IO_DATA_PORT); if (!testmode) { if (!testmode) { unsigned pin_map; outb_p(0xE6, IO_INDEX_PORT); Loading Loading @@ -170,8 +173,7 @@ static int wdt_stop(void) */ outb_p(DEVICE_REGISTER, IO_INDEX_PORT); outb_p(0x07, IO_DATA_PORT); if (!testmode) { if (!testmode) { outb_p(0xE6, IO_INDEX_PORT); outb_p(0x01, IO_DATA_PORT); } Loading Loading @@ -306,13 +308,13 @@ static int wdt_release(struct inode *inode, struct file *file) * Shut off the timer. * Lock it in if it's a module and we set nowayout */ if (expect_close == 42) { if (expect_close == 42) { wdt_stop(); clear_bit(0, &timer_alive); } else { wdt_keepalive(); printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); } expect_close = 0; return 0; Loading @@ -333,26 +335,24 @@ static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { /* See if we got the magic character 'V' and reload the timer */ if(count) { if (!nowayout) { if (count) { if (!nowayout) { size_t ofs; /* note: just in case someone wrote the magic character long ago */ /* note: just in case someone wrote the magic character long ago */ expect_close = 0; /* scan to see whether or not we got the magic character */ for(ofs = 0; ofs != count; ofs++) { /* scan to see whether or not we got the magic character */ for (ofs = 0; ofs != count; ofs++) { char c; if (get_user(c, buf + ofs)) return -EFAULT; if (c == 'V') { if (c == 'V') expect_close = 42; } } } /* someone wrote to us, we should restart timer */ wdt_keepalive(); Loading @@ -377,8 +377,7 @@ static struct watchdog_info ident = { .identity = WATCHDOG_NAME, }; static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int status; int new_options, retval = -EINVAL; Loading @@ -390,13 +389,13 @@ static int wdt_ioctl(struct inode *inode, struct file *file, uarg.i = (int __user *)arg; switch(cmd) { switch (cmd) { default: return -ENOTTY; case WDIOC_GETSUPPORT: return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; case WDIOC_GETSTATUS: wdt_get_status(&status); Loading Loading @@ -449,18 +448,16 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code, return NOTIFY_DONE; } static const struct file_operations wdt_fops= { static const struct file_operations wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = wdt_write, .ioctl = wdt_ioctl, .unlocked_ioctl = wdt_ioctl, .open = wdt_open, .release = wdt_release, }; static struct miscdevice wdt_miscdev= { static struct miscdevice wdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &wdt_fops, Loading @@ -482,12 +479,12 @@ static int __init w83977f_wdt_init(void) */ if (wdt_set_timeout(timeout)) { wdt_set_timeout(DEFAULT_TIMEOUT); printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n", printk(KERN_INFO PFX "timeout value must be 15 <= timeout <= 7635, using %d\n", DEFAULT_TIMEOUT); } if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) { if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) { printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", IO_INDEX_PORT); rc = -EIO; Loading @@ -495,22 +492,22 @@ static int __init w83977f_wdt_init(void) } rc = register_reboot_notifier(&wdt_notifier); if (rc) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", rc); if (rc) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", rc); goto err_out_region; } rc = misc_register(&wdt_miscdev); if (rc) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", if (rc) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", wdt_miscdev.minor, rc); goto err_out_reboot; } printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", timeout, nowayout, testmode); return 0; Loading Loading
drivers/watchdog/w83977f_wdt.c +111 −114 Original line number Diff line number Diff line Loading @@ -26,10 +26,10 @@ #include <linux/watchdog.h> #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/uaccess.h> #include <linux/io.h> #include <asm/io.h> #include <asm/system.h> #include <asm/uaccess.h> #define WATCHDOG_VERSION "1.00" #define WATCHDOG_NAME "W83977F WDT" Loading @@ -53,13 +53,17 @@ static char expect_close; static DEFINE_SPINLOCK(spinlock); module_param(timeout, int, 0); MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); module_param(testmode, int, 0); MODULE_PARM_DESC(testmode, "Watchdog testmode (1 = no reboot), default=0"); 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) ")"); /* * Start the watchdog Loading Loading @@ -103,8 +107,7 @@ static int wdt_start(void) */ outb_p(DEVICE_REGISTER, IO_INDEX_PORT); outb_p(0x07, IO_DATA_PORT); if (!testmode) { if (!testmode) { unsigned pin_map; outb_p(0xE6, IO_INDEX_PORT); Loading Loading @@ -170,8 +173,7 @@ static int wdt_stop(void) */ outb_p(DEVICE_REGISTER, IO_INDEX_PORT); outb_p(0x07, IO_DATA_PORT); if (!testmode) { if (!testmode) { outb_p(0xE6, IO_INDEX_PORT); outb_p(0x01, IO_DATA_PORT); } Loading Loading @@ -306,13 +308,13 @@ static int wdt_release(struct inode *inode, struct file *file) * Shut off the timer. * Lock it in if it's a module and we set nowayout */ if (expect_close == 42) { if (expect_close == 42) { wdt_stop(); clear_bit(0, &timer_alive); } else { wdt_keepalive(); printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); } expect_close = 0; return 0; Loading @@ -333,26 +335,24 @@ static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { /* See if we got the magic character 'V' and reload the timer */ if(count) { if (!nowayout) { if (count) { if (!nowayout) { size_t ofs; /* note: just in case someone wrote the magic character long ago */ /* note: just in case someone wrote the magic character long ago */ expect_close = 0; /* scan to see whether or not we got the magic character */ for(ofs = 0; ofs != count; ofs++) { /* scan to see whether or not we got the magic character */ for (ofs = 0; ofs != count; ofs++) { char c; if (get_user(c, buf + ofs)) return -EFAULT; if (c == 'V') { if (c == 'V') expect_close = 42; } } } /* someone wrote to us, we should restart timer */ wdt_keepalive(); Loading @@ -377,8 +377,7 @@ static struct watchdog_info ident = { .identity = WATCHDOG_NAME, }; static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int status; int new_options, retval = -EINVAL; Loading @@ -390,13 +389,13 @@ static int wdt_ioctl(struct inode *inode, struct file *file, uarg.i = (int __user *)arg; switch(cmd) { switch (cmd) { default: return -ENOTTY; case WDIOC_GETSUPPORT: return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; case WDIOC_GETSTATUS: wdt_get_status(&status); Loading Loading @@ -449,18 +448,16 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code, return NOTIFY_DONE; } static const struct file_operations wdt_fops= { static const struct file_operations wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = wdt_write, .ioctl = wdt_ioctl, .unlocked_ioctl = wdt_ioctl, .open = wdt_open, .release = wdt_release, }; static struct miscdevice wdt_miscdev= { static struct miscdevice wdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &wdt_fops, Loading @@ -482,12 +479,12 @@ static int __init w83977f_wdt_init(void) */ if (wdt_set_timeout(timeout)) { wdt_set_timeout(DEFAULT_TIMEOUT); printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n", printk(KERN_INFO PFX "timeout value must be 15 <= timeout <= 7635, using %d\n", DEFAULT_TIMEOUT); } if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) { if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) { printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", IO_INDEX_PORT); rc = -EIO; Loading @@ -495,22 +492,22 @@ static int __init w83977f_wdt_init(void) } rc = register_reboot_notifier(&wdt_notifier); if (rc) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", rc); if (rc) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", rc); goto err_out_region; } rc = misc_register(&wdt_miscdev); if (rc) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", if (rc) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", wdt_miscdev.minor, rc); goto err_out_reboot; } printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", timeout, nowayout, testmode); return 0; Loading