Commit 143a2e54 authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] More coding-style and trivial clean-up

Some more cleaning-up of the watchdog drivers.
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent d5c26a59
/* /*
* Acquire Single Board Computer Watchdog Timer driver * Acquire Single Board Computer Watchdog Timer driver
* *
* Based on wdt.c. Original copyright messages: * Based on wdt.c. Original copyright messages:
* *
* (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
* All Rights Reserved. * All Rights Reserved.
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
* *
* (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
* *
* 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
* Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
* Can't add timeout - driver doesn't allow changing value * Can't add timeout - driver doesn't allow changing value
*/ */
/* /*
......
...@@ -138,7 +138,9 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -138,7 +138,9 @@ static long advwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int __user *p = argp; int __user *p = argp;
static struct watchdog_info ident = { static struct watchdog_info ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .options = WDIOF_KEEPALIVEPING |
WDIOF_SETTIMEOUT |
WDIOF_MAGICCLOSE,
.firmware_version = 1, .firmware_version = 1,
.identity = WATCHDOG_NAME, .identity = WATCHDOG_NAME,
}; };
...@@ -259,7 +261,8 @@ static int __devinit advwdt_probe(struct platform_device *dev) ...@@ -259,7 +261,8 @@ static int __devinit advwdt_probe(struct platform_device *dev)
goto unreg_stop; goto unreg_stop;
} }
/* 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 (advwdt_set_heartbeat(timeout)) { if (advwdt_set_heartbeat(timeout)) {
advwdt_set_heartbeat(WATCHDOG_TIMEOUT); advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
printk(KERN_INFO PFX printk(KERN_INFO PFX
......
...@@ -60,7 +60,7 @@ static void ali_start(void) ...@@ -60,7 +60,7 @@ static void ali_start(void)
pci_read_config_dword(ali_pci, 0xCC, &val); pci_read_config_dword(ali_pci, 0xCC, &val);
val &= ~0x3F; /* Mask count */ val &= ~0x3F; /* Mask count */
val |= (1<<25) | ali_timeout_bits; val |= (1 << 25) | ali_timeout_bits;
pci_write_config_dword(ali_pci, 0xCC, val); pci_write_config_dword(ali_pci, 0xCC, val);
spin_unlock(&ali_lock); spin_unlock(&ali_lock);
...@@ -79,8 +79,8 @@ static void ali_stop(void) ...@@ -79,8 +79,8 @@ static void ali_stop(void)
spin_lock(&ali_lock); spin_lock(&ali_lock);
pci_read_config_dword(ali_pci, 0xCC, &val); pci_read_config_dword(ali_pci, 0xCC, &val);
val &= ~0x3F; /* Mask count to zero (disabled) */ val &= ~0x3F; /* Mask count to zero (disabled) */
val &= ~(1<<25);/* and for safety mask the reset enable */ val &= ~(1 << 25); /* and for safety mask the reset enable */
pci_write_config_dword(ali_pci, 0xCC, val); pci_write_config_dword(ali_pci, 0xCC, val);
spin_unlock(&ali_lock); spin_unlock(&ali_lock);
...@@ -89,7 +89,7 @@ static void ali_stop(void) ...@@ -89,7 +89,7 @@ static void ali_stop(void)
/* /*
* ali_keepalive - send a keepalive to the watchdog * ali_keepalive - send a keepalive to the watchdog
* *
* Send a keepalive to the timer (actually we restart the timer). * Send a keepalive to the timer (actually we restart the timer).
*/ */
static void ali_keepalive(void) static void ali_keepalive(void)
...@@ -109,11 +109,11 @@ static int ali_settimer(int t) ...@@ -109,11 +109,11 @@ static int ali_settimer(int t)
if (t < 0) if (t < 0)
return -EINVAL; return -EINVAL;
else if (t < 60) else if (t < 60)
ali_timeout_bits = t|(1<<6); ali_timeout_bits = t|(1 << 6);
else if (t < 3600) else if (t < 3600)
ali_timeout_bits = (t/60)|(1<<7); ali_timeout_bits = (t / 60)|(1 << 7);
else if (t < 18000) else if (t < 18000)
ali_timeout_bits = (t/300)|(1<<6)|(1<<7); ali_timeout_bits = (t / 300)|(1 << 6)|(1 << 7);
else else
return -EINVAL; return -EINVAL;
...@@ -138,7 +138,7 @@ static int ali_settimer(int t) ...@@ -138,7 +138,7 @@ static int ali_settimer(int t)
*/ */
static ssize_t ali_write(struct file *file, const char __user *data, static ssize_t ali_write(struct file *file, const char __user *data,
size_t len, loff_t *ppos) size_t len, loff_t *ppos)
{ {
/* See if we got the magic character 'V' and reload the timer */ /* See if we got the magic character 'V' and reload the timer */
if (len) { if (len) {
...@@ -348,9 +348,9 @@ static int __init ali_find_watchdog(void) ...@@ -348,9 +348,9 @@ static int __init ali_find_watchdog(void)
/* Timer bits */ /* Timer bits */
wdog &= ~0x3F; wdog &= ~0x3F;
/* Issued events */ /* Issued events */
wdog &= ~((1<<27)|(1<<26)|(1<<25)|(1<<24)); wdog &= ~((1 << 27)|(1 << 26)|(1 << 25)|(1 << 24));
/* No monitor bits */ /* No monitor bits */
wdog &= ~((1<<16)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)); wdog &= ~((1 << 16)|(1 << 13)|(1 << 12)|(1 << 11)|(1 << 10)|(1 << 9));
pci_write_config_dword(pdev, 0xCC, wdog); pci_write_config_dword(pdev, 0xCC, wdog);
......
...@@ -355,7 +355,8 @@ static int __init alim7101_wdt_init(void) ...@@ -355,7 +355,8 @@ static int __init alim7101_wdt_init(void)
alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
NULL); NULL);
if (!alim7101_pmu) { if (!alim7101_pmu) {
printk(KERN_INFO PFX "ALi M7101 PMU not present - WDT not set\n"); printk(KERN_INFO PFX
"ALi M7101 PMU not present - WDT not set\n");
return -EBUSY; return -EBUSY;
} }
...@@ -399,7 +400,8 @@ static int __init alim7101_wdt_init(void) ...@@ -399,7 +400,8 @@ static int __init alim7101_wdt_init(void)
rc = misc_register(&wdt_miscdev); rc = misc_register(&wdt_miscdev);
if (rc) { if (rc) {
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",
wdt_miscdev.minor, rc); wdt_miscdev.minor, rc);
goto err_out_reboot; goto err_out_reboot;
} }
......
...@@ -201,7 +201,7 @@ static long at91_wdt_ioctl(struct file *file, ...@@ -201,7 +201,7 @@ static long at91_wdt_ioctl(struct file *file,
* Pat the watchdog whenever device is written to. * Pat the watchdog whenever device is written to.
*/ */
static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len,
loff_t *ppos) loff_t *ppos)
{ {
if (!len) if (!len)
return 0; return 0;
......
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
* Based on wdt.c. * Based on wdt.c.
* Original copyright messages: * Original copyright messages:
* *
* (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>, * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
* *
* Neither Alan Cox nor CymruNet Ltd. admit liability nor provide * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
* warranty for any of this software. This material is provided * warranty for any of this software. This material is provided
* "AS-IS" and at no charge. * "AS-IS" and at no charge.
* *
* (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>* * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>*
*/ */
/* Changelog: /* Changelog:
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* add expect_close support * add expect_close support
* *
* 2002.05.30 - Joel Becker <joel.becker@oracle.com> * 2002.05.30 - Joel Becker <joel.becker@oracle.com>
* Added Matt Domsch's nowayout module option. * Added Matt Domsch's nowayout module option.
*/ */
/* /*
...@@ -151,7 +151,7 @@ static void eurwdt_activate_timer(void) ...@@ -151,7 +151,7 @@ static void eurwdt_activate_timer(void)
if (irq == 0) if (irq == 0)
printk(KERN_INFO ": interrupt disabled\n"); printk(KERN_INFO ": interrupt disabled\n");
eurwdt_write_reg(WDT_TIMER_CFG, irq<<4); eurwdt_write_reg(WDT_TIMER_CFG, irq << 4);
eurwdt_write_reg(WDT_UNIT_SEL, WDT_UNIT_SECS); /* we use seconds */ eurwdt_write_reg(WDT_UNIT_SEL, WDT_UNIT_SECS); /* we use seconds */
eurwdt_set_timeout(0); /* the default timeout */ eurwdt_set_timeout(0); /* the default timeout */
......
...@@ -34,11 +34,15 @@ ...@@ -34,11 +34,15 @@
static int timeout = WATCHDOG_TIMEOUT; static int timeout = WATCHDOG_TIMEOUT;
module_param(timeout, int, 0); module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=131, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) "."); MODULE_PARM_DESC(timeout,
"Watchdog timeout in seconds. 1<= timeout <=131, default="
__MODULE_STRING(WATCHDOG_TIMEOUT) ".");
static int nowayout = WATCHDOG_NOWAYOUT; static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); 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 struct platform_device *geodewdt_platform_device; static struct platform_device *geodewdt_platform_device;
static unsigned long wdt_flags; static unsigned long wdt_flags;
...@@ -269,7 +273,8 @@ static int __init geodewdt_init(void) ...@@ -269,7 +273,8 @@ static int __init geodewdt_init(void)
if (ret) if (ret)
return ret; return ret;
geodewdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); geodewdt_platform_device = platform_device_register_simple(DRV_NAME,
-1, NULL, 0);
if (IS_ERR(geodewdt_platform_device)) { if (IS_ERR(geodewdt_platform_device)) {
ret = PTR_ERR(geodewdt_platform_device); ret = PTR_ERR(geodewdt_platform_device);
goto err; goto err;
......
...@@ -137,7 +137,8 @@ static struct pci_device_id hpwdt_devices[] = { ...@@ -137,7 +137,8 @@ static struct pci_device_id hpwdt_devices[] = {
}; };
MODULE_DEVICE_TABLE(pci, hpwdt_devices); MODULE_DEVICE_TABLE(pci, hpwdt_devices);
extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs, unsigned long *pRomEntry); extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
unsigned long *pRomEntry);
#ifndef CONFIG_X86_64 #ifndef CONFIG_X86_64
/* --32 Bit Bios------------------------------------------------------------ */ /* --32 Bit Bios------------------------------------------------------------ */
......
...@@ -240,7 +240,8 @@ static ssize_t esb_write(struct file *file, const char __user *data, ...@@ -240,7 +240,8 @@ static ssize_t esb_write(struct file *file, const char __user *data,
* five months ago... */ * five months ago... */
esb_expect_close = 0; esb_expect_close = 0;
/* scan to see whether or not we got the magic character */ /* scan to see whether or not we got the
* magic character */
for (i = 0; i != len; i++) { for (i = 0; i != len; i++) {
char c; char c;
if (get_user(c, data + i)) if (get_user(c, data + i))
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
static int vendorsupport; static int vendorsupport;
module_param(vendorsupport, int, 0); module_param(vendorsupport, int, 0);
MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default=0 (none), 1=SuperMicro Pent3, 2=SuperMicro Pent4+"); MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default="
"0 (none), 1=SuperMicro Pent3, 2=SuperMicro Pent4+");
/* /*
* Vendor Specific Support * Vendor Specific Support
...@@ -305,7 +306,8 @@ static void __exit iTCO_vendor_exit_module(void) ...@@ -305,7 +306,8 @@ static void __exit iTCO_vendor_exit_module(void)
module_init(iTCO_vendor_init_module); module_init(iTCO_vendor_init_module);
module_exit(iTCO_vendor_exit_module); module_exit(iTCO_vendor_exit_module);
MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, R. Seretny <lkpatches@paypc.com>"); MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, "
"R. Seretny <lkpatches@paypc.com>");
MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support"); MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support");
MODULE_VERSION(DRV_VERSION); MODULE_VERSION(DRV_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -273,7 +273,9 @@ static struct platform_device *iTCO_wdt_platform_device; ...@@ -273,7 +273,9 @@ static struct platform_device *iTCO_wdt_platform_device;
#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */
static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39 (TCO v1) or 613 (TCO v2), default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
"(2<heartbeat<39 (TCO v1) or 613 (TCO v2), default="
__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, int, 0);
...@@ -346,7 +348,8 @@ static int iTCO_wdt_start(void) ...@@ -346,7 +348,8 @@ static int iTCO_wdt_start(void)
/* disable chipset's NO_REBOOT bit */ /* disable chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit()) { if (iTCO_wdt_unset_NO_REBOOT_bit()) {
spin_unlock(&iTCO_wdt_private.io_lock); spin_unlock(&iTCO_wdt_private.io_lock);
printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, "
"reboot disabled by hardware\n");
return -EIO; return -EIO;
} }
...@@ -669,7 +672,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -669,7 +672,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
/* Check chipset's NO_REBOOT bit */ /* Check chipset's NO_REBOOT bit */
if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, "
"reboot disabled by hardware\n");
ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
goto out; goto out;
} }
...@@ -716,8 +720,9 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, ...@@ -716,8 +720,9 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev,
if not reset to the default */ if not reset to the default */
if (iTCO_wdt_set_heartbeat(heartbeat)) { if (iTCO_wdt_set_heartbeat(heartbeat)) {
iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT); iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT);
printk(KERN_INFO PFX "heartbeat value must be 2 < heartbeat < 39 (TCO v1) or 613 (TCO v2), using %d\n", printk(KERN_INFO PFX
heartbeat); "heartbeat value must be 2 < heartbeat < 39 (TCO v1) "
"or 613 (TCO v2), using %d\n", heartbeat);
} }
ret = misc_register(&iTCO_wdt_miscdev); ret = misc_register(&iTCO_wdt_miscdev);
......
...@@ -188,8 +188,8 @@ static inline int superio_inb(int reg) ...@@ -188,8 +188,8 @@ static inline int superio_inb(int reg)
static inline void superio_outb(int val, int reg) static inline void superio_outb(int val, int reg)
{ {
outb(reg, REG); outb(reg, REG);
outb(val, VAL); outb(val, VAL);
} }
static inline int superio_inw(int reg) static inline int superio_inw(int reg)
...@@ -204,10 +204,10 @@ static inline int superio_inw(int reg) ...@@ -204,10 +204,10 @@ static inline int superio_inw(int reg)
static inline void superio_outw(int val, int reg) static inline void superio_outw(int val, int reg)
{ {
outb(reg++, REG); outb(reg++, REG);
outb(val >> 8, VAL); outb(val >> 8, VAL);
outb(reg, REG); outb(reg, REG);
outb(val, VAL); outb(val, VAL);
} }
/* watchdog timer handling */ /* watchdog timer handling */
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include <asm/mpc52xx.h> #include <asm/mpc52xx.h>
#define GPT_MODE_WDT (1<<15) #define GPT_MODE_WDT (1 << 15)
#define GPT_MODE_CE (1<<12) #define GPT_MODE_CE (1 << 12)
#define GPT_MODE_MS_TIMER (0x4) #define GPT_MODE_MS_TIMER (0x4)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Based on the SoftDog driver: * Based on the SoftDog driver:
* (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* All Rights Reserved. * All Rights Reserved.
* http://www.4g-systems.biz * http://www.4g-systems.biz
* *
* (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org> * (C) Copyright 2007 OpenWrt.org, Florian Fainelli <florian@openwrt.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -536,7 +536,8 @@ static int __init pc87413_init(void) ...@@ -536,7 +536,8 @@ static int __init pc87413_init(void)
ret = misc_register(&pc87413_miscdev); ret = misc_register(&pc87413_miscdev);
if (ret != 0) { 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); WATCHDOG_MINOR, ret);
unregister_reboot_notifier(&pc87413_notifier); unregister_reboot_notifier(&pc87413_notifier);
return ret; return ret;
...@@ -574,7 +575,8 @@ static void __exit pc87413_exit(void) ...@@ -574,7 +575,8 @@ static void __exit pc87413_exit(void)
module_init(pc87413_init); module_init(pc87413_init);
module_exit(pc87413_exit); module_exit(pc87413_exit);
MODULE_AUTHOR("Sven Anders <anders@anduras.de>, Marcus Junker <junker@anduras.de>,"); MODULE_AUTHOR("Sven Anders <anders@anduras.de>, "
"Marcus Junker <junker@anduras.de>,");
MODULE_DESCRIPTION("PC87413 WDT driver"); MODULE_DESCRIPTION("PC87413 WDT driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -24,25 +24,25 @@ ...@@ -24,25 +24,25 @@
* version reporting. Added read routine for temperature. * version reporting. Added read routine for temperature.
* Removed some extra defines, added an autodetect Revision * Removed some extra defines, added an autodetect Revision
* routine. * routine.
* 961006 Revised some documentation, fixed some cosmetic bugs. Made * 961006 Revised some documentation, fixed some cosmetic bugs. Made
* drivers to panic the system if it's overheating at bootup. * drivers to panic the system if it's overheating at bootup.
* 961118 Changed some verbiage on some of the output, tidied up * 961118 Changed some verbiage on some of the output, tidied up
* code bits, and added compatibility to 2.1.x. * code bits, and added compatibility to 2.1.x.
* 970912 Enabled board on open and disable on close. * 970912 Enabled board on open and disable on close.
* 971107 Took account of recent VFS changes (broke read). * 971107 Took account of recent VFS changes (broke read).
* 971210 Disable board on initialisation in case board already ticking. * 971210 Disable board on initialisation in case board already ticking.
* 971222 Changed open/close for temperature handling * 971222 Changed open/close for temperature handling
* Michael Meskes <meskes@debian.org>. * Michael Meskes <meskes@debian.org>.
* 980112 Used minor numbers from include/linux/miscdevice.h * 980112 Used minor numbers from include/linux/miscdevice.h
* 990403 Clear reset status after reading control status register in * 990403 Clear reset status after reading control status register in
* pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>] * pcwd_showprevstate(). [Marc Boucher <marc@mbsi.ca>]
* 990605 Made changes to code to support Firmware 1.22a, added * 990605 Made changes to code to support Firmware 1.22a, added
* fairly useless proc entry. * fairly useless proc entry.
* 990610 removed said useless proc code for the merge <alan> * 990610 removed said useless proc code for the merge <alan>
* 000403 Removed last traces of proc code. <davej> * 000403 Removed last traces of proc code. <davej>
* 011214 Added nowayout module option to override * 011214 Added nowayout module option to override
* CONFIG_WATCHDOG_NOWAYOUT <Matt_Domsch@dell.com> * CONFIG_WATCHDOG_NOWAYOUT <Matt_Domsch@dell.com>
* Added timeout module option to override default * Added timeout module option to override default
*/ */
/* /*
...@@ -76,8 +76,7 @@ ...@@ -76,8 +76,7 @@
#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" #define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog"
#define WATCHDOG_NAME "pcwd" #define WATCHDOG_NAME "pcwd"
#define PFX WATCHDOG_NAME ": " #define PFX WATCHDOG_NAME ": "
#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n" #define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n"
#define WD_VER WATCHDOG_VERSION " (" WATCHDOG_DATE ")"
/* /*
* It should be noted that PCWD_REVISION_B was removed because A and B * It should be noted that PCWD_REVISION_B was removed because A and B
...@@ -200,7 +199,9 @@ MODULE_PARM_DESC(debug, ...@@ -200,7 +199,9 @@ MODULE_PARM_DESC(debug,
#define WATCHDOG_HEARTBEAT 0 #define WATCHDOG_HEARTBEAT 0
static int heartbeat = WATCHDOG_HEARTBEAT; static int heartbeat = WATCHDOG_HEARTBEAT;
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2 <= heartbeat <= 7200 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
"(2 <= heartbeat <= 7200 or 0=delay-time from dip-switches, default="
__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); module_param(nowayout, int, 0);
...@@ -239,7 +240,8 @@ static int send_isa_command(int cmd) ...@@ -239,7 +240,8 @@ static int send_isa_command(int cmd)
} }
if (debug >= DEBUG) if (debug >= DEBUG)
printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n", printk(KERN_DEBUG PFX "received following data for "
"cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n",
cmd, port0, last_port0); cmd, port0, last_port0);
return port0; return port0;
...@@ -339,10 +341,12 @@ static void pcwd_show_card_info(void) ...@@ -339,10 +341,12 @@ static void pcwd_show_card_info(void)
pcwd_private.io_addr); pcwd_private.io_addr);
else if (pcwd_private.revision == PCWD_REVISION_C) { else if (pcwd_private.revision == PCWD_REVISION_C) {
pcwd_get_firmware(); pcwd_get_firmware();
printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port "
"0x%04x (Firmware version: %s)\n",
pcwd_private.io_addr, pcwd_private.fw_ver_str); pcwd_private.io_addr, pcwd_private.fw_ver_str);
option_switches = pcwd_get_option_switches(); option_switches = pcwd_get_option_switches();
printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", printk(KERN_INFO PFX "Option switches (0x%02x): "
"Temperature Reset Enable=%s, Power On Delay=%s\n",
option_switches, option_switches,
((option_switches & 0x10) ? "ON" : "OFF"), ((option_switches & 0x10) ? "ON" : "OFF"),
((option_switches & 0x08) ? "ON" : "OFF")); ((option_switches & 0x08) ? "ON" : "OFF"));
...@@ -358,7 +362,8 @@ static void pcwd_show_card_info(void) ...@@ -358,7 +362,8 @@ static void pcwd_show_card_info(void)
printk(KERN_INFO PFX "Temperature Option Detected\n"); printk(KERN_INFO PFX "Temperature Option Detected\n");
if (pcwd_private.boot_status & WDIOF_CARDRESET) if (pcwd_private.boot_status & WDIOF_CARDRESET)
printk(KERN_INFO PFX "Previous reboot was caused by the card\n"); printk(KERN_INFO PFX
"Previous reboot was caused by the card\n");
if (pcwd_private.boot_status & WDIOF_OVERHEAT) { if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
printk(KERN_EMERG PFX printk(KERN_EMERG PFX
...@@ -871,7 +876,7 @@ static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id) ...@@ -871,7 +876,7 @@ static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id)
cards_found++; cards_found++;
if (cards_found == 1) if (cards_found == 1)
printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n", printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n",
WD_VER); WATCHDOG_VERSION);
if (cards_found > 1) { if (cards_found > 1) {
printk(KERN_ERR PFX "This driver only supports 1 device\n"); printk(KERN_ERR PFX "This driver only supports 1 device\n");
...@@ -1026,7 +1031,8 @@ static void __exit pcwd_cleanup_module(void) ...@@ -1026,7 +1031,8 @@ static void __exit pcwd_cleanup_module(void)
module_init(pcwd_init_module); module_init(pcwd_init_module);
module_exit(pcwd_cleanup_module); module_exit(pcwd_cleanup_module);
MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>, Wim Van Sebroeck <wim@iguana.be>"); MODULE_AUTHOR("Ken Hollis <kenji@bitgate.com>, "
"Wim Van Sebroeck <wim@iguana.be>");
MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver"); MODULE_DESCRIPTION("Berkshire ISA-PC Watchdog driver");
MODULE_VERSION(WATCHDOG_VERSION); MODULE_VERSION(WATCHDOG_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
* A bells and whistles driver is available from: * A bells and whistles driver is available from:
* http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/
* *
* More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ * More info available at
* http://www.berkprod.com/ or http://www.pcwatchdog.com/
*/ */
/* /*
...@@ -51,11 +52,10 @@ ...@@ -51,11 +52,10 @@
/* Module and version information */ /* Module and version information */
#define WATCHDOG_VERSION "1.03" #define WATCHDOG_VERSION "1.03"
#define WATCHDOG_DATE "21 Jan 2007"
#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog"
#define WATCHDOG_NAME "pcwd_pci" #define WATCHDOG_NAME "pcwd_pci"
#define PFX WATCHDOG_NAME ": " #define PFX WATCHDOG_NAME ": "
#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n" #define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n"
/* Stuff for the PCI ID's */ /* Stuff for the PCI ID's */
#ifndef PCI_VENDOR_ID_QUICKLOGIC #ifndef PCI_VENDOR_ID_QUICKLOGIC
...@@ -76,7 +76,8 @@ ...@@ -76,7 +76,8 @@
#define WD_PCI_TTRP 0x04 /* Temperature Trip status */ #define WD_PCI_TTRP 0x04 /* Temperature Trip status */
#define WD_PCI_RL2A 0x08 /* Relay 2 Active */ #define WD_PCI_RL2A 0x08 /* Relay 2 Active */
#define WD_PCI_RL1A 0x10 /* Relay 1 Active */ #define WD_PCI_RL1A 0x10 /* Relay 1 Active */
#define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip/reset */ #define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip /
reset */
#define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */ #define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */
/* Port 2 : Control Status #2 */ /* Port 2 : Control Status #2 */
#define WD_PCI_WDIS 0x10 /* Watchdog Disable */ #define WD_PCI_WDIS 0x10 /* Watchdog Disable */
...@@ -114,12 +115,18 @@ static int cards_found; ...@@ -114,12 +115,18 @@ static int cards_found;
static int temp_panic; static int temp_panic;
static unsigned long is_active; static unsigned long is_active;
static char expect_release; static char expect_release;
static struct { /* this is private data for each PCI-PC watchdog card */ /* this is private data for each PCI-PC watchdog card */
int supports_temp; /* Wether or not the card has a temperature device */ static struct {
int boot_status; /* The card's boot status */ /* Wether or not the card has a temperature device */
unsigned long io_addr; /* The cards I/O address */ int supports_temp;
spinlock_t io_lock; /* the lock for io operations */ /* The card's boot status */
struct pci_dev *pdev; /* the PCI-device */ int boot_status;
/* The cards I/O address */
unsigned long io_addr;
/* the lock for io operations */
spinlock_t io_lock;
/* the PCI-device */
struct pci_dev *pdev;
} pcipcwd_private; } pcipcwd_private;
/* module parameters */ /* module parameters */
...@@ -130,14 +137,18 @@ static int debug = QUIET; ...@@ -130,14 +137,18 @@ static int debug = QUIET;
module_param(debug, int, 0); module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)");
#define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ #define WATCHDOG_HEARTBEAT 0 /* default heartbeat =
delay-time from dip-switches */
static int heartbeat = WATCHDOG_HEARTBEAT; static int heartbeat = WATCHDOG_HEARTBEAT;
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
"(0<heartbeat<65536 or 0=delay-time from dip-switches, default="
__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); 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) ")");
/* /*
* Internal functions * Internal functions
...@@ -148,8 +159,8 @@ static int send_command(int cmd, int *msb, int *lsb) ...@@ -148,8 +159,8 @@ static int send_command(int cmd, int *msb, int *lsb)
int got_response, count; int got_response, count;
if (debug >= DEBUG) if (debug >= DEBUG)
printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n", printk(KERN_DEBUG PFX "sending following data "
cmd, *msb, *lsb); "cmd=0x%02x msb=0x%02x lsb=0x%02x\n", cmd, *msb, *lsb);
spin_lock(&pcipcwd_private.io_lock); spin_lock(&pcipcwd_private.io_lock);
/* If a command requires data it should be written first. /* If a command requires data it should be written first.
...@@ -166,17 +177,20 @@ static int send_command(int cmd, int *msb, int *lsb) ...@@ -166,17 +177,20 @@ static int send_command(int cmd, int *msb, int *lsb)
* the WRSP bit in port 2 and give it a max. timeout of * the WRSP bit in port 2 and give it a max. timeout of
* PCI_COMMAND_TIMEOUT to process */ * PCI_COMMAND_TIMEOUT to process */
got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) { for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response);
count++) {
mdelay(1); mdelay(1);
got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
} }
if (debug >= DEBUG) { if (debug >= DEBUG) {
if (got_response) { if (got_response) {
printk(KERN_DEBUG PFX "time to process command was: %d ms\n", printk(KERN_DEBUG PFX
"time to process command was: %d ms\n",
count); count);
} else { } else {
printk(KERN_DEBUG PFX "card did not respond on command!\n"); printk(KERN_DEBUG PFX
"card did not respond on command!\n");
} }
} }
...@@ -189,7 +203,8 @@ static int send_command(int cmd, int *msb, int *lsb) ...@@ -189,7 +203,8 @@ static int send_command(int cmd, int *msb, int *lsb)
inb_p(pcipcwd_private.io_addr + 6); inb_p(pcipcwd_private.io_addr + 6);
if (debug >= DEBUG) if (debug >= DEBUG)
printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", printk(KERN_DEBUG PFX "received following data for "
"cmd=0x%02x: msb=0x%02x lsb=0x%02x\n",
cmd, *msb, *lsb); cmd, *msb, *lsb);
} }
...@@ -218,7 +233,8 @@ static void pcipcwd_show_card_info(void) ...@@ -218,7 +233,8 @@ static void pcipcwd_show_card_info(void)
char fw_ver_str[20]; /* The cards firmware version */ char fw_ver_str[20]; /* The cards firmware version */
int option_switches; int option_switches;
got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major,
&fw_rev_minor);
if (got_fw_rev) if (got_fw_rev)
sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
else else
...@@ -227,23 +243,27 @@ static void pcipcwd_show_card_info(void) ...@@ -227,23 +243,27 @@ static void pcipcwd_show_card_info(void)
/* Get switch settings */ /* Get switch settings */
option_switches = pcipcwd_get_option_switches(); option_switches = pcipcwd_get_option_switches();
printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n", printk(KERN_INFO PFX "Found card at port "
"0x%04x (Firmware: %s) %s temp option\n",
(int) pcipcwd_private.io_addr, fw_ver_str, (int) pcipcwd_private.io_addr, fw_ver_str,
(pcipcwd_private.supports_temp ? "with" : "without")); (pcipcwd_private.supports_temp ? "with" : "without"));
printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", printk(KERN_INFO PFX "Option switches (0x%02x): "
"Temperature Reset Enable=%s, Power On Delay=%s\n",
option_switches, option_switches,
((option_switches & 0x10) ? "ON" : "OFF"), ((option_switches & 0x10) ? "ON" : "OFF"),
((option_switches & 0x08) ? "ON" : "OFF")); ((option_switches & 0x08) ? "ON" : "OFF"));
if (pcipcwd_private.boot_status & WDIOF_CARDRESET) if (pcipcwd_private.boot_status & WDIOF_CARDRESET)
printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n"); printk(KERN_INFO PFX
"Previous reset was caused by the Watchdog card\n");
if (pcipcwd_private.boot_status & WDIOF_OVERHEAT) if (pcipcwd_private.boot_status & WDIOF_OVERHEAT)
printk(KERN_INFO PFX "Card sensed a CPU Overheat\n"); printk(KERN_INFO PFX "Card sensed a CPU Overheat\n");
if (pcipcwd_private.boot_status == 0) if (pcipcwd_private.boot_status == 0)
printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); printk(KERN_INFO PFX
"No previous trip detected - Cold boot or reset\n");
} }
static int pcipcwd_start(void) static int pcipcwd_start(void)
...@@ -283,7 +303,8 @@ static int pcipcwd_stop(void) ...@@ -283,7 +303,8 @@ static int pcipcwd_stop(void)
spin_unlock(&pcipcwd_private.io_lock); spin_unlock(&pcipcwd_private.io_lock);
if (!(stat_reg & WD_PCI_WDIS)) { if (!(stat_reg & WD_PCI_WDIS)) {
printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); printk(KERN_ERR PFX
"Card did not acknowledge disable attempt\n");
return -1; return -1;
} }
...@@ -364,7 +385,8 @@ static int pcipcwd_clear_status(void) ...@@ -364,7 +385,8 @@ static int pcipcwd_clear_status(void)
} }
/* clear trip status & LED and keep mode of relay 2 */ /* clear trip status & LED and keep mode of relay 2 */
outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP,
pcipcwd_private.io_addr + 1);
/* clear reset counter */ /* clear reset counter */
msb = 0; msb = 0;
...@@ -437,7 +459,8 @@ static ssize_t pcipcwd_write(struct file *file, const char __user *data, ...@@ -437,7 +459,8 @@ static ssize_t pcipcwd_write(struct file *file, const char __user *data,
* five months ago... */ * five months ago... */
expect_release = 0; expect_release = 0;
/* scan to see whether or not we got the magic character */ /* scan to see whether or not we got the
* magic character */
for (i = 0; i != len; i++) { for (i = 0; i != len; i++) {
char c; char c;
if (get_user(c, data + i)) if (get_user(c, data + i))
...@@ -531,7 +554,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd, ...@@ -531,7 +554,7 @@ static long pcipcwd_ioctl(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
if (pcipcwd_set_heartbeat(new_heartbeat)) if (pcipcwd_set_heartbeat(new_heartbeat))
return -EINVAL; return -EINVAL;
pcipcwd_keepalive(); pcipcwd_keepalive();
/* Fall */ /* Fall */
...@@ -560,7 +583,8 @@ static int pcipcwd_open(struct inode *inode, struct file *file) ...@@ -560,7 +583,8 @@ static int pcipcwd_open(struct inode *inode, struct file *file)
/* /dev/watchdog can only be opened once */ /* /dev/watchdog can only be opened once */
if (test_and_set_bit(0, &is_active)) { if (test_and_set_bit(0, &is_active)) {
if (debug >= VERBOSE) if (debug >= VERBOSE)
printk(KERN_ERR PFX "Attempt to open already opened device.\n"); printk(KERN_ERR PFX
"Attempt to open already opened device.\n");
return -EBUSY; return -EBUSY;
} }
...@@ -578,7 +602,8 @@ static int pcipcwd_release(struct inode *inode, struct file *file) ...@@ -578,7 +602,8 @@ static int pcipcwd_release(struct inode *inode, struct file *file)
if (expect_release == 42) { if (expect_release == 42) {
pcipcwd_stop(); pcipcwd_stop();
} else { } else {
printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); printk(KERN_CRIT PFX
"Unexpected close, not stopping watchdog!\n");
pcipcwd_keepalive(); pcipcwd_keepalive();
} }
expect_release = 0; expect_release = 0;
...@@ -621,7 +646,8 @@ static int pcipcwd_temp_release(struct inode *inode, struct file *file) ...@@ -621,7 +646,8 @@ static int pcipcwd_temp_release(struct inode *inode, struct file *file)
* Notify system * Notify system
*/ */
static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code,
void *unused)
{ {
if (code == SYS_DOWN || code == SYS_HALT) if (code == SYS_DOWN || code == SYS_HALT)
pcipcwd_stop(); /* Turn the WDT off */ pcipcwd_stop(); /* Turn the WDT off */
...@@ -722,34 +748,38 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev, ...@@ -722,34 +748,38 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev,
/* If heartbeat = 0 then we use the heartbeat from the dip-switches */ /* If heartbeat = 0 then we use the heartbeat from the dip-switches */
if (heartbeat == 0) if (heartbeat == 0)
heartbeat = heartbeat_tbl[(pcipcwd_get_option_switches() & 0x07)]; heartbeat =
heartbeat_tbl[(pcipcwd_get_option_switches() & 0x07)];
/* 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 (pcipcwd_set_heartbeat(heartbeat)) { if (pcipcwd_set_heartbeat(heartbeat)) {
pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT);
printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n", printk(KERN_INFO PFX
"heartbeat value must be 0<heartbeat<65536, using %d\n",
WATCHDOG_HEARTBEAT); WATCHDOG_HEARTBEAT);
} }
ret = register_reboot_notifier(&pcipcwd_notifier); ret = register_reboot_notifier(&pcipcwd_notifier);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX
ret); "cannot register reboot notifier (err=%d)\n", ret);
goto err_out_release_region; goto err_out_release_region;
} }
if (pcipcwd_private.supports_temp) { if (pcipcwd_private.supports_temp) {
ret = misc_register(&pcipcwd_temp_miscdev); ret = misc_register(&pcipcwd_temp_miscdev);
if (ret != 0) { if (ret != 0) {
printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", printk(KERN_ERR PFX "cannot register miscdev on "
TEMP_MINOR, ret); "minor=%d (err=%d)\n", TEMP_MINOR, ret);
goto err_out_unregister_reboot; goto err_out_unregister_reboot;
} }
} }
ret = misc_register(&pcipcwd_miscdev); ret = misc_register(&pcipcwd_miscdev);
if (ret != 0) { 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); WATCHDOG_MINOR, ret);
goto err_out_misc_deregister; goto err_out_misc_deregister;
} }
......
...@@ -51,12 +51,11 @@ ...@@ -51,12 +51,11 @@
/* Use our own dbg macro */ /* Use our own dbg macro */
#undef dbg #undef dbg
#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG PFX format "\n" , ## arg); } while (0) #define dbg(format, arg...) \
do { if (debug) printk(KERN_DEBUG PFX format "\n" , ## arg); } while (0)
/* Module and Version Information */ /* Module and Version Information */
#define DRIVER_VERSION "1.02" #define DRIVER_VERSION "1.02"
#define DRIVER_DATE "21 Jan 2007"
#define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>" #define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>"
#define DRIVER_DESC "Berkshire USB-PC Watchdog driver" #define DRIVER_DESC "Berkshire USB-PC Watchdog driver"
#define DRIVER_LICENSE "GPL" #define DRIVER_LICENSE "GPL"
...@@ -73,14 +72,18 @@ MODULE_ALIAS_MISCDEV(TEMP_MINOR); ...@@ -73,14 +72,18 @@ MODULE_ALIAS_MISCDEV(TEMP_MINOR);
module_param(debug, int, 0); module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Debug enabled or not"); MODULE_PARM_DESC(debug, "Debug enabled or not");
#define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ #define WATCHDOG_HEARTBEAT 0 /* default heartbeat =
delay-time from dip-switches */
static int heartbeat = WATCHDOG_HEARTBEAT; static int heartbeat = WATCHDOG_HEARTBEAT;
module_param(heartbeat, int, 0); module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
"(0<heartbeat<65536 or 0=delay-time from dip-switches, default="
__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
static int nowayout = WATCHDOG_NOWAYOUT; static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); 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) ")");
/* The vendor and product id's for the USB-PC Watchdog card */ /* The vendor and product id's for the USB-PC Watchdog card */
#define USB_PCWD_VENDOR_ID 0x0c98 #define USB_PCWD_VENDOR_ID 0x0c98
...@@ -91,20 +94,21 @@ static struct usb_device_id usb_pcwd_table[] = { ...@@ -91,20 +94,21 @@ static struct usb_device_id usb_pcwd_table[] = {
{ USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) }, { USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) },
{ } /* Terminating entry */ { } /* Terminating entry */
}; };
MODULE_DEVICE_TABLE (usb, usb_pcwd_table); MODULE_DEVICE_TABLE(usb, usb_pcwd_table);
/* according to documentation max. time to process a command for the USB /* according to documentation max. time to process a command for the USB
* watchdog card is 100 or 200 ms, so we give it 250 ms to do it's job */ * watchdog card is 100 or 200 ms, so we give it 250 ms to do it's job */
#define USB_COMMAND_TIMEOUT 250 #define USB_COMMAND_TIMEOUT 250
/* Watchdog's internal commands */ /* Watchdog's internal commands */
#define CMD_READ_TEMP 0x02 /* Read Temperature; Re-trigger Watchdog */ #define CMD_READ_TEMP 0x02 /* Read Temperature;
Re-trigger Watchdog */
#define CMD_TRIGGER CMD_READ_TEMP #define CMD_TRIGGER CMD_READ_TEMP
#define CMD_GET_STATUS 0x04 /* Get Status Information */ #define CMD_GET_STATUS 0x04 /* Get Status Information */
#define CMD_GET_FIRMWARE_VERSION 0x08 /* Get Firmware Version */ #define CMD_GET_FIRMWARE_VERSION 0x08 /* Get Firmware Version */
#define CMD_GET_DIP_SWITCH_SETTINGS 0x0c /* Get Dip Switch Settings */ #define CMD_GET_DIP_SWITCH_SETTINGS 0x0c /* Get Dip Switch Settings */
#define CMD_READ_WATCHDOG_TIMEOUT 0x18 /* Read Current Watchdog Time */ #define CMD_READ_WATCHDOG_TIMEOUT 0x18 /* Read Current Watchdog Time */
#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 /* Write Current Watchdog Time */ #define CMD_WRITE_WATCHDOG_TIMEOUT 0x19 /* Write Current WatchdogTime */
#define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ #define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */
#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG #define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG
...@@ -129,23 +133,36 @@ static char expect_release; ...@@ -129,23 +133,36 @@ static char expect_release;
/* Structure to hold all of our device specific stuff */ /* Structure to hold all of our device specific stuff */
struct usb_pcwd_private { struct usb_pcwd_private {
struct usb_device *udev; /* save off the usb device pointer */ /* save off the usb device pointer */
struct usb_interface *interface; /* the interface for this device */ struct usb_device *udev;
/* the interface for this device */
unsigned int interface_number; /* the interface number used for cmd's */ struct usb_interface *interface;
unsigned char *intr_buffer; /* the buffer to intr data */ /* the interface number used for cmd's */
dma_addr_t intr_dma; /* the dma address for the intr buffer */ unsigned int interface_number;
size_t intr_size; /* the size of the intr buffer */
struct urb *intr_urb; /* the urb used for the intr pipe */ /* the buffer to intr data */
unsigned char *intr_buffer;
unsigned char cmd_command; /* The command that is reported back */ /* the dma address for the intr buffer */
unsigned char cmd_data_msb; /* The data MSB that is reported back */ dma_addr_t intr_dma;
unsigned char cmd_data_lsb; /* The data LSB that is reported back */ /* the size of the intr buffer */
atomic_t cmd_received; /* true if we received a report after a command */ size_t intr_size;
/* the urb used for the intr pipe */
int exists; /* Wether or not the device exists */ struct urb *intr_urb;
struct mutex mtx; /* locks this structure */
/* The command that is reported back */
unsigned char cmd_command;
/* The data MSB that is reported back */
unsigned char cmd_data_msb;
/* The data LSB that is reported back */
unsigned char cmd_data_lsb;
/* true if we received a report after a command */
atomic_t cmd_received;
/* Wether or not the device exists */
int exists;
/* locks this structure */
struct mutex mtx;
}; };
static struct usb_pcwd_private *usb_pcwd_device; static struct usb_pcwd_private *usb_pcwd_device;
...@@ -153,7 +170,8 @@ static struct usb_pcwd_private *usb_pcwd_device; ...@@ -153,7 +170,8 @@ static struct usb_pcwd_private *usb_pcwd_device;
static DEFINE_MUTEX(disconnect_mutex); static DEFINE_MUTEX(disconnect_mutex);
/* local function prototypes */ /* local function prototypes */
static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_device_id *id); static int usb_pcwd_probe(struct usb_interface *interface,
const struct usb_device_id *id);
static void usb_pcwd_disconnect(struct usb_interface *interface); static void usb_pcwd_disconnect(struct usb_interface *interface);
/* usb specific object needed to register this driver with the usb subsystem */ /* usb specific object needed to register this driver with the usb subsystem */
...@@ -167,7 +185,8 @@ static struct usb_driver usb_pcwd_driver = { ...@@ -167,7 +185,8 @@ static struct usb_driver usb_pcwd_driver = {
static void usb_pcwd_intr_done(struct urb *urb) static void usb_pcwd_intr_done(struct urb *urb)
{ {
struct usb_pcwd_private *usb_pcwd = (struct usb_pcwd_private *)urb->context; struct usb_pcwd_private *usb_pcwd =
(struct usb_pcwd_private *)urb->context;
unsigned char *data = usb_pcwd->intr_buffer; unsigned char *data = usb_pcwd->intr_buffer;
int retval; int retval;
...@@ -178,11 +197,13 @@ static void usb_pcwd_intr_done(struct urb *urb) ...@@ -178,11 +197,13 @@ static void usb_pcwd_intr_done(struct urb *urb)
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
/* this urb is terminated, clean up */ /* this urb is terminated, clean up */
dbg("%s - urb shutting down with status: %d", __func__, urb->status); dbg("%s - urb shutting down with status: %d", __func__,
urb->status);
return; return;
/* -EPIPE: should clear the halt */ /* -EPIPE: should clear the halt */
default: /* error */ default: /* error */
dbg("%s - nonzero urb status received: %d", __func__, urb->status); dbg("%s - nonzero urb status received: %d", __func__,
urb->status);
goto resubmit; goto resubmit;
} }
...@@ -199,22 +220,23 @@ static void usb_pcwd_intr_done(struct urb *urb) ...@@ -199,22 +220,23 @@ static void usb_pcwd_intr_done(struct urb *urb)
resubmit: resubmit:
retval = usb_submit_urb(urb, GFP_ATOMIC); retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval) if (retval)
printk(KERN_ERR PFX "can't resubmit intr, usb_submit_urb failed with result %d\n", printk(KERN_ERR PFX "can't resubmit intr, "
retval); "usb_submit_urb failed with result %d\n", retval);
} }
static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned char cmd, static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
unsigned char *msb, unsigned char *lsb) unsigned char cmd, unsigned char *msb, unsigned char *lsb)
{ {
int got_response, count; int got_response, count;
unsigned char buf[6]; unsigned char buf[6];
/* We will not send any commands if the USB PCWD device does not exist */ /* We will not send any commands if the USB PCWD device does
* not exist */
if ((!usb_pcwd) || (!usb_pcwd->exists)) if ((!usb_pcwd) || (!usb_pcwd->exists))
return -1; return -1;
/* The USB PC Watchdog uses a 6 byte report format. The board currently uses /* The USB PC Watchdog uses a 6 byte report format.
* only 3 of the six bytes of the report. */ * The board currently uses only 3 of the six bytes of the report. */
buf[0] = cmd; /* Byte 0 = CMD */ buf[0] = cmd; /* Byte 0 = CMD */
buf[1] = *msb; /* Byte 1 = Data MSB */ buf[1] = *msb; /* Byte 1 = Data MSB */
buf[2] = *lsb; /* Byte 2 = Data LSB */ buf[2] = *lsb; /* Byte 2 = Data LSB */
...@@ -229,12 +251,14 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned cha ...@@ -229,12 +251,14 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned cha
HID_REQ_SET_REPORT, HID_DT_REPORT, HID_REQ_SET_REPORT, HID_DT_REPORT,
0x0200, usb_pcwd->interface_number, buf, sizeof(buf), 0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
USB_COMMAND_TIMEOUT) != sizeof(buf)) { USB_COMMAND_TIMEOUT) != sizeof(buf)) {
dbg("usb_pcwd_send_command: error in usb_control_msg for cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb); dbg("usb_pcwd_send_command: error in usb_control_msg for "
"cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
} }
/* wait till the usb card processed the command, /* wait till the usb card processed the command,
* with a max. timeout of USB_COMMAND_TIMEOUT */ * with a max. timeout of USB_COMMAND_TIMEOUT */
got_response = 0; got_response = 0;
for (count = 0; (count < USB_COMMAND_TIMEOUT) && (!got_response); count++) { for (count = 0; (count < USB_COMMAND_TIMEOUT) && (!got_response);
count++) {
mdelay(1); mdelay(1);
if (atomic_read(&usb_pcwd->cmd_received)) if (atomic_read(&usb_pcwd->cmd_received))
got_response = 1; got_response = 1;
...@@ -256,10 +280,12 @@ static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd) ...@@ -256,10 +280,12 @@ static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd)
int retval; int retval;
/* Enable Watchdog */ /* Enable Watchdog */
retval = usb_pcwd_send_command(usb_pcwd, CMD_ENABLE_WATCHDOG, &msb, &lsb); retval = usb_pcwd_send_command(usb_pcwd, CMD_ENABLE_WATCHDOG,
&msb, &lsb);
if ((retval == 0) || (lsb == 0)) { if ((retval == 0) || (lsb == 0)) {
printk(KERN_ERR PFX "Card did not acknowledge enable attempt\n"); printk(KERN_ERR PFX
"Card did not acknowledge enable attempt\n");
return -1; return -1;
} }
...@@ -273,10 +299,12 @@ static int usb_pcwd_stop(struct usb_pcwd_private *usb_pcwd) ...@@ -273,10 +299,12 @@ static int usb_pcwd_stop(struct usb_pcwd_private *usb_pcwd)
int retval; int retval;
/* Disable Watchdog */ /* Disable Watchdog */
retval = usb_pcwd_send_command(usb_pcwd, CMD_DISABLE_WATCHDOG, &msb, &lsb); retval = usb_pcwd_send_command(usb_pcwd, CMD_DISABLE_WATCHDOG,
&msb, &lsb);
if ((retval == 0) || (lsb != 0)) { if ((retval == 0) || (lsb != 0)) {
printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); printk(KERN_ERR PFX
"Card did not acknowledge disable attempt\n");
return -1; return -1;
} }
...@@ -308,7 +336,8 @@ static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t) ...@@ -308,7 +336,8 @@ static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t)
return 0; return 0;
} }
static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temperature) static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd,
int *temperature)
{ {
unsigned char msb, lsb; unsigned char msb, lsb;
...@@ -323,7 +352,8 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp ...@@ -323,7 +352,8 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp
return 0; return 0;
} }
static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_left) static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
int *time_left)
{ {
unsigned char msb, lsb; unsigned char msb, lsb;
...@@ -341,7 +371,7 @@ static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_le ...@@ -341,7 +371,7 @@ static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_le
*/ */
static ssize_t usb_pcwd_write(struct file *file, const char __user *data, static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
size_t len, loff_t *ppos) size_t len, loff_t *ppos)
{ {
/* See if we got the magic character 'V' and reload the timer */ /* See if we got the magic character 'V' and reload the timer */
if (len) { if (len) {
...@@ -352,7 +382,8 @@ static ssize_t usb_pcwd_write(struct file *file, const char __user *data, ...@@ -352,7 +382,8 @@ static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
* five months ago... */ * five months ago... */
expect_release = 0; expect_release = 0;
/* scan to see whether or not we got the magic character */ /* scan to see whether or not we got the
* magic character */
for (i = 0; i != len; i++) { for (i = 0; i != len; i++) {
char c; char c;
if (get_user(c, data + i)) if (get_user(c, data + i))
...@@ -431,7 +462,7 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd, ...@@ -431,7 +462,7 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
if (usb_pcwd_set_heartbeat(usb_pcwd_device, new_heartbeat)) if (usb_pcwd_set_heartbeat(usb_pcwd_device, new_heartbeat))
return -EINVAL; return -EINVAL;
usb_pcwd_keepalive(usb_pcwd_device); usb_pcwd_keepalive(usb_pcwd_device);
/* Fall */ /* Fall */
...@@ -475,7 +506,8 @@ static int usb_pcwd_release(struct inode *inode, struct file *file) ...@@ -475,7 +506,8 @@ static int usb_pcwd_release(struct inode *inode, struct file *file)
if (expect_release == 42) { if (expect_release == 42) {
usb_pcwd_stop(usb_pcwd_device); usb_pcwd_stop(usb_pcwd_device);
} else { } else {
printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); printk(KERN_CRIT PFX
"Unexpected close, not stopping watchdog!\n");
usb_pcwd_keepalive(usb_pcwd_device); usb_pcwd_keepalive(usb_pcwd_device);
} }
expect_release = 0; expect_release = 0;
...@@ -515,7 +547,8 @@ static int usb_pcwd_temperature_release(struct inode *inode, struct file *file) ...@@ -515,7 +547,8 @@ static int usb_pcwd_temperature_release(struct inode *inode, struct file *file)
* Notify system * Notify system
*/ */
static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code,
void *unused)
{ {
if (code == SYS_DOWN || code == SYS_HALT) if (code == SYS_DOWN || code == SYS_HALT)
usb_pcwd_stop(usb_pcwd_device); /* Turn the WDT off */ usb_pcwd_stop(usb_pcwd_device); /* Turn the WDT off */
...@@ -578,7 +611,8 @@ static inline void usb_pcwd_delete(struct usb_pcwd_private *usb_pcwd) ...@@ -578,7 +611,8 @@ static inline void usb_pcwd_delete(struct usb_pcwd_private *usb_pcwd)
* Called by the usb core when a new device is connected that it thinks * Called by the usb core when a new device is connected that it thinks
* this driver might be interested in. * this driver might be interested in.
*/ */
static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_device_id *id) static int usb_pcwd_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{ {
struct usb_device *udev = interface_to_usbdev(interface); struct usb_device *udev = interface_to_usbdev(interface);
struct usb_host_interface *iface_desc; struct usb_host_interface *iface_desc;
...@@ -602,7 +636,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -602,7 +636,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
/* check out that we have a HID device */ /* check out that we have a HID device */
if (!(iface_desc->desc.bInterfaceClass == USB_CLASS_HID)) { if (!(iface_desc->desc.bInterfaceClass == USB_CLASS_HID)) {
printk(KERN_ERR PFX "The device isn't a Human Interface Device\n"); printk(KERN_ERR PFX
"The device isn't a Human Interface Device\n");
return -ENODEV; return -ENODEV;
} }
...@@ -632,10 +667,12 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -632,10 +667,12 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
usb_pcwd->udev = udev; usb_pcwd->udev = udev;
usb_pcwd->interface = interface; usb_pcwd->interface = interface;
usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber; usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber;
usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ?
le16_to_cpu(endpoint->wMaxPacketSize) : 8);
/* set up the memory buffer's */ /* set up the memory buffer's */
usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma); usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size,
GFP_ATOMIC, &usb_pcwd->intr_dma);
if (!usb_pcwd->intr_buffer) { if (!usb_pcwd->intr_buffer) {
printk(KERN_ERR PFX "Out of memory\n"); printk(KERN_ERR PFX "Out of memory\n");
goto error; goto error;
...@@ -669,7 +706,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -669,7 +706,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
usb_pcwd_stop(usb_pcwd); usb_pcwd_stop(usb_pcwd);
/* Get the Firmware Version */ /* Get the Firmware Version */
got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION,
&fw_rev_major, &fw_rev_minor);
if (got_fw_rev) if (got_fw_rev)
sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
else else
...@@ -679,9 +717,11 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -679,9 +717,11 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
fw_ver_str); fw_ver_str);
/* Get switch settings */ /* Get switch settings */
usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy, &option_switches); usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy,
&option_switches);
printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", printk(KERN_INFO PFX "Option switches (0x%02x): "
"Temperature Reset Enable=%s, Power On Delay=%s\n",
option_switches, option_switches,
((option_switches & 0x10) ? "ON" : "OFF"), ((option_switches & 0x10) ? "ON" : "OFF"),
((option_switches & 0x08) ? "ON" : "OFF")); ((option_switches & 0x08) ? "ON" : "OFF"));
...@@ -690,30 +730,35 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -690,30 +730,35 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
if (heartbeat == 0) if (heartbeat == 0)
heartbeat = heartbeat_tbl[(option_switches & 0x07)]; heartbeat = heartbeat_tbl[(option_switches & 0x07)];
/* 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 (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) {
usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT);
printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n", printk(KERN_INFO PFX
"heartbeat value must be 0<heartbeat<65536, using %d\n",
WATCHDOG_HEARTBEAT); WATCHDOG_HEARTBEAT);
} }
retval = register_reboot_notifier(&usb_pcwd_notifier); retval = register_reboot_notifier(&usb_pcwd_notifier);
if (retval != 0) { if (retval != 0) {
printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", printk(KERN_ERR PFX
"cannot register reboot notifier (err=%d)\n",
retval); retval);
goto error; goto error;
} }
retval = misc_register(&usb_pcwd_temperature_miscdev); retval = misc_register(&usb_pcwd_temperature_miscdev);
if (retval != 0) { if (retval != 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",
TEMP_MINOR, retval); TEMP_MINOR, retval);
goto err_out_unregister_reboot; goto err_out_unregister_reboot;
} }
retval = misc_register(&usb_pcwd_miscdev); retval = misc_register(&usb_pcwd_miscdev);
if (retval != 0) { if (retval != 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, retval); WATCHDOG_MINOR, retval);
goto err_out_misc_deregister; goto err_out_misc_deregister;
} }
...@@ -799,7 +844,7 @@ static int __init usb_pcwd_init(void) ...@@ -799,7 +844,7 @@ static int __init usb_pcwd_init(void)
return result; return result;
} }
printk(KERN_INFO PFX DRIVER_DESC " v" DRIVER_VERSION " (" DRIVER_DATE ")\n"); printk(KERN_INFO PFX DRIVER_DESC " v" DRIVER_VERSION "\n");
return 0; return 0;
} }
......
...@@ -54,22 +54,22 @@ ...@@ -54,22 +54,22 @@
/* WDTIM_CTRL bit definitions */ /* WDTIM_CTRL bit definitions */
#define COUNT_ENAB 1 #define COUNT_ENAB 1
#define RESET_COUNT (1<<1) #define RESET_COUNT (1 << 1)
#define DEBUG_EN (1<<2) #define DEBUG_EN (1 << 2)
/* WDTIM_MCTRL bit definitions */ /* WDTIM_MCTRL bit definitions */
#define MR0_INT 1 #define MR0_INT 1
#undef RESET_COUNT0 #undef RESET_COUNT0
#define RESET_COUNT0 (1<<2) #define RESET_COUNT0 (1 << 2)
#define STOP_COUNT0 (1<<2) #define STOP_COUNT0 (1 << 2)
#define M_RES1 (1<<3) #define M_RES1 (1 << 3)
#define M_RES2 (1<<4) #define M_RES2 (1 << 4)
#define RESFRC1 (1<<5) #define RESFRC1 (1 << 5)
#define RESFRC2 (1<<6) #define RESFRC2 (1 << 6)
/* WDTIM_EMR bit definitions */ /* WDTIM_EMR bit definitions */
#define EXT_MATCH0 1 #define EXT_MATCH0 1
#define MATCH_OUTPUT_HIGH (2<<4) /*a MATCH_CTRL setting */ #define MATCH_OUTPUT_HIGH (2 << 4) /*a MATCH_CTRL setting */
/* WDTIM_RES bit definitions */ /* WDTIM_RES bit definitions */
#define WDOG_RESET 1 /* read only */ #define WDOG_RESET 1 /* read only */
......
...@@ -146,7 +146,8 @@ static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -146,7 +146,8 @@ static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return 0; return 0;
} }
static ssize_t riowd_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) static ssize_t riowd_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{ {
struct riowd *p = riowd_device; struct riowd *p = riowd_device;
......
/* /*
* Watchdog driver for the SA11x0/PXA2xx * Watchdog driver for the SA11x0/PXA2xx
* *
* (c) Copyright 2000 Oleg Drokin <green@crimea.edu> * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
* Based on SoftDog driver by Alan Cox <alan@lxorguk.ukuu.org.uk> * Based on SoftDog driver by Alan Cox <alan@lxorguk.ukuu.org.uk>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* (c) Copyright 2000 Oleg Drokin <green@crimea.edu> * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
* *
* 27/11/2000 Initial release * 27/11/2000 Initial release
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
......
/* /*
* 60xx Single Board Computer Watchdog Timer driver for Linux 2.2.x * 60xx Single Board Computer Watchdog Timer driver for Linux 2.2.x
* *
* Based on acquirewdt.c by Alan Cox. * Based on acquirewdt.c by Alan Cox.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
* (c) Copyright 2005 Webcon, Inc. * (c) Copyright 2005 Webcon, Inc.
* *
* Based on ib700wdt.c, which is based on advantechwdt.c which is based * Based on ib700wdt.c, which is based on advantechwdt.c which is based
* on acquirewdt.c which is based on wdt.c. * on acquirewdt.c which is based on wdt.c.
* *
* (c) Copyright 2001 Charles Howes <chowes@vsol.net> * (c) Copyright 2001 Charles Howes <chowes@vsol.net>
* *
* Based on advantechwdt.c which is based on acquirewdt.c which * Based on advantechwdt.c which is based on acquirewdt.c which
* is based on wdt.c. * is based on wdt.c.
* *
* (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl> * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl>
* *
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
* *
* (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
* *
* 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
* Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
* Added timeout module option to override default * Added timeout module option to override default
* *
*/ */
......
...@@ -35,7 +35,8 @@ static int epx_c3_alive; ...@@ -35,7 +35,8 @@ static int epx_c3_alive;
static int nowayout = WATCHDOG_NOWAYOUT; static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0); 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) ")");
#define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */ #define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */
#define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */ #define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#define UART2_IRQ 0x04 /* Serial1 */ #define UART2_IRQ 0x04 /* Serial1 */
/* 5 -7 are reserved */ /* 5 -7 are reserved */
static char banner[] __initdata = KERN_INFO PFX SC1200_MODULE_VER; static char banner[] __initdata = PFX SC1200_MODULE_VER;
static int timeout = 1; static int timeout = 1;
static int io = -1; static int io = -1;
static int io_len = 2; /* for non plug and play */ static int io_len = 2; /* for non plug and play */
...@@ -392,7 +392,7 @@ static int __init sc1200wdt_init(void) ...@@ -392,7 +392,7 @@ static int __init sc1200wdt_init(void)
{ {
int ret; int ret;
printk("%s\n", banner); printk(KERN_INFO "%s\n", banner);
#if defined CONFIG_PNP #if defined CONFIG_PNP
if (isapnp) { if (isapnp) {
...@@ -477,6 +477,7 @@ module_init(sc1200wdt_init); ...@@ -477,6 +477,7 @@ module_init(sc1200wdt_init);
module_exit(sc1200wdt_exit); module_exit(sc1200wdt_exit);
MODULE_AUTHOR("Zwane Mwaikambo <zwane@commfireservices.com>"); MODULE_AUTHOR("Zwane Mwaikambo <zwane@commfireservices.com>");
MODULE_DESCRIPTION("Driver for National Semiconductor PC87307/PC97307 watchdog component"); MODULE_DESCRIPTION(
"Driver for National Semiconductor PC87307/PC97307 watchdog component");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
/* /*
* AMD Elan SC520 processor Watchdog Timer driver * AMD Elan SC520 processor Watchdog Timer driver
* *
* Based on acquirewdt.c by Alan Cox, * Based on acquirewdt.c by Alan Cox,
* and sbc60xxwdt.c by Jakob Oestergaard <jakob@unthought.net> * and sbc60xxwdt.c by Jakob Oestergaard <jakob@unthought.net>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* The authors do NOT admit liability nor provide warranty for * The authors do NOT admit liability nor provide warranty for
* any of this software. This material is provided "AS-IS" in * any of this software. This material is provided "AS-IS" in
* the hope that it may be useful for others. * the hope that it may be useful for others.
* *
* (c) Copyright 2001 Scott Jennings <linuxdrivers@oro.net> * (c) Copyright 2001 Scott Jennings <linuxdrivers@oro.net>
* 9/27 - 2001 [Initial release] * 9/27 - 2001 [Initial release]
...@@ -438,6 +438,7 @@ module_init(sc520_wdt_init); ...@@ -438,6 +438,7 @@ module_init(sc520_wdt_init);
module_exit(sc520_wdt_unload); module_exit(sc520_wdt_unload);
MODULE_AUTHOR("Scott and Bill Jennings"); MODULE_AUTHOR("Scott and Bill Jennings");
MODULE_DESCRIPTION("Driver for watchdog timer in AMD \"Elan\" SC520 uProcessor"); MODULE_DESCRIPTION(
"Driver for watchdog timer in AMD \"Elan\" SC520 uProcessor");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x * SMsC 37B787 Watchdog Timer driver for Linux 2.6.x.x
* *
* Based on acquirewdt.c by Alan Cox <alan@lxorguk.ukuu.org.uk> * Based on acquirewdt.c by Alan Cox <alan@lxorguk.ukuu.org.uk>
* and some other existing drivers * and some other existing drivers
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* The authors do NOT admit liability nor provide warranty for * The authors do NOT admit liability nor provide warranty for
* any of this software. This material is provided "AS-IS" in * any of this software. This material is provided "AS-IS" in
* the hope that it may be useful for others. * the hope that it may be useful for others.
* *
* (C) Copyright 2003-2006 Sven Anders <anders@anduras.de> * (C) Copyright 2003-2006 Sven Anders <anders@anduras.de>
* *
...@@ -22,19 +22,19 @@ ...@@ -22,19 +22,19 @@
* *
* Theory of operation: * Theory of operation:
* *
* A Watchdog Timer (WDT) is a hardware circuit that can * A Watchdog Timer (WDT) is a hardware circuit that can
* reset the computer system in case of a software fault. * reset the computer system in case of a software fault.
* You probably knew that already. * You probably knew that already.
* *
* Usually a userspace daemon will notify the kernel WDT driver * Usually a userspace daemon will notify the kernel WDT driver
* via the /dev/watchdog special device file that userspace is * via the /dev/watchdog special device file that userspace is
* still alive, at regular intervals. When such a notification * still alive, at regular intervals. When such a notification
* occurs, the driver will usually tell the hardware watchdog * occurs, the driver will usually tell the hardware watchdog
* that everything is in order, and that the watchdog should wait * that everything is in order, and that the watchdog should wait
* for yet another little while to reset the system. * for yet another little while to reset the system.
* If userspace fails (RAM error, kernel bug, whatever), the * If userspace fails (RAM error, kernel bug, whatever), the
* notifications cease to occur, and the hardware watchdog will * notifications cease to occur, and the hardware watchdog will
* reset the system (causing a reboot) after the timeout occurs. * reset the system (causing a reboot) after the timeout occurs.
* *
* Create device with: * Create device with:
* mknod /dev/watchdog c 10 130 * mknod /dev/watchdog c 10 130
...@@ -485,7 +485,7 @@ static long wb_smsc_wdt_ioctl(struct file *file, ...@@ -485,7 +485,7 @@ static long wb_smsc_wdt_ioctl(struct file *file,
case WDIOC_GETTIMEOUT: case WDIOC_GETTIMEOUT:
new_timeout = timeout; new_timeout = timeout;
if (unit == UNIT_MINUTE) if (unit == UNIT_MINUTE)
new_timeout *= 60; new_timeout *= 60;
return put_user(new_timeout, uarg.i); return put_user(new_timeout, uarg.i);
default: default:
return -ENOTTY; return -ENOTTY;
......
/* /*
* SoftDog 0.07: A Software Watchdog Device * SoftDog 0.07: A Software Watchdog Device
* *
* (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>, All Rights Reserved. * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
* All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
* Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT. * Added WDIOC_GETTIMEOUT and WDIOC_SETTIMOUT.
* *
* 20020530 Joel Becker <joel.becker@oracle.com> * 20020530 Joel Becker <joel.becker@oracle.com>
* Added Matt Domsch's nowayout module option. * Added Matt Domsch's nowayout module option.
*/ */
#include <linux/module.h> #include <linux/module.h>
......
...@@ -462,6 +462,7 @@ module_init(wdt_init); ...@@ -462,6 +462,7 @@ module_init(wdt_init);
module_exit(wdt_exit); module_exit(wdt_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, Samuel Tardieu <sam@rfc1149.net>"); MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, "
"Samuel Tardieu <sam@rfc1149.net>");
MODULE_DESCRIPTION("w83697hf/hg WDT driver"); MODULE_DESCRIPTION("w83697hf/hg WDT driver");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* w83697ug/uf WDT driver * w83697ug/uf WDT driver
* *
* (c) Copyright 2008 Flemming Fransen <ff@nrvissing.net> * (c) Copyright 2008 Flemming Fransen <ff@nrvissing.net>
* reused original code to supoprt w83697ug/uf. * reused original code to support w83697ug/uf.
* *
* Based on w83627hf_wdt.c which is based on advantechwdt.c * Based on w83627hf_wdt.c which is based on advantechwdt.c
* which is based on wdt.c. * which is based on wdt.c.
......
...@@ -426,7 +426,7 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -426,7 +426,7 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return -EFAULT; return -EFAULT;
if (wdt_set_timeout(new_timeout)) if (wdt_set_timeout(new_timeout))
return -EINVAL; return -EINVAL;
wdt_keepalive(); wdt_keepalive();
/* Fall */ /* Fall */
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
* *
* http://www.cymru.net * http://www.cymru.net
* *
* This driver is provided under the GNU General Public License, incorporated * This driver is provided under the GNU General Public License,
* herein by reference. The driver is provided without warranty or * incorporated herein by reference. The driver is provided without
* support. * warranty or support.
* *
* Release 0.04. * Release 0.04.
* *
...@@ -39,13 +39,13 @@ ...@@ -39,13 +39,13 @@
/* programmable outputs: */ /* programmable outputs: */
#define WDT_PROGOUT (io+15) /* wr=enable, rd=disable */ #define WDT_PROGOUT (io+15) /* wr=enable, rd=disable */
/* FAN 501 500 */ /* FAN 501 500 */
#define WDC_SR_WCCR 1 /* Active low */ /* X X X */ #define WDC_SR_WCCR 1 /* Active low */ /* X X X */
#define WDC_SR_TGOOD 2 /* X X - */ #define WDC_SR_TGOOD 2 /* X X - */
#define WDC_SR_ISOI0 4 /* X X X */ #define WDC_SR_ISOI0 4 /* X X X */
#define WDC_SR_ISII1 8 /* X X X */ #define WDC_SR_ISII1 8 /* X X X */
#define WDC_SR_FANGOOD 16 /* X - - */ #define WDC_SR_FANGOOD 16 /* X - - */
#define WDC_SR_PSUOVER 32 /* Active low */ /* X X - */ #define WDC_SR_PSUOVER 32 /* Active low */ /* X X - */
#define WDC_SR_PSUUNDR 64 /* Active low */ /* X X - */ #define WDC_SR_PSUUNDR 64 /* Active low */ /* X X - */
#define WDC_SR_IRQ 128 /* Active low */ /* X X X */ #define WDC_SR_IRQ 128 /* Active low */ /* X X X */
...@@ -401,7 +401,7 @@ static long wdt977_ioctl(struct file *file, unsigned int cmd, ...@@ -401,7 +401,7 @@ static long wdt977_ioctl(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
if (wdt977_set_timeout(new_timeout)) if (wdt977_set_timeout(new_timeout))
return -EINVAL; return -EINVAL;
wdt977_keepalive(); wdt977_keepalive();
/* Fall */ /* Fall */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment