Loading drivers/watchdog/i6300esb.c +167 −175 Original line number Diff line number Diff line Loading @@ -38,9 +38,8 @@ #include <linux/init.h> #include <linux/pci.h> #include <linux/ioport.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/uaccess.h> #include <linux/io.h> /* Module and version information */ #define ESB_VERSION "0.03" Loading Loading @@ -84,14 +83,20 @@ static unsigned short triggered; /* The status of the watchdog upon boot */ static char esb_expect_close; /* module parameters */ #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (1<heartbeat<2*1023) */ /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ #define WATCHDOG_HEARTBEAT 30 static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ module_param(heartbeat, int, 0); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 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 i6300ESB specific functions Loading @@ -114,7 +119,6 @@ static void esb_timer_start(void) /* Enable or Enable + Lock? */ val = 0x02 | (nowayout ? 0x01 : 0x00); pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); } Loading Loading @@ -211,10 +215,11 @@ static int esb_open (struct inode *inode, struct file *file) static int esb_release(struct inode *inode, struct file *file) { /* Shut off the timer. */ if (esb_expect_close == 42) { if (esb_expect_close == 42) esb_timer_stop(); } else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); esb_timer_keepalive(); } clear_bit(0, &timer_alive); Loading Loading @@ -250,8 +255,7 @@ static ssize_t esb_write (struct file *file, const char __user *data, return len; } static int esb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int new_options, retval = -EINVAL; int new_heartbeat; Loading Loading @@ -295,25 +299,19 @@ static int esb_ioctl (struct inode *inode, struct file *file, esb_timer_start(); retval = 0; } return retval; } case WDIOC_SETTIMEOUT: { if (get_user(new_heartbeat, p)) return -EFAULT; if (esb_timer_set_heartbeat(new_heartbeat)) return -EINVAL; esb_timer_keepalive(); /* Fall */ } case WDIOC_GETTIMEOUT: return put_user(heartbeat, p); default: return -ENOTTY; } Loading @@ -323,13 +321,13 @@ static int esb_ioctl (struct inode *inode, struct file *file, * Notify system */ static int esb_notify_sys (struct notifier_block *this, unsigned long code, void *unused) static int esb_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { if (code == SYS_DOWN || code == SYS_HALT) { /* Turn the WDT off */ esb_timer_stop(); } return NOTIFY_DONE; } Loading @@ -341,7 +339,7 @@ static const struct file_operations esb_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = esb_write, .ioctl = esb_ioctl, .unlocked_ioctl = esb_ioctl, .open = esb_open, .release = esb_release, }; Loading Loading @@ -378,18 +376,12 @@ static unsigned char __init esb_getdevice (void) { u8 val1; unsigned short val2; struct pci_dev *dev = NULL; /* * Find the PCI device */ for_each_pci_dev(dev) { if (pci_match_id(esb_pci_tbl, dev)) { esb_pci = dev; break; } } esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9, NULL); if (esb_pci) { if (pci_enable_device(esb_pci)) { Loading Loading @@ -460,32 +452,32 @@ static int __init watchdog_init (void) if (!esb_getdevice() || esb_pci == NULL) return -ENODEV; /* Check that the heartbeat value is within it's range ; if not reset to the default */ /* Check that the heartbeat value is within it's range; if not reset to the default */ if (esb_timer_set_heartbeat(heartbeat)) { esb_timer_set_heartbeat(WATCHDOG_HEARTBEAT); printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n", printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n", heartbeat); } ret = register_reboot_notifier(&esb_notifier); if (ret != 0) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); goto err_unmap; } ret = misc_register(&esb_miscdev); if (ret != 0) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto err_notifier; } esb_timer_stop(); printk (KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", printk(KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", BASEADDR, heartbeat, nowayout); return 0; err_notifier: Loading Loading
drivers/watchdog/i6300esb.c +167 −175 Original line number Diff line number Diff line Loading @@ -38,9 +38,8 @@ #include <linux/init.h> #include <linux/pci.h> #include <linux/ioport.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/uaccess.h> #include <linux/io.h> /* Module and version information */ #define ESB_VERSION "0.03" Loading Loading @@ -84,14 +83,20 @@ static unsigned short triggered; /* The status of the watchdog upon boot */ static char esb_expect_close; /* module parameters */ #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (1<heartbeat<2*1023) */ /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ #define WATCHDOG_HEARTBEAT 30 static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ module_param(heartbeat, int, 0); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 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 i6300ESB specific functions Loading @@ -114,7 +119,6 @@ static void esb_timer_start(void) /* Enable or Enable + Lock? */ val = 0x02 | (nowayout ? 0x01 : 0x00); pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); } Loading Loading @@ -211,10 +215,11 @@ static int esb_open (struct inode *inode, struct file *file) static int esb_release(struct inode *inode, struct file *file) { /* Shut off the timer. */ if (esb_expect_close == 42) { if (esb_expect_close == 42) esb_timer_stop(); } else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); else { printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); esb_timer_keepalive(); } clear_bit(0, &timer_alive); Loading Loading @@ -250,8 +255,7 @@ static ssize_t esb_write (struct file *file, const char __user *data, return len; } static int esb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int new_options, retval = -EINVAL; int new_heartbeat; Loading Loading @@ -295,25 +299,19 @@ static int esb_ioctl (struct inode *inode, struct file *file, esb_timer_start(); retval = 0; } return retval; } case WDIOC_SETTIMEOUT: { if (get_user(new_heartbeat, p)) return -EFAULT; if (esb_timer_set_heartbeat(new_heartbeat)) return -EINVAL; esb_timer_keepalive(); /* Fall */ } case WDIOC_GETTIMEOUT: return put_user(heartbeat, p); default: return -ENOTTY; } Loading @@ -323,13 +321,13 @@ static int esb_ioctl (struct inode *inode, struct file *file, * Notify system */ static int esb_notify_sys (struct notifier_block *this, unsigned long code, void *unused) static int esb_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { if (code == SYS_DOWN || code == SYS_HALT) { /* Turn the WDT off */ esb_timer_stop(); } return NOTIFY_DONE; } Loading @@ -341,7 +339,7 @@ static const struct file_operations esb_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = esb_write, .ioctl = esb_ioctl, .unlocked_ioctl = esb_ioctl, .open = esb_open, .release = esb_release, }; Loading Loading @@ -378,18 +376,12 @@ static unsigned char __init esb_getdevice (void) { u8 val1; unsigned short val2; struct pci_dev *dev = NULL; /* * Find the PCI device */ for_each_pci_dev(dev) { if (pci_match_id(esb_pci_tbl, dev)) { esb_pci = dev; break; } } esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9, NULL); if (esb_pci) { if (pci_enable_device(esb_pci)) { Loading Loading @@ -460,32 +452,32 @@ static int __init watchdog_init (void) if (!esb_getdevice() || esb_pci == NULL) return -ENODEV; /* Check that the heartbeat value is within it's range ; if not reset to the default */ /* Check that the heartbeat value is within it's range; if not reset to the default */ if (esb_timer_set_heartbeat(heartbeat)) { esb_timer_set_heartbeat(WATCHDOG_HEARTBEAT); printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n", printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n", heartbeat); } ret = register_reboot_notifier(&esb_notifier); if (ret != 0) { printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret); goto err_unmap; } ret = misc_register(&esb_miscdev); if (ret != 0) { printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", WATCHDOG_MINOR, ret); goto err_notifier; } esb_timer_stop(); printk (KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", printk(KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", BASEADDR, heartbeat, nowayout); return 0; err_notifier: Loading