提交 2ef473de 编写于 作者: W Wim Van Sebroeck

[WATCHDOG] pcwd_usb.c - get heartbeat from dip switches

The PCWD cards normally use the heartbeat that is set via
the dip-switches of the card. There are only 3 switches,
thus 8 combinations that each have a certain heartbeat.
The card can however be programmed with a heartbeat from
1 till 65535 seconds. This is what our driver does: it
programs the heartbeat on the card.

There are however a lot of people that don't know that
we set the heartbeat of the watchdog card to the value
provided by the heartbeat module parameter. Instead they
think that the heartbeat value is the same as set by the
dip-switches.

This patch changes the driver so that at startup you can
take the heartbeat from the dip-switches. You do this
by setting the heartbeat module parameter to 0. This
patch also makes this the default behaviour.
Signed-off-by: NWim Van Sebroeck <wim@iguana.be>
上级 d26d9096
/* /*
* Berkshire USB-PC Watchdog Card Driver * Berkshire USB-PC Watchdog Card Driver
* *
* (c) Copyright 2004 Wim Van Sebroeck <wim@iguana.be>. * (c) Copyright 2004-2007 Wim Van Sebroeck <wim@iguana.be>.
* *
* Based on source code of the following authors: * Based on source code of the following authors:
* Ken Hollis <kenji@bitgate.com>, * Ken Hollis <kenji@bitgate.com>,
...@@ -56,8 +56,8 @@ ...@@ -56,8 +56,8 @@
/* Module and Version Information */ /* Module and Version Information */
#define DRIVER_VERSION "1.01" #define DRIVER_VERSION "1.02"
#define DRIVER_DATE "15 Mar 2005" #define DRIVER_DATE "06 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"
...@@ -74,10 +74,10 @@ MODULE_ALIAS_MISCDEV(TEMP_MINOR); ...@@ -74,10 +74,10 @@ 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 2 /* 2 sec default heartbeat */ #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, 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);
...@@ -109,6 +109,18 @@ MODULE_DEVICE_TABLE (usb, usb_pcwd_table); ...@@ -109,6 +109,18 @@ MODULE_DEVICE_TABLE (usb, usb_pcwd_table);
#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
/* Watchdog's Dip Switch heartbeat values */
static const int heartbeat_tbl [] = {
5, /* OFF-OFF-OFF = 5 Sec */
10, /* OFF-OFF-ON = 10 Sec */
30, /* OFF-ON-OFF = 30 Sec */
60, /* OFF-ON-ON = 1 Min */
300, /* ON-OFF-OFF = 5 Min */
600, /* ON-OFF-ON = 10 Min */
1800, /* ON-ON-OFF = 30 Min */
3600, /* ON-ON-ON = 1 hour */
};
/* We can only use 1 card due to the /dev/watchdog restriction */ /* We can only use 1 card due to the /dev/watchdog restriction */
static int cards_found; static int cards_found;
...@@ -681,6 +693,10 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi ...@@ -681,6 +693,10 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
((option_switches & 0x10) ? "ON" : "OFF"), ((option_switches & 0x10) ? "ON" : "OFF"),
((option_switches & 0x08) ? "ON" : "OFF")); ((option_switches & 0x08) ? "ON" : "OFF"));
/* If heartbeat = 0 then we use the heartbeat from the dip-switches */
if (heartbeat == 0)
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册