diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2012-03-22 15:42:16 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-03-27 14:15:57 -0400 |
commit | dddbc6a0513b25c80e73e14ee704186deedc0d00 (patch) | |
tree | 369ee13682bb2fafc13ba10347943e3ab74464f9 | |
parent | 15b25701b282bd761a82c6508529b2145744075f (diff) |
watchdog: coh901327_wdt.c: fix timeout
Set the timeout value properly so that we don't get faulty values
for the WDIOC_GETTIMEOUT iotcl. 'margin' should be an unsigned int.
Also add a check to see if margin is a valid parameter after it is
loaded as a module.
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
-rw-r--r-- | drivers/watchdog/coh901327_wdt.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c index 7f0cbeb58770..6876430a9f5e 100644 --- a/drivers/watchdog/coh901327_wdt.c +++ b/drivers/watchdog/coh901327_wdt.c | |||
@@ -67,7 +67,7 @@ | |||
67 | #define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U | 67 | #define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U |
68 | 68 | ||
69 | /* Default timeout in seconds = 1 minute */ | 69 | /* Default timeout in seconds = 1 minute */ |
70 | static int margin = 60; | 70 | static unsigned int margin = 60; |
71 | static resource_size_t phybase; | 71 | static resource_size_t phybase; |
72 | static resource_size_t physize; | 72 | static resource_size_t physize; |
73 | static int irq; | 73 | static int irq; |
@@ -153,7 +153,7 @@ static void coh901327_disable(void) | |||
153 | 153 | ||
154 | static int coh901327_start(struct watchdog_device *wdt_dev) | 154 | static int coh901327_start(struct watchdog_device *wdt_dev) |
155 | { | 155 | { |
156 | coh901327_enable(margin * 100); | 156 | coh901327_enable(wdt_dev->timeout * 100); |
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | 159 | ||
@@ -176,10 +176,10 @@ static int coh901327_ping(struct watchdog_device *wdd) | |||
176 | static int coh901327_settimeout(struct watchdog_device *wdt_dev, | 176 | static int coh901327_settimeout(struct watchdog_device *wdt_dev, |
177 | unsigned int time) | 177 | unsigned int time) |
178 | { | 178 | { |
179 | margin = time; | 179 | wdt_dev->timeout = time; |
180 | clk_enable(clk); | 180 | clk_enable(clk); |
181 | /* Set new timeout value */ | 181 | /* Set new timeout value */ |
182 | writew(margin * 100, virtbase + U300_WDOG_TR); | 182 | writew(time * 100, virtbase + U300_WDOG_TR); |
183 | /* Feed the dog */ | 183 | /* Feed the dog */ |
184 | writew(U300_WDOG_FR_FEED_RESTART_TIMER, | 184 | writew(U300_WDOG_FR_FEED_RESTART_TIMER, |
185 | virtbase + U300_WDOG_FR); | 185 | virtbase + U300_WDOG_FR); |
@@ -250,7 +250,7 @@ static struct watchdog_device coh901327_wdt = { | |||
250 | .info = &coh901327_ident, | 250 | .info = &coh901327_ident, |
251 | .ops = &coh901327_ops, | 251 | .ops = &coh901327_ops, |
252 | /* | 252 | /* |
253 | * Max margin is 327 since the 10ms | 253 | * Max timeout is 327 since the 10ms |
254 | * timeout register is max | 254 | * timeout register is max |
255 | * 0x7FFF = 327670ms ~= 327s. | 255 | * 0x7FFF = 327670ms ~= 327s. |
256 | */ | 256 | */ |
@@ -353,6 +353,10 @@ static int __init coh901327_probe(struct platform_device *pdev) | |||
353 | 353 | ||
354 | clk_disable(clk); | 354 | clk_disable(clk); |
355 | 355 | ||
356 | if (margin < 1 || margin > 327) | ||
357 | margin = 60; | ||
358 | coh901327_wdt.timeout = margin; | ||
359 | |||
356 | ret = watchdog_register_device(&coh901327_wdt); | 360 | ret = watchdog_register_device(&coh901327_wdt); |
357 | if (ret == 0) | 361 | if (ret == 0) |
358 | dev_info(&pdev->dev, | 362 | dev_info(&pdev->dev, |
@@ -461,7 +465,7 @@ module_exit(coh901327_exit); | |||
461 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); | 465 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); |
462 | MODULE_DESCRIPTION("COH 901 327 Watchdog"); | 466 | MODULE_DESCRIPTION("COH 901 327 Watchdog"); |
463 | 467 | ||
464 | module_param(margin, int, 0); | 468 | module_param(margin, uint, 0); |
465 | MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); | 469 | MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); |
466 | 470 | ||
467 | MODULE_LICENSE("GPL"); | 471 | MODULE_LICENSE("GPL"); |