Loading drivers/watchdog/eurotechwdt.c +36 −21 Original line number Diff line number Diff line Loading @@ -56,14 +56,15 @@ #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/init.h> #include <linux/io.h> #include <linux/uaccess.h> #include <asm/io.h> #include <asm/uaccess.h> #include <asm/system.h> static unsigned long eurwdt_is_open; static int eurwdt_timeout; static char eur_expect_close; static spinlock_t eurwdt_lock; /* * You must set these - there is no sane way to probe for this board. Loading @@ -78,7 +79,9 @@ static char *ev = "int"; 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) ")"); /* * Some symbolic names Loading Loading @@ -137,7 +140,8 @@ static void eurwdt_activate_timer(void) { eurwdt_disable_timer(); eurwdt_write_reg(WDT_CTRL_REG, 0x01); /* activate the WDT */ eurwdt_write_reg(WDT_OUTPIN_CFG, !strcmp("int", ev) ? WDT_EVENT_INT : WDT_EVENT_REBOOT); eurwdt_write_reg(WDT_OUTPIN_CFG, !strcmp("int", ev) ? WDT_EVENT_INT : WDT_EVENT_REBOOT); /* Setting interrupt line */ if (irq == 2 || irq > 15 || irq < 0) { Loading Loading @@ -212,15 +216,15 @@ size_t count, loff_t *ppos) eur_expect_close = 42; } } spin_lock(&eurwdt_lock); eurwdt_ping(); /* the default timeout */ spin_unlock(&eurwdt_lock); } return count; } /** * eurwdt_ioctl: * @inode: inode of the device * @file: file handle to the device * @cmd: watchdog command * @arg: argument pointer Loading @@ -229,13 +233,14 @@ size_t count, loff_t *ppos) * according to their available features. */ static int eurwdt_ioctl(struct inode *inode, struct file *file, static long eurwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; static struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .firmware_version = 1, .identity = "WDT Eurotech CPU-1220/1410", }; Loading @@ -255,7 +260,9 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, return put_user(0, p); case WDIOC_KEEPALIVE: spin_lock(&eurwdt_lock); eurwdt_ping(); spin_unlock(&eurwdt_lock); return 0; case WDIOC_SETTIMEOUT: Loading @@ -266,8 +273,10 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, if (time < 0 || time > 255) return -EINVAL; spin_lock(&eurwdt_lock); eurwdt_timeout = time; eurwdt_set_timeout(time); spin_unlock(&eurwdt_lock); /* Fall */ case WDIOC_GETTIMEOUT: Loading @@ -276,6 +285,7 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, case WDIOC_SETOPTIONS: if (get_user(options, p)) return -EFAULT; spin_lock(&eurwdt_lock); if (options & WDIOS_DISABLECARD) { eurwdt_disable_timer(); retval = 0; Loading @@ -285,6 +295,7 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, eurwdt_ping(); retval = 0; } spin_unlock(&eurwdt_lock); return retval; } } Loading Loading @@ -322,10 +333,11 @@ static int eurwdt_open(struct inode *inode, struct file *file) static int eurwdt_release(struct inode *inode, struct file *file) { if (eur_expect_close == 42) { if (eur_expect_close == 42) eurwdt_disable_timer(); } else { printk(KERN_CRIT "eurwdt: Unexpected close, not stopping watchdog!\n"); else { printk(KERN_CRIT "eurwdt: Unexpected close, not stopping watchdog!\n"); eurwdt_ping(); } clear_bit(0, &eurwdt_is_open); Loading Loading @@ -365,7 +377,7 @@ static const struct file_operations eurwdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = eurwdt_write, .ioctl = eurwdt_ioctl, .unlocked_ioctl = eurwdt_ioctl, .open = eurwdt_open, .release = eurwdt_release, }; Loading Loading @@ -432,10 +444,13 @@ static int __init eurwdt_init(void) ret = register_reboot_notifier(&eurwdt_notifier); if (ret) { printk(KERN_ERR "eurwdt: can't register reboot notifier (err=%d)\n", ret); printk(KERN_ERR "eurwdt: can't register reboot notifier (err=%d)\n", ret); goto outreg; } spin_lock_init(&eurwdt_lock); ret = misc_register(&eurwdt_miscdev); if (ret) { printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", Loading Loading
drivers/watchdog/eurotechwdt.c +36 −21 Original line number Diff line number Diff line Loading @@ -56,14 +56,15 @@ #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/init.h> #include <linux/io.h> #include <linux/uaccess.h> #include <asm/io.h> #include <asm/uaccess.h> #include <asm/system.h> static unsigned long eurwdt_is_open; static int eurwdt_timeout; static char eur_expect_close; static spinlock_t eurwdt_lock; /* * You must set these - there is no sane way to probe for this board. Loading @@ -78,7 +79,9 @@ static char *ev = "int"; 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) ")"); /* * Some symbolic names Loading Loading @@ -137,7 +140,8 @@ static void eurwdt_activate_timer(void) { eurwdt_disable_timer(); eurwdt_write_reg(WDT_CTRL_REG, 0x01); /* activate the WDT */ eurwdt_write_reg(WDT_OUTPIN_CFG, !strcmp("int", ev) ? WDT_EVENT_INT : WDT_EVENT_REBOOT); eurwdt_write_reg(WDT_OUTPIN_CFG, !strcmp("int", ev) ? WDT_EVENT_INT : WDT_EVENT_REBOOT); /* Setting interrupt line */ if (irq == 2 || irq > 15 || irq < 0) { Loading Loading @@ -212,15 +216,15 @@ size_t count, loff_t *ppos) eur_expect_close = 42; } } spin_lock(&eurwdt_lock); eurwdt_ping(); /* the default timeout */ spin_unlock(&eurwdt_lock); } return count; } /** * eurwdt_ioctl: * @inode: inode of the device * @file: file handle to the device * @cmd: watchdog command * @arg: argument pointer Loading @@ -229,13 +233,14 @@ size_t count, loff_t *ppos) * according to their available features. */ static int eurwdt_ioctl(struct inode *inode, struct file *file, static long eurwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; static struct watchdog_info ident = { .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .firmware_version = 1, .identity = "WDT Eurotech CPU-1220/1410", }; Loading @@ -255,7 +260,9 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, return put_user(0, p); case WDIOC_KEEPALIVE: spin_lock(&eurwdt_lock); eurwdt_ping(); spin_unlock(&eurwdt_lock); return 0; case WDIOC_SETTIMEOUT: Loading @@ -266,8 +273,10 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, if (time < 0 || time > 255) return -EINVAL; spin_lock(&eurwdt_lock); eurwdt_timeout = time; eurwdt_set_timeout(time); spin_unlock(&eurwdt_lock); /* Fall */ case WDIOC_GETTIMEOUT: Loading @@ -276,6 +285,7 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, case WDIOC_SETOPTIONS: if (get_user(options, p)) return -EFAULT; spin_lock(&eurwdt_lock); if (options & WDIOS_DISABLECARD) { eurwdt_disable_timer(); retval = 0; Loading @@ -285,6 +295,7 @@ static int eurwdt_ioctl(struct inode *inode, struct file *file, eurwdt_ping(); retval = 0; } spin_unlock(&eurwdt_lock); return retval; } } Loading Loading @@ -322,10 +333,11 @@ static int eurwdt_open(struct inode *inode, struct file *file) static int eurwdt_release(struct inode *inode, struct file *file) { if (eur_expect_close == 42) { if (eur_expect_close == 42) eurwdt_disable_timer(); } else { printk(KERN_CRIT "eurwdt: Unexpected close, not stopping watchdog!\n"); else { printk(KERN_CRIT "eurwdt: Unexpected close, not stopping watchdog!\n"); eurwdt_ping(); } clear_bit(0, &eurwdt_is_open); Loading Loading @@ -365,7 +377,7 @@ static const struct file_operations eurwdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = eurwdt_write, .ioctl = eurwdt_ioctl, .unlocked_ioctl = eurwdt_ioctl, .open = eurwdt_open, .release = eurwdt_release, }; Loading Loading @@ -432,10 +444,13 @@ static int __init eurwdt_init(void) ret = register_reboot_notifier(&eurwdt_notifier); if (ret) { printk(KERN_ERR "eurwdt: can't register reboot notifier (err=%d)\n", ret); printk(KERN_ERR "eurwdt: can't register reboot notifier (err=%d)\n", ret); goto outreg; } spin_lock_init(&eurwdt_lock); ret = misc_register(&eurwdt_miscdev); if (ret) { printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", Loading