aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2008-10-15 07:44:40 -0400
committerWim Van Sebroeck <wim@iguana.be>2008-12-31 11:12:16 -0500
commit794db26f20b7dbb879f4e1911221e1959818dfdb (patch)
tree2e78ac503dc21fdce9f796fe72ea852416ce85e0 /drivers
parent6a94cb73064c952255336cc57731904174b2c58f (diff)
[WATCHDOG] ib700wdt - add timeout parameter
Add the timeout module parameter to ib700wdt.c Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/watchdog/ib700wdt.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/watchdog/ib700wdt.c b/drivers/watchdog/ib700wdt.c
index 317ef2b16cff..4bef3ddff4a5 100644
--- a/drivers/watchdog/ib700wdt.c
+++ b/drivers/watchdog/ib700wdt.c
@@ -91,32 +91,16 @@ static char expect_close;
91 * 91 *
92 */ 92 */
93 93
94static int wd_times[] = {
95 30, /* 0x0 */
96 28, /* 0x1 */
97 26, /* 0x2 */
98 24, /* 0x3 */
99 22, /* 0x4 */
100 20, /* 0x5 */
101 18, /* 0x6 */
102 16, /* 0x7 */
103 14, /* 0x8 */
104 12, /* 0x9 */
105 10, /* 0xA */
106 8, /* 0xB */
107 6, /* 0xC */
108 4, /* 0xD */
109 2, /* 0xE */
110 0, /* 0xF */
111};
112
113#define WDT_STOP 0x441 94#define WDT_STOP 0x441
114#define WDT_START 0x443 95#define WDT_START 0x443
115 96
116/* Default timeout */ 97/* Default timeout */
117#define WD_TIMO 0 /* 30 seconds +/- 20%, from table */ 98#define WATCHDOG_TIMEOUT 30 /* 30 seconds +/- 20% */
118 99static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
119static int wd_margin = WD_TIMO; 100module_param(timeout, int, 0);
101MODULE_PARM_DESC(timeout,
102 "Watchdog timeout in seconds. 0<= timeout <=30, default="
103 __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
120 104
121static int nowayout = WATCHDOG_NOWAYOUT; 105static int nowayout = WATCHDOG_NOWAYOUT;
122module_param(nowayout, int, 0); 106module_param(nowayout, int, 0);
@@ -131,6 +115,8 @@ MODULE_PARM_DESC(nowayout,
131 115
132static void ibwdt_ping(void) 116static void ibwdt_ping(void)
133{ 117{
118 int wd_margin = 15 - ((timeout + 1) / 2);
119
134 spin_lock(&ibwdt_lock); 120 spin_lock(&ibwdt_lock);
135 121
136 /* Write a watchdog value */ 122 /* Write a watchdog value */
@@ -148,15 +134,10 @@ static void ibwdt_disable(void)
148 134
149static int ibwdt_set_heartbeat(int t) 135static int ibwdt_set_heartbeat(int t)
150{ 136{
151 int i; 137 if (t < 0 || t > 30)
152
153 if ((t < 0) || (t > 30))
154 return -EINVAL; 138 return -EINVAL;
155 139
156 for (i = 0x0F; i > -1; i--) 140 timeout = t;
157 if (wd_times[i] >= t)
158 break;
159 wd_margin = i;
160 return 0; 141 return 0;
161} 142}
162 143
@@ -240,7 +221,7 @@ static long ibwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
240 /* Fall */ 221 /* Fall */
241 222
242 case WDIOC_GETTIMEOUT: 223 case WDIOC_GETTIMEOUT:
243 return put_user(wd_times[wd_margin], p); 224 return put_user(timeout, p);
244 225
245 default: 226 default:
246 return -ENOTTY; 227 return -ENOTTY;
@@ -317,6 +298,14 @@ static int __devinit ibwdt_probe(struct platform_device *dev)
317 goto out_nostartreg; 298 goto out_nostartreg;
318 } 299 }
319 300
301 /* Check that the heartbeat value is within it's range ;
302 * if not reset to the default */
303 if (ibwdt_set_heartbeat(timeout)) {
304 ibwdt_set_heartbeat(WATCHDOG_TIMEOUT);
305 printk(KERN_INFO PFX
306 "timeout value must be 0<=x<=30, using %d\n", timeout);
307 }
308
320 res = misc_register(&ibwdt_miscdev); 309 res = misc_register(&ibwdt_miscdev);
321 if (res) { 310 if (res) {
322 printk(KERN_ERR PFX "failed to register misc device\n"); 311 printk(KERN_ERR PFX "failed to register misc device\n");