diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2007-02-09 15:35:36 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-02-09 15:35:36 -0500 |
commit | 9af9fc45ddd3e315c51f87392b5048967e4343cd (patch) | |
tree | 78f00b28dab7d8f222be20d5503570394b586b23 /drivers/char/watchdog/pcwd_usb.c | |
parent | 62d0cfcb27cf755cebdc93ca95dabc83608007cd (diff) | |
parent | f3dc07330c3e43a8d365eaa74693e320e6ed79d9 (diff) |
Merge ../linux-2.6-watchdog-mm
Diffstat (limited to 'drivers/char/watchdog/pcwd_usb.c')
-rw-r--r-- | drivers/char/watchdog/pcwd_usb.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 2da5ac99687c..1ad1f22e97d7 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Berkshire USB-PC Watchdog Card Driver | 2 | * Berkshire USB-PC Watchdog Card Driver |
3 | * | 3 | * |
4 | * (c) Copyright 2004 Wim Van Sebroeck <wim@iguana.be>. | 4 | * (c) Copyright 2004-2007 Wim Van Sebroeck <wim@iguana.be>. |
5 | * | 5 | * |
6 | * Based on source code of the following authors: | 6 | * Based on source code of the following authors: |
7 | * Ken Hollis <kenji@bitgate.com>, | 7 | * Ken Hollis <kenji@bitgate.com>, |
@@ -24,26 +24,25 @@ | |||
24 | * http://www.berkprod.com/ or http://www.pcwatchdog.com/ | 24 | * http://www.berkprod.com/ or http://www.pcwatchdog.com/ |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/kernel.h> | 27 | #include <linux/module.h> /* For module specific items */ |
28 | #include <linux/errno.h> | 28 | #include <linux/moduleparam.h> /* For new moduleparam's */ |
29 | #include <linux/init.h> | 29 | #include <linux/types.h> /* For standard types (like size_t) */ |
30 | #include <linux/slab.h> | 30 | #include <linux/errno.h> /* For the -ENODEV/... values */ |
31 | #include <linux/module.h> | 31 | #include <linux/kernel.h> /* For printk/panic/... */ |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/delay.h> /* For mdelay function */ |
33 | #include <linux/types.h> | 33 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ |
34 | #include <linux/delay.h> | 34 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
35 | #include <linux/miscdevice.h> | 35 | #include <linux/notifier.h> /* For notifier support */ |
36 | #include <linux/watchdog.h> | 36 | #include <linux/reboot.h> /* For reboot_notifier stuff */ |
37 | #include <linux/notifier.h> | 37 | #include <linux/init.h> /* For __init/__exit/... */ |
38 | #include <linux/reboot.h> | 38 | #include <linux/fs.h> /* For file operations */ |
39 | #include <linux/fs.h> | 39 | #include <linux/usb.h> /* For USB functions */ |
40 | #include <linux/smp_lock.h> | 40 | #include <linux/slab.h> /* For kmalloc, ... */ |
41 | #include <linux/completion.h> | 41 | #include <linux/mutex.h> /* For mutex locking */ |
42 | #include <asm/uaccess.h> | ||
43 | #include <linux/usb.h> | ||
44 | #include <linux/mutex.h> | ||
45 | #include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */ | 42 | #include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */ |
46 | 43 | ||
44 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ | ||
45 | |||
47 | 46 | ||
48 | #ifdef CONFIG_USB_DEBUG | 47 | #ifdef CONFIG_USB_DEBUG |
49 | static int debug = 1; | 48 | static int debug = 1; |
@@ -57,8 +56,8 @@ | |||
57 | 56 | ||
58 | 57 | ||
59 | /* Module and Version Information */ | 58 | /* Module and Version Information */ |
60 | #define DRIVER_VERSION "1.01" | 59 | #define DRIVER_VERSION "1.02" |
61 | #define DRIVER_DATE "15 Mar 2005" | 60 | #define DRIVER_DATE "06 Jan 2007" |
62 | #define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>" | 61 | #define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>" |
63 | #define DRIVER_DESC "Berkshire USB-PC Watchdog driver" | 62 | #define DRIVER_DESC "Berkshire USB-PC Watchdog driver" |
64 | #define DRIVER_LICENSE "GPL" | 63 | #define DRIVER_LICENSE "GPL" |
@@ -75,10 +74,10 @@ MODULE_ALIAS_MISCDEV(TEMP_MINOR); | |||
75 | module_param(debug, int, 0); | 74 | module_param(debug, int, 0); |
76 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 75 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
77 | 76 | ||
78 | #define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */ | 77 | #define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ |
79 | static int heartbeat = WATCHDOG_HEARTBEAT; | 78 | static int heartbeat = WATCHDOG_HEARTBEAT; |
80 | module_param(heartbeat, int, 0); | 79 | module_param(heartbeat, int, 0); |
81 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); | 80 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); |
82 | 81 | ||
83 | static int nowayout = WATCHDOG_NOWAYOUT; | 82 | static int nowayout = WATCHDOG_NOWAYOUT; |
84 | module_param(nowayout, int, 0); | 83 | module_param(nowayout, int, 0); |
@@ -110,6 +109,18 @@ MODULE_DEVICE_TABLE (usb, usb_pcwd_table); | |||
110 | #define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ | 109 | #define CMD_ENABLE_WATCHDOG 0x30 /* Enable / Disable Watchdog */ |
111 | #define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG | 110 | #define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG |
112 | 111 | ||
112 | /* Watchdog's Dip Switch heartbeat values */ | ||
113 | static const int heartbeat_tbl [] = { | ||
114 | 5, /* OFF-OFF-OFF = 5 Sec */ | ||
115 | 10, /* OFF-OFF-ON = 10 Sec */ | ||
116 | 30, /* OFF-ON-OFF = 30 Sec */ | ||
117 | 60, /* OFF-ON-ON = 1 Min */ | ||
118 | 300, /* ON-OFF-OFF = 5 Min */ | ||
119 | 600, /* ON-OFF-ON = 10 Min */ | ||
120 | 1800, /* ON-ON-OFF = 30 Min */ | ||
121 | 3600, /* ON-ON-ON = 1 hour */ | ||
122 | }; | ||
123 | |||
113 | /* We can only use 1 card due to the /dev/watchdog restriction */ | 124 | /* We can only use 1 card due to the /dev/watchdog restriction */ |
114 | static int cards_found; | 125 | static int cards_found; |
115 | 126 | ||
@@ -682,6 +693,10 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi | |||
682 | ((option_switches & 0x10) ? "ON" : "OFF"), | 693 | ((option_switches & 0x10) ? "ON" : "OFF"), |
683 | ((option_switches & 0x08) ? "ON" : "OFF")); | 694 | ((option_switches & 0x08) ? "ON" : "OFF")); |
684 | 695 | ||
696 | /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ | ||
697 | if (heartbeat == 0) | ||
698 | heartbeat = heartbeat_tbl[(option_switches & 0x07)]; | ||
699 | |||
685 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | 700 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ |
686 | if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { | 701 | if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { |
687 | usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); | 702 | usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); |