aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/alim7101_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/alim7101_wdt.c')
-rw-r--r--drivers/watchdog/alim7101_wdt.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c
index 46f4b85b46de..b9e9558ab218 100644
--- a/drivers/watchdog/alim7101_wdt.c
+++ b/drivers/watchdog/alim7101_wdt.c
@@ -19,6 +19,8 @@
19 * -- Mike Waychison <michael.waychison@sun.com> 19 * -- Mike Waychison <michael.waychison@sun.com>
20 */ 20 */
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/module.h> 24#include <linux/module.h>
23#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
24#include <linux/types.h> 26#include <linux/types.h>
@@ -36,9 +38,6 @@
36 38
37#include <asm/system.h> 39#include <asm/system.h>
38 40
39#define OUR_NAME "alim7101_wdt"
40#define PFX OUR_NAME ": "
41
42#define WDT_ENABLE 0x9C 41#define WDT_ENABLE 0x9C
43#define WDT_DISABLE 0x8C 42#define WDT_DISABLE 0x8C
44 43
@@ -79,8 +78,8 @@ static unsigned long wdt_is_open;
79static char wdt_expect_close; 78static char wdt_expect_close;
80static struct pci_dev *alim7101_pmu; 79static struct pci_dev *alim7101_pmu;
81 80
82static int nowayout = WATCHDOG_NOWAYOUT; 81static bool nowayout = WATCHDOG_NOWAYOUT;
83module_param(nowayout, int, 0); 82module_param(nowayout, bool, 0);
84MODULE_PARM_DESC(nowayout, 83MODULE_PARM_DESC(nowayout,
85 "Watchdog cannot be stopped once started (default=" 84 "Watchdog cannot be stopped once started (default="
86 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 85 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
@@ -112,8 +111,7 @@ static void wdt_timer_ping(unsigned long data)
112 ALI_7101_GPIO_O, tmp & ~0x20); 111 ALI_7101_GPIO_O, tmp & ~0x20);
113 } 112 }
114 } else { 113 } else {
115 printk(KERN_WARNING PFX 114 pr_warn("Heartbeat lost! Will not ping the watchdog\n");
116 "Heartbeat lost! Will not ping the watchdog\n");
117 } 115 }
118 /* Re-set the timer interval */ 116 /* Re-set the timer interval */
119 mod_timer(&timer, jiffies + WDT_INTERVAL); 117 mod_timer(&timer, jiffies + WDT_INTERVAL);
@@ -162,7 +160,7 @@ static void wdt_startup(void)
162 /* Start the timer */ 160 /* Start the timer */
163 mod_timer(&timer, jiffies + WDT_INTERVAL); 161 mod_timer(&timer, jiffies + WDT_INTERVAL);
164 162
165 printk(KERN_INFO PFX "Watchdog timer is now enabled.\n"); 163 pr_info("Watchdog timer is now enabled\n");
166} 164}
167 165
168static void wdt_turnoff(void) 166static void wdt_turnoff(void)
@@ -170,7 +168,7 @@ static void wdt_turnoff(void)
170 /* Stop the timer */ 168 /* Stop the timer */
171 del_timer_sync(&timer); 169 del_timer_sync(&timer);
172 wdt_change(WDT_DISABLE); 170 wdt_change(WDT_DISABLE);
173 printk(KERN_INFO PFX "Watchdog timer is now disabled...\n"); 171 pr_info("Watchdog timer is now disabled...\n");
174} 172}
175 173
176static void wdt_keepalive(void) 174static void wdt_keepalive(void)
@@ -226,8 +224,7 @@ static int fop_close(struct inode *inode, struct file *file)
226 wdt_turnoff(); 224 wdt_turnoff();
227 else { 225 else {
228 /* wim: shouldn't there be a: del_timer(&timer); */ 226 /* wim: shouldn't there be a: del_timer(&timer); */
229 printk(KERN_CRIT PFX 227 pr_crit("device file closed unexpectedly. Will not stop the WDT!\n");
230 "device file closed unexpectedly. Will not stop the WDT!\n");
231 } 228 }
232 clear_bit(0, &wdt_is_open); 229 clear_bit(0, &wdt_is_open);
233 wdt_expect_close = 0; 230 wdt_expect_close = 0;
@@ -322,8 +319,7 @@ static int wdt_notify_sys(struct notifier_block *this,
322 * watchdog on reboot with no heartbeat 319 * watchdog on reboot with no heartbeat
323 */ 320 */
324 wdt_change(WDT_ENABLE); 321 wdt_change(WDT_ENABLE);
325 printk(KERN_INFO PFX "Watchdog timer is now enabled " 322 pr_info("Watchdog timer is now enabled with no heartbeat - should reboot in ~1 second\n");
326 "with no heartbeat - should reboot in ~1 second.\n");
327 } 323 }
328 return NOTIFY_DONE; 324 return NOTIFY_DONE;
329} 325}
@@ -352,12 +348,11 @@ static int __init alim7101_wdt_init(void)
352 struct pci_dev *ali1543_south; 348 struct pci_dev *ali1543_south;
353 char tmp; 349 char tmp;
354 350
355 printk(KERN_INFO PFX "Steve Hill <steve@navaho.co.uk>.\n"); 351 pr_info("Steve Hill <steve@navaho.co.uk>\n");
356 alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 352 alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
357 NULL); 353 NULL);
358 if (!alim7101_pmu) { 354 if (!alim7101_pmu) {
359 printk(KERN_INFO PFX 355 pr_info("ALi M7101 PMU not present - WDT not set\n");
360 "ALi M7101 PMU not present - WDT not set\n");
361 return -EBUSY; 356 return -EBUSY;
362 } 357 }
363 358
@@ -367,56 +362,46 @@ static int __init alim7101_wdt_init(void)
367 ali1543_south = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 362 ali1543_south = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533,
368 NULL); 363 NULL);
369 if (!ali1543_south) { 364 if (!ali1543_south) {
370 printk(KERN_INFO PFX 365 pr_info("ALi 1543 South-Bridge not present - WDT not set\n");
371 "ALi 1543 South-Bridge not present - WDT not set\n");
372 goto err_out; 366 goto err_out;
373 } 367 }
374 pci_read_config_byte(ali1543_south, 0x5e, &tmp); 368 pci_read_config_byte(ali1543_south, 0x5e, &tmp);
375 pci_dev_put(ali1543_south); 369 pci_dev_put(ali1543_south);
376 if ((tmp & 0x1e) == 0x00) { 370 if ((tmp & 0x1e) == 0x00) {
377 if (!use_gpio) { 371 if (!use_gpio) {
378 printk(KERN_INFO PFX 372 pr_info("Detected old alim7101 revision 'a1d'. If this is a cobalt board, set the 'use_gpio' module parameter.\n");
379 "Detected old alim7101 revision 'a1d'. "
380 "If this is a cobalt board, set the 'use_gpio' "
381 "module parameter.\n");
382 goto err_out; 373 goto err_out;
383 } 374 }
384 nowayout = 1; 375 nowayout = 1;
385 } else if ((tmp & 0x1e) != 0x12 && (tmp & 0x1e) != 0x00) { 376 } else if ((tmp & 0x1e) != 0x12 && (tmp & 0x1e) != 0x00) {
386 printk(KERN_INFO PFX 377 pr_info("ALi 1543 South-Bridge does not have the correct revision number (???1001?) - WDT not set\n");
387 "ALi 1543 South-Bridge does not have the correct "
388 "revision number (???1001?) - WDT not set\n");
389 goto err_out; 378 goto err_out;
390 } 379 }
391 380
392 if (timeout < 1 || timeout > 3600) { 381 if (timeout < 1 || timeout > 3600) {
393 /* arbitrary upper limit */ 382 /* arbitrary upper limit */
394 timeout = WATCHDOG_TIMEOUT; 383 timeout = WATCHDOG_TIMEOUT;
395 printk(KERN_INFO PFX 384 pr_info("timeout value must be 1 <= x <= 3600, using %d\n",
396 "timeout value must be 1 <= x <= 3600, using %d\n", 385 timeout);
397 timeout);
398 } 386 }
399 387
400 rc = register_reboot_notifier(&wdt_notifier); 388 rc = register_reboot_notifier(&wdt_notifier);
401 if (rc) { 389 if (rc) {
402 printk(KERN_ERR PFX 390 pr_err("cannot register reboot notifier (err=%d)\n", rc);
403 "cannot register reboot notifier (err=%d)\n", rc);
404 goto err_out; 391 goto err_out;
405 } 392 }
406 393
407 rc = misc_register(&wdt_miscdev); 394 rc = misc_register(&wdt_miscdev);
408 if (rc) { 395 if (rc) {
409 printk(KERN_ERR PFX 396 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
410 "cannot register miscdev on minor=%d (err=%d)\n", 397 wdt_miscdev.minor, rc);
411 wdt_miscdev.minor, rc);
412 goto err_out_reboot; 398 goto err_out_reboot;
413 } 399 }
414 400
415 if (nowayout) 401 if (nowayout)
416 __module_get(THIS_MODULE); 402 __module_get(THIS_MODULE);
417 403
418 printk(KERN_INFO PFX "WDT driver for ALi M7101 initialised. " 404 pr_info("WDT driver for ALi M7101 initialised. timeout=%d sec (nowayout=%d)\n",
419 "timeout=%d sec (nowayout=%d)\n",
420 timeout, nowayout); 405 timeout, nowayout);
421 return 0; 406 return 0;
422 407