aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/pcwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/pcwd.c')
-rw-r--r--drivers/watchdog/pcwd.c123
1 files changed, 49 insertions, 74 deletions
diff --git a/drivers/watchdog/pcwd.c b/drivers/watchdog/pcwd.c
index 06f7922606c0..fe370defc71f 100644
--- a/drivers/watchdog/pcwd.c
+++ b/drivers/watchdog/pcwd.c
@@ -51,6 +51,8 @@
51 * http://www.pcwatchdog.com/ 51 * http://www.pcwatchdog.com/
52 */ 52 */
53 53
54#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
55
54#include <linux/module.h> /* For module specific items */ 56#include <linux/module.h> /* For module specific items */
55#include <linux/moduleparam.h> /* For new moduleparam's */ 57#include <linux/moduleparam.h> /* For new moduleparam's */
56#include <linux/types.h> /* For standard types (like size_t) */ 58#include <linux/types.h> /* For standard types (like size_t) */
@@ -75,7 +77,6 @@
75#define WATCHDOG_DATE "18 Feb 2007" 77#define WATCHDOG_DATE "18 Feb 2007"
76#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog" 78#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog"
77#define WATCHDOG_NAME "pcwd" 79#define WATCHDOG_NAME "pcwd"
78#define PFX WATCHDOG_NAME ": "
79#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n" 80#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n"
80 81
81/* 82/*
@@ -220,8 +221,7 @@ static int send_isa_command(int cmd)
220 int port0, last_port0; /* Double read for stabilising */ 221 int port0, last_port0; /* Double read for stabilising */
221 222
222 if (debug >= DEBUG) 223 if (debug >= DEBUG)
223 printk(KERN_DEBUG PFX "sending following data cmd=0x%02x\n", 224 pr_debug("sending following data cmd=0x%02x\n", cmd);
224 cmd);
225 225
226 /* The WCMD bit must be 1 and the command is only 4 bits in size */ 226 /* The WCMD bit must be 1 and the command is only 4 bits in size */
227 control_status = (cmd & 0x0F) | WD_WCMD; 227 control_status = (cmd & 0x0F) | WD_WCMD;
@@ -240,9 +240,8 @@ static int send_isa_command(int cmd)
240 } 240 }
241 241
242 if (debug >= DEBUG) 242 if (debug >= DEBUG)
243 printk(KERN_DEBUG PFX "received following data for " 243 pr_debug("received following data for cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n",
244 "cmd=0x%02x: port0=0x%02x last_port0=0x%02x\n", 244 cmd, port0, last_port0);
245 cmd, port0, last_port0);
246 245
247 return port0; 246 return port0;
248} 247}
@@ -271,8 +270,7 @@ static int set_command_mode(void)
271 pcwd_private.command_mode = found; 270 pcwd_private.command_mode = found;
272 271
273 if (debug >= DEBUG) 272 if (debug >= DEBUG)
274 printk(KERN_DEBUG PFX "command_mode=%d\n", 273 pr_debug("command_mode=%d\n", pcwd_private.command_mode);
275 pcwd_private.command_mode);
276 274
277 return found; 275 return found;
278} 276}
@@ -288,8 +286,7 @@ static void unset_command_mode(void)
288 pcwd_private.command_mode = 0; 286 pcwd_private.command_mode = 0;
289 287
290 if (debug >= DEBUG) 288 if (debug >= DEBUG)
291 printk(KERN_DEBUG PFX "command_mode=%d\n", 289 pr_debug("command_mode=%d\n", pcwd_private.command_mode);
292 pcwd_private.command_mode);
293} 290}
294 291
295static inline void pcwd_check_temperature_support(void) 292static inline void pcwd_check_temperature_support(void)
@@ -336,17 +333,14 @@ static void pcwd_show_card_info(void)
336 333
337 /* Get some extra info from the hardware (in command/debug/diag mode) */ 334 /* Get some extra info from the hardware (in command/debug/diag mode) */
338 if (pcwd_private.revision == PCWD_REVISION_A) 335 if (pcwd_private.revision == PCWD_REVISION_A)
339 printk(KERN_INFO PFX 336 pr_info("ISA-PC Watchdog (REV.A) detected at port 0x%04x\n",
340 "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", 337 pcwd_private.io_addr);
341 pcwd_private.io_addr);
342 else if (pcwd_private.revision == PCWD_REVISION_C) { 338 else if (pcwd_private.revision == PCWD_REVISION_C) {
343 pcwd_get_firmware(); 339 pcwd_get_firmware();
344 printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port " 340 pr_info("ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",
345 "0x%04x (Firmware version: %s)\n",
346 pcwd_private.io_addr, pcwd_private.fw_ver_str); 341 pcwd_private.io_addr, pcwd_private.fw_ver_str);
347 option_switches = pcwd_get_option_switches(); 342 option_switches = pcwd_get_option_switches();
348 printk(KERN_INFO PFX "Option switches (0x%02x): " 343 pr_info("Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
349 "Temperature Reset Enable=%s, Power On Delay=%s\n",
350 option_switches, 344 option_switches,
351 ((option_switches & 0x10) ? "ON" : "OFF"), 345 ((option_switches & 0x10) ? "ON" : "OFF"),
352 ((option_switches & 0x08) ? "ON" : "OFF")); 346 ((option_switches & 0x08) ? "ON" : "OFF"));
@@ -359,22 +353,18 @@ static void pcwd_show_card_info(void)
359 } 353 }
360 354
361 if (pcwd_private.supports_temp) 355 if (pcwd_private.supports_temp)
362 printk(KERN_INFO PFX "Temperature Option Detected\n"); 356 pr_info("Temperature Option Detected\n");
363 357
364 if (pcwd_private.boot_status & WDIOF_CARDRESET) 358 if (pcwd_private.boot_status & WDIOF_CARDRESET)
365 printk(KERN_INFO PFX 359 pr_info("Previous reboot was caused by the card\n");
366 "Previous reboot was caused by the card\n");
367 360
368 if (pcwd_private.boot_status & WDIOF_OVERHEAT) { 361 if (pcwd_private.boot_status & WDIOF_OVERHEAT) {
369 printk(KERN_EMERG PFX 362 pr_emerg("Card senses a CPU Overheat. Panicking!\n");
370 "Card senses a CPU Overheat. Panicking!\n"); 363 pr_emerg("CPU Overheat\n");
371 printk(KERN_EMERG PFX
372 "CPU Overheat\n");
373 } 364 }
374 365
375 if (pcwd_private.boot_status == 0) 366 if (pcwd_private.boot_status == 0)
376 printk(KERN_INFO PFX 367 pr_info("No previous trip detected - Cold boot or reset\n");
377 "No previous trip detected - Cold boot or reset\n");
378} 368}
379 369
380static void pcwd_timer_ping(unsigned long data) 370static void pcwd_timer_ping(unsigned long data)
@@ -404,8 +394,7 @@ static void pcwd_timer_ping(unsigned long data)
404 394
405 spin_unlock(&pcwd_private.io_lock); 395 spin_unlock(&pcwd_private.io_lock);
406 } else { 396 } else {
407 printk(KERN_WARNING PFX 397 pr_warn("Heartbeat lost! Will not ping the watchdog\n");
408 "Heartbeat lost! Will not ping the watchdog\n");
409 } 398 }
410} 399}
411 400
@@ -426,13 +415,13 @@ static int pcwd_start(void)
426 stat_reg = inb_p(pcwd_private.io_addr + 2); 415 stat_reg = inb_p(pcwd_private.io_addr + 2);
427 spin_unlock(&pcwd_private.io_lock); 416 spin_unlock(&pcwd_private.io_lock);
428 if (stat_reg & WD_WDIS) { 417 if (stat_reg & WD_WDIS) {
429 printk(KERN_INFO PFX "Could not start watchdog\n"); 418 pr_info("Could not start watchdog\n");
430 return -EIO; 419 return -EIO;
431 } 420 }
432 } 421 }
433 422
434 if (debug >= VERBOSE) 423 if (debug >= VERBOSE)
435 printk(KERN_DEBUG PFX "Watchdog started\n"); 424 pr_debug("Watchdog started\n");
436 425
437 return 0; 426 return 0;
438} 427}
@@ -454,13 +443,13 @@ static int pcwd_stop(void)
454 stat_reg = inb_p(pcwd_private.io_addr + 2); 443 stat_reg = inb_p(pcwd_private.io_addr + 2);
455 spin_unlock(&pcwd_private.io_lock); 444 spin_unlock(&pcwd_private.io_lock);
456 if ((stat_reg & WD_WDIS) == 0) { 445 if ((stat_reg & WD_WDIS) == 0) {
457 printk(KERN_INFO PFX "Could not stop watchdog\n"); 446 pr_info("Could not stop watchdog\n");
458 return -EIO; 447 return -EIO;
459 } 448 }
460 } 449 }
461 450
462 if (debug >= VERBOSE) 451 if (debug >= VERBOSE)
463 printk(KERN_DEBUG PFX "Watchdog stopped\n"); 452 pr_debug("Watchdog stopped\n");
464 453
465 return 0; 454 return 0;
466} 455}
@@ -471,7 +460,7 @@ static int pcwd_keepalive(void)
471 pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ); 460 pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ);
472 461
473 if (debug >= DEBUG) 462 if (debug >= DEBUG)
474 printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); 463 pr_debug("Watchdog keepalive signal send\n");
475 464
476 return 0; 465 return 0;
477} 466}
@@ -484,8 +473,7 @@ static int pcwd_set_heartbeat(int t)
484 heartbeat = t; 473 heartbeat = t;
485 474
486 if (debug >= VERBOSE) 475 if (debug >= VERBOSE)
487 printk(KERN_DEBUG PFX "New heartbeat: %d\n", 476 pr_debug("New heartbeat: %d\n", heartbeat);
488 heartbeat);
489 477
490 return 0; 478 return 0;
491} 479}
@@ -518,8 +506,7 @@ static int pcwd_get_status(int *status)
518 if (control_status & WD_T110) { 506 if (control_status & WD_T110) {
519 *status |= WDIOF_OVERHEAT; 507 *status |= WDIOF_OVERHEAT;
520 if (temp_panic) { 508 if (temp_panic) {
521 printk(KERN_INFO PFX 509 pr_info("Temperature overheat trip!\n");
522 "Temperature overheat trip!\n");
523 kernel_power_off(); 510 kernel_power_off();
524 } 511 }
525 } 512 }
@@ -530,8 +517,7 @@ static int pcwd_get_status(int *status)
530 if (control_status & WD_REVC_TTRP) { 517 if (control_status & WD_REVC_TTRP) {
531 *status |= WDIOF_OVERHEAT; 518 *status |= WDIOF_OVERHEAT;
532 if (temp_panic) { 519 if (temp_panic) {
533 printk(KERN_INFO PFX 520 pr_info("Temperature overheat trip!\n");
534 "Temperature overheat trip!\n");
535 kernel_power_off(); 521 kernel_power_off();
536 } 522 }
537 } 523 }
@@ -548,16 +534,14 @@ static int pcwd_clear_status(void)
548 spin_lock(&pcwd_private.io_lock); 534 spin_lock(&pcwd_private.io_lock);
549 535
550 if (debug >= VERBOSE) 536 if (debug >= VERBOSE)
551 printk(KERN_INFO PFX 537 pr_info("clearing watchdog trip status\n");
552 "clearing watchdog trip status\n");
553 538
554 control_status = inb_p(pcwd_private.io_addr + 1); 539 control_status = inb_p(pcwd_private.io_addr + 1);
555 540
556 if (debug >= DEBUG) { 541 if (debug >= DEBUG) {
557 printk(KERN_DEBUG PFX "status was: 0x%02x\n", 542 pr_debug("status was: 0x%02x\n", control_status);
558 control_status); 543 pr_debug("sending: 0x%02x\n",
559 printk(KERN_DEBUG PFX "sending: 0x%02x\n", 544 (control_status & WD_REVC_R2DS));
560 (control_status & WD_REVC_R2DS));
561 } 545 }
562 546
563 /* clear reset status & Keep Relay 2 disable state as it is */ 547 /* clear reset status & Keep Relay 2 disable state as it is */
@@ -588,8 +572,7 @@ static int pcwd_get_temperature(int *temperature)
588 spin_unlock(&pcwd_private.io_lock); 572 spin_unlock(&pcwd_private.io_lock);
589 573
590 if (debug >= DEBUG) { 574 if (debug >= DEBUG) {
591 printk(KERN_DEBUG PFX "temperature is: %d F\n", 575 pr_debug("temperature is: %d F\n", *temperature);
592 *temperature);
593 } 576 }
594 577
595 return 0; 578 return 0;
@@ -720,8 +703,7 @@ static int pcwd_close(struct inode *inode, struct file *file)
720 if (expect_close == 42) 703 if (expect_close == 42)
721 pcwd_stop(); 704 pcwd_stop();
722 else { 705 else {
723 printk(KERN_CRIT PFX 706 pr_crit("Unexpected close, not stopping watchdog!\n");
724 "Unexpected close, not stopping watchdog!\n");
725 pcwd_keepalive(); 707 pcwd_keepalive();
726 } 708 }
727 expect_close = 0; 709 expect_close = 0;
@@ -828,11 +810,10 @@ static int __devinit pcwd_isa_match(struct device *dev, unsigned int id)
828 int retval; 810 int retval;
829 811
830 if (debug >= DEBUG) 812 if (debug >= DEBUG)
831 printk(KERN_DEBUG PFX "pcwd_isa_match id=%d\n", 813 pr_debug("pcwd_isa_match id=%d\n", id);
832 id);
833 814
834 if (!request_region(base_addr, 4, "PCWD")) { 815 if (!request_region(base_addr, 4, "PCWD")) {
835 printk(KERN_INFO PFX "Port 0x%04x unavailable\n", base_addr); 816 pr_info("Port 0x%04x unavailable\n", base_addr);
836 return 0; 817 return 0;
837 } 818 }
838 819
@@ -870,21 +851,20 @@ static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id)
870 int ret; 851 int ret;
871 852
872 if (debug >= DEBUG) 853 if (debug >= DEBUG)
873 printk(KERN_DEBUG PFX "pcwd_isa_probe id=%d\n", 854 pr_debug("pcwd_isa_probe id=%d\n", id);
874 id);
875 855
876 cards_found++; 856 cards_found++;
877 if (cards_found == 1) 857 if (cards_found == 1)
878 printk(KERN_INFO PFX "v%s Ken Hollis (kenji@bitgate.com)\n", 858 pr_info("v%s Ken Hollis (kenji@bitgate.com)\n",
879 WATCHDOG_VERSION); 859 WATCHDOG_VERSION);
880 860
881 if (cards_found > 1) { 861 if (cards_found > 1) {
882 printk(KERN_ERR PFX "This driver only supports 1 device\n"); 862 pr_err("This driver only supports 1 device\n");
883 return -ENODEV; 863 return -ENODEV;
884 } 864 }
885 865
886 if (pcwd_ioports[id] == 0x0000) { 866 if (pcwd_ioports[id] == 0x0000) {
887 printk(KERN_ERR PFX "No I/O-Address for card detected\n"); 867 pr_err("No I/O-Address for card detected\n");
888 return -ENODEV; 868 return -ENODEV;
889 } 869 }
890 pcwd_private.io_addr = pcwd_ioports[id]; 870 pcwd_private.io_addr = pcwd_ioports[id];
@@ -896,8 +876,8 @@ static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id)
896 876
897 if (!request_region(pcwd_private.io_addr, 877 if (!request_region(pcwd_private.io_addr,
898 (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) { 878 (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) {
899 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", 879 pr_err("I/O address 0x%04x already in use\n",
900 pcwd_private.io_addr); 880 pcwd_private.io_addr);
901 ret = -EIO; 881 ret = -EIO;
902 goto error_request_region; 882 goto error_request_region;
903 } 883 }
@@ -932,30 +912,27 @@ static int __devinit pcwd_isa_probe(struct device *dev, unsigned int id)
932 if not reset to the default */ 912 if not reset to the default */
933 if (pcwd_set_heartbeat(heartbeat)) { 913 if (pcwd_set_heartbeat(heartbeat)) {
934 pcwd_set_heartbeat(WATCHDOG_HEARTBEAT); 914 pcwd_set_heartbeat(WATCHDOG_HEARTBEAT);
935 printk(KERN_INFO PFX 915 pr_info("heartbeat value must be 2 <= heartbeat <= 7200, using %d\n",
936 "heartbeat value must be 2 <= heartbeat <= 7200, using %d\n", 916 WATCHDOG_HEARTBEAT);
937 WATCHDOG_HEARTBEAT);
938 } 917 }
939 918
940 if (pcwd_private.supports_temp) { 919 if (pcwd_private.supports_temp) {
941 ret = misc_register(&temp_miscdev); 920 ret = misc_register(&temp_miscdev);
942 if (ret) { 921 if (ret) {
943 printk(KERN_ERR PFX 922 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
944 "cannot register miscdev on minor=%d (err=%d)\n", 923 TEMP_MINOR, ret);
945 TEMP_MINOR, ret);
946 goto error_misc_register_temp; 924 goto error_misc_register_temp;
947 } 925 }
948 } 926 }
949 927
950 ret = misc_register(&pcwd_miscdev); 928 ret = misc_register(&pcwd_miscdev);
951 if (ret) { 929 if (ret) {
952 printk(KERN_ERR PFX 930 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
953 "cannot register miscdev on minor=%d (err=%d)\n", 931 WATCHDOG_MINOR, ret);
954 WATCHDOG_MINOR, ret);
955 goto error_misc_register_watchdog; 932 goto error_misc_register_watchdog;
956 } 933 }
957 934
958 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", 935 pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
959 heartbeat, nowayout); 936 heartbeat, nowayout);
960 937
961 return 0; 938 return 0;
@@ -975,8 +952,7 @@ error_request_region:
975static int __devexit pcwd_isa_remove(struct device *dev, unsigned int id) 952static int __devexit pcwd_isa_remove(struct device *dev, unsigned int id)
976{ 953{
977 if (debug >= DEBUG) 954 if (debug >= DEBUG)
978 printk(KERN_DEBUG PFX "pcwd_isa_remove id=%d\n", 955 pr_debug("pcwd_isa_remove id=%d\n", id);
979 id);
980 956
981 if (!pcwd_private.io_addr) 957 if (!pcwd_private.io_addr)
982 return 1; 958 return 1;
@@ -1000,8 +976,7 @@ static int __devexit pcwd_isa_remove(struct device *dev, unsigned int id)
1000static void pcwd_isa_shutdown(struct device *dev, unsigned int id) 976static void pcwd_isa_shutdown(struct device *dev, unsigned int id)
1001{ 977{
1002 if (debug >= DEBUG) 978 if (debug >= DEBUG)
1003 printk(KERN_DEBUG PFX "pcwd_isa_shutdown id=%d\n", 979 pr_debug("pcwd_isa_shutdown id=%d\n", id);
1004 id);
1005 980
1006 pcwd_stop(); 981 pcwd_stop();
1007} 982}
@@ -1025,7 +1000,7 @@ static int __init pcwd_init_module(void)
1025static void __exit pcwd_cleanup_module(void) 1000static void __exit pcwd_cleanup_module(void)
1026{ 1001{
1027 isa_unregister_driver(&pcwd_isa_driver); 1002 isa_unregister_driver(&pcwd_isa_driver);
1028 printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); 1003 pr_info("Watchdog Module Unloaded\n");
1029} 1004}
1030 1005
1031module_init(pcwd_init_module); 1006module_init(pcwd_init_module);