diff options
Diffstat (limited to 'drivers/watchdog/pcwd_pci.c')
-rw-r--r-- | drivers/watchdog/pcwd_pci.c | 109 |
1 files changed, 46 insertions, 63 deletions
diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c index b8d14f88f0b5..75f2fa84c500 100644 --- a/drivers/watchdog/pcwd_pci.c +++ b/drivers/watchdog/pcwd_pci.c | |||
@@ -32,6 +32,8 @@ | |||
32 | * Includes, defines, variables, module parameters, ... | 32 | * Includes, defines, variables, module parameters, ... |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
36 | |||
35 | #include <linux/module.h> /* For module specific items */ | 37 | #include <linux/module.h> /* For module specific items */ |
36 | #include <linux/moduleparam.h> /* For new moduleparam's */ | 38 | #include <linux/moduleparam.h> /* For new moduleparam's */ |
37 | #include <linux/types.h> /* For standard types (like size_t) */ | 39 | #include <linux/types.h> /* For standard types (like size_t) */ |
@@ -54,8 +56,7 @@ | |||
54 | #define WATCHDOG_VERSION "1.03" | 56 | #define WATCHDOG_VERSION "1.03" |
55 | #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" | 57 | #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" |
56 | #define WATCHDOG_NAME "pcwd_pci" | 58 | #define WATCHDOG_NAME "pcwd_pci" |
57 | #define PFX WATCHDOG_NAME ": " | 59 | #define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION |
58 | #define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION "\n" | ||
59 | 60 | ||
60 | /* Stuff for the PCI ID's */ | 61 | /* Stuff for the PCI ID's */ |
61 | #ifndef PCI_VENDOR_ID_QUICKLOGIC | 62 | #ifndef PCI_VENDOR_ID_QUICKLOGIC |
@@ -159,8 +160,8 @@ static int send_command(int cmd, int *msb, int *lsb) | |||
159 | int got_response, count; | 160 | int got_response, count; |
160 | 161 | ||
161 | if (debug >= DEBUG) | 162 | if (debug >= DEBUG) |
162 | printk(KERN_DEBUG PFX "sending following data " | 163 | pr_debug("sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n", |
163 | "cmd=0x%02x msb=0x%02x lsb=0x%02x\n", cmd, *msb, *lsb); | 164 | cmd, *msb, *lsb); |
164 | 165 | ||
165 | spin_lock(&pcipcwd_private.io_lock); | 166 | spin_lock(&pcipcwd_private.io_lock); |
166 | /* If a command requires data it should be written first. | 167 | /* If a command requires data it should be written first. |
@@ -185,12 +186,10 @@ static int send_command(int cmd, int *msb, int *lsb) | |||
185 | 186 | ||
186 | if (debug >= DEBUG) { | 187 | if (debug >= DEBUG) { |
187 | if (got_response) { | 188 | if (got_response) { |
188 | printk(KERN_DEBUG PFX | 189 | pr_debug("time to process command was: %d ms\n", |
189 | "time to process command was: %d ms\n", | 190 | count); |
190 | count); | ||
191 | } else { | 191 | } else { |
192 | printk(KERN_DEBUG PFX | 192 | pr_debug("card did not respond on command!\n"); |
193 | "card did not respond on command!\n"); | ||
194 | } | 193 | } |
195 | } | 194 | } |
196 | 195 | ||
@@ -203,9 +202,8 @@ static int send_command(int cmd, int *msb, int *lsb) | |||
203 | inb_p(pcipcwd_private.io_addr + 6); | 202 | inb_p(pcipcwd_private.io_addr + 6); |
204 | 203 | ||
205 | if (debug >= DEBUG) | 204 | if (debug >= DEBUG) |
206 | printk(KERN_DEBUG PFX "received following data for " | 205 | pr_debug("received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", |
207 | "cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", | 206 | cmd, *msb, *lsb); |
208 | cmd, *msb, *lsb); | ||
209 | } | 207 | } |
210 | 208 | ||
211 | spin_unlock(&pcipcwd_private.io_lock); | 209 | spin_unlock(&pcipcwd_private.io_lock); |
@@ -243,27 +241,23 @@ static void pcipcwd_show_card_info(void) | |||
243 | /* Get switch settings */ | 241 | /* Get switch settings */ |
244 | option_switches = pcipcwd_get_option_switches(); | 242 | option_switches = pcipcwd_get_option_switches(); |
245 | 243 | ||
246 | printk(KERN_INFO PFX "Found card at port " | 244 | pr_info("Found card at port 0x%04x (Firmware: %s) %s temp option\n", |
247 | "0x%04x (Firmware: %s) %s temp option\n", | ||
248 | (int) pcipcwd_private.io_addr, fw_ver_str, | 245 | (int) pcipcwd_private.io_addr, fw_ver_str, |
249 | (pcipcwd_private.supports_temp ? "with" : "without")); | 246 | (pcipcwd_private.supports_temp ? "with" : "without")); |
250 | 247 | ||
251 | printk(KERN_INFO PFX "Option switches (0x%02x): " | 248 | pr_info("Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", |
252 | "Temperature Reset Enable=%s, Power On Delay=%s\n", | ||
253 | option_switches, | 249 | option_switches, |
254 | ((option_switches & 0x10) ? "ON" : "OFF"), | 250 | ((option_switches & 0x10) ? "ON" : "OFF"), |
255 | ((option_switches & 0x08) ? "ON" : "OFF")); | 251 | ((option_switches & 0x08) ? "ON" : "OFF")); |
256 | 252 | ||
257 | if (pcipcwd_private.boot_status & WDIOF_CARDRESET) | 253 | if (pcipcwd_private.boot_status & WDIOF_CARDRESET) |
258 | printk(KERN_INFO PFX | 254 | pr_info("Previous reset was caused by the Watchdog card\n"); |
259 | "Previous reset was caused by the Watchdog card\n"); | ||
260 | 255 | ||
261 | if (pcipcwd_private.boot_status & WDIOF_OVERHEAT) | 256 | if (pcipcwd_private.boot_status & WDIOF_OVERHEAT) |
262 | printk(KERN_INFO PFX "Card sensed a CPU Overheat\n"); | 257 | pr_info("Card sensed a CPU Overheat\n"); |
263 | 258 | ||
264 | if (pcipcwd_private.boot_status == 0) | 259 | if (pcipcwd_private.boot_status == 0) |
265 | printk(KERN_INFO PFX | 260 | pr_info("No previous trip detected - Cold boot or reset\n"); |
266 | "No previous trip detected - Cold boot or reset\n"); | ||
267 | } | 261 | } |
268 | 262 | ||
269 | static int pcipcwd_start(void) | 263 | static int pcipcwd_start(void) |
@@ -278,12 +272,12 @@ static int pcipcwd_start(void) | |||
278 | spin_unlock(&pcipcwd_private.io_lock); | 272 | spin_unlock(&pcipcwd_private.io_lock); |
279 | 273 | ||
280 | if (stat_reg & WD_PCI_WDIS) { | 274 | if (stat_reg & WD_PCI_WDIS) { |
281 | printk(KERN_ERR PFX "Card timer not enabled\n"); | 275 | pr_err("Card timer not enabled\n"); |
282 | return -1; | 276 | return -1; |
283 | } | 277 | } |
284 | 278 | ||
285 | if (debug >= VERBOSE) | 279 | if (debug >= VERBOSE) |
286 | printk(KERN_DEBUG PFX "Watchdog started\n"); | 280 | pr_debug("Watchdog started\n"); |
287 | 281 | ||
288 | return 0; | 282 | return 0; |
289 | } | 283 | } |
@@ -303,13 +297,12 @@ static int pcipcwd_stop(void) | |||
303 | spin_unlock(&pcipcwd_private.io_lock); | 297 | spin_unlock(&pcipcwd_private.io_lock); |
304 | 298 | ||
305 | if (!(stat_reg & WD_PCI_WDIS)) { | 299 | if (!(stat_reg & WD_PCI_WDIS)) { |
306 | printk(KERN_ERR PFX | 300 | pr_err("Card did not acknowledge disable attempt\n"); |
307 | "Card did not acknowledge disable attempt\n"); | ||
308 | return -1; | 301 | return -1; |
309 | } | 302 | } |
310 | 303 | ||
311 | if (debug >= VERBOSE) | 304 | if (debug >= VERBOSE) |
312 | printk(KERN_DEBUG PFX "Watchdog stopped\n"); | 305 | pr_debug("Watchdog stopped\n"); |
313 | 306 | ||
314 | return 0; | 307 | return 0; |
315 | } | 308 | } |
@@ -322,7 +315,7 @@ static int pcipcwd_keepalive(void) | |||
322 | spin_unlock(&pcipcwd_private.io_lock); | 315 | spin_unlock(&pcipcwd_private.io_lock); |
323 | 316 | ||
324 | if (debug >= DEBUG) | 317 | if (debug >= DEBUG) |
325 | printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); | 318 | pr_debug("Watchdog keepalive signal send\n"); |
326 | 319 | ||
327 | return 0; | 320 | return 0; |
328 | } | 321 | } |
@@ -340,8 +333,7 @@ static int pcipcwd_set_heartbeat(int t) | |||
340 | 333 | ||
341 | heartbeat = t; | 334 | heartbeat = t; |
342 | if (debug >= VERBOSE) | 335 | if (debug >= VERBOSE) |
343 | printk(KERN_DEBUG PFX "New heartbeat: %d\n", | 336 | pr_debug("New heartbeat: %d\n", heartbeat); |
344 | heartbeat); | ||
345 | 337 | ||
346 | return 0; | 338 | return 0; |
347 | } | 339 | } |
@@ -357,12 +349,11 @@ static int pcipcwd_get_status(int *status) | |||
357 | if (control_status & WD_PCI_TTRP) { | 349 | if (control_status & WD_PCI_TTRP) { |
358 | *status |= WDIOF_OVERHEAT; | 350 | *status |= WDIOF_OVERHEAT; |
359 | if (temp_panic) | 351 | if (temp_panic) |
360 | panic(PFX "Temperature overheat trip!\n"); | 352 | panic(KBUILD_MODNAME ": Temperature overheat trip!\n"); |
361 | } | 353 | } |
362 | 354 | ||
363 | if (debug >= DEBUG) | 355 | if (debug >= DEBUG) |
364 | printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n", | 356 | pr_debug("Control Status #1: 0x%02x\n", control_status); |
365 | control_status); | ||
366 | 357 | ||
367 | return 0; | 358 | return 0; |
368 | } | 359 | } |
@@ -374,14 +365,14 @@ static int pcipcwd_clear_status(void) | |||
374 | int reset_counter; | 365 | int reset_counter; |
375 | 366 | ||
376 | if (debug >= VERBOSE) | 367 | if (debug >= VERBOSE) |
377 | printk(KERN_INFO PFX "clearing watchdog trip status & LED\n"); | 368 | pr_info("clearing watchdog trip status & LED\n"); |
378 | 369 | ||
379 | control_status = inb_p(pcipcwd_private.io_addr + 1); | 370 | control_status = inb_p(pcipcwd_private.io_addr + 1); |
380 | 371 | ||
381 | if (debug >= DEBUG) { | 372 | if (debug >= DEBUG) { |
382 | printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status); | 373 | pr_debug("status was: 0x%02x\n", control_status); |
383 | printk(KERN_DEBUG PFX "sending: 0x%02x\n", | 374 | pr_debug("sending: 0x%02x\n", |
384 | (control_status & WD_PCI_R2DS) | WD_PCI_WTRP); | 375 | (control_status & WD_PCI_R2DS) | WD_PCI_WTRP); |
385 | } | 376 | } |
386 | 377 | ||
387 | /* clear trip status & LED and keep mode of relay 2 */ | 378 | /* clear trip status & LED and keep mode of relay 2 */ |
@@ -394,8 +385,7 @@ static int pcipcwd_clear_status(void) | |||
394 | send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); | 385 | send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); |
395 | 386 | ||
396 | if (debug >= DEBUG) { | 387 | if (debug >= DEBUG) { |
397 | printk(KERN_DEBUG PFX "reset count was: 0x%02x\n", | 388 | pr_debug("reset count was: 0x%02x\n", reset_counter); |
398 | reset_counter); | ||
399 | } | 389 | } |
400 | 390 | ||
401 | return 0; | 391 | return 0; |
@@ -418,8 +408,7 @@ static int pcipcwd_get_temperature(int *temperature) | |||
418 | *temperature = (*temperature * 9 / 5) + 32; | 408 | *temperature = (*temperature * 9 / 5) + 32; |
419 | 409 | ||
420 | if (debug >= DEBUG) { | 410 | if (debug >= DEBUG) { |
421 | printk(KERN_DEBUG PFX "temperature is: %d F\n", | 411 | pr_debug("temperature is: %d F\n", *temperature); |
422 | *temperature); | ||
423 | } | 412 | } |
424 | 413 | ||
425 | return 0; | 414 | return 0; |
@@ -437,8 +426,7 @@ static int pcipcwd_get_timeleft(int *time_left) | |||
437 | *time_left = (msb << 8) + lsb; | 426 | *time_left = (msb << 8) + lsb; |
438 | 427 | ||
439 | if (debug >= VERBOSE) | 428 | if (debug >= VERBOSE) |
440 | printk(KERN_DEBUG PFX "Time left before next reboot: %d\n", | 429 | pr_debug("Time left before next reboot: %d\n", *time_left); |
441 | *time_left); | ||
442 | 430 | ||
443 | return 0; | 431 | return 0; |
444 | } | 432 | } |
@@ -583,8 +571,7 @@ static int pcipcwd_open(struct inode *inode, struct file *file) | |||
583 | /* /dev/watchdog can only be opened once */ | 571 | /* /dev/watchdog can only be opened once */ |
584 | if (test_and_set_bit(0, &is_active)) { | 572 | if (test_and_set_bit(0, &is_active)) { |
585 | if (debug >= VERBOSE) | 573 | if (debug >= VERBOSE) |
586 | printk(KERN_ERR PFX | 574 | pr_err("Attempt to open already opened device\n"); |
587 | "Attempt to open already opened device.\n"); | ||
588 | return -EBUSY; | 575 | return -EBUSY; |
589 | } | 576 | } |
590 | 577 | ||
@@ -602,8 +589,7 @@ static int pcipcwd_release(struct inode *inode, struct file *file) | |||
602 | if (expect_release == 42) { | 589 | if (expect_release == 42) { |
603 | pcipcwd_stop(); | 590 | pcipcwd_stop(); |
604 | } else { | 591 | } else { |
605 | printk(KERN_CRIT PFX | 592 | pr_crit("Unexpected close, not stopping watchdog!\n"); |
606 | "Unexpected close, not stopping watchdog!\n"); | ||
607 | pcipcwd_keepalive(); | 593 | pcipcwd_keepalive(); |
608 | } | 594 | } |
609 | expect_release = 0; | 595 | expect_release = 0; |
@@ -703,20 +689,20 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev, | |||
703 | 689 | ||
704 | cards_found++; | 690 | cards_found++; |
705 | if (cards_found == 1) | 691 | if (cards_found == 1) |
706 | printk(KERN_INFO PFX DRIVER_VERSION); | 692 | pr_info("%s\n", DRIVER_VERSION); |
707 | 693 | ||
708 | if (cards_found > 1) { | 694 | if (cards_found > 1) { |
709 | printk(KERN_ERR PFX "This driver only supports 1 device\n"); | 695 | pr_err("This driver only supports 1 device\n"); |
710 | return -ENODEV; | 696 | return -ENODEV; |
711 | } | 697 | } |
712 | 698 | ||
713 | if (pci_enable_device(pdev)) { | 699 | if (pci_enable_device(pdev)) { |
714 | printk(KERN_ERR PFX "Not possible to enable PCI Device\n"); | 700 | pr_err("Not possible to enable PCI Device\n"); |
715 | return -ENODEV; | 701 | return -ENODEV; |
716 | } | 702 | } |
717 | 703 | ||
718 | if (pci_resource_start(pdev, 0) == 0x0000) { | 704 | if (pci_resource_start(pdev, 0) == 0x0000) { |
719 | printk(KERN_ERR PFX "No I/O-Address for card detected\n"); | 705 | pr_err("No I/O-Address for card detected\n"); |
720 | ret = -ENODEV; | 706 | ret = -ENODEV; |
721 | goto err_out_disable_device; | 707 | goto err_out_disable_device; |
722 | } | 708 | } |
@@ -725,8 +711,8 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev, | |||
725 | pcipcwd_private.io_addr = pci_resource_start(pdev, 0); | 711 | pcipcwd_private.io_addr = pci_resource_start(pdev, 0); |
726 | 712 | ||
727 | if (pci_request_regions(pdev, WATCHDOG_NAME)) { | 713 | if (pci_request_regions(pdev, WATCHDOG_NAME)) { |
728 | printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", | 714 | pr_err("I/O address 0x%04x already in use\n", |
729 | (int) pcipcwd_private.io_addr); | 715 | (int) pcipcwd_private.io_addr); |
730 | ret = -EIO; | 716 | ret = -EIO; |
731 | goto err_out_disable_device; | 717 | goto err_out_disable_device; |
732 | } | 718 | } |
@@ -755,36 +741,33 @@ static int __devinit pcipcwd_card_init(struct pci_dev *pdev, | |||
755 | * if not reset to the default */ | 741 | * if not reset to the default */ |
756 | if (pcipcwd_set_heartbeat(heartbeat)) { | 742 | if (pcipcwd_set_heartbeat(heartbeat)) { |
757 | pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); | 743 | pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); |
758 | printk(KERN_INFO PFX | 744 | pr_info("heartbeat value must be 0<heartbeat<65536, using %d\n", |
759 | "heartbeat value must be 0<heartbeat<65536, using %d\n", | ||
760 | WATCHDOG_HEARTBEAT); | 745 | WATCHDOG_HEARTBEAT); |
761 | } | 746 | } |
762 | 747 | ||
763 | ret = register_reboot_notifier(&pcipcwd_notifier); | 748 | ret = register_reboot_notifier(&pcipcwd_notifier); |
764 | if (ret != 0) { | 749 | if (ret != 0) { |
765 | printk(KERN_ERR PFX | 750 | pr_err("cannot register reboot notifier (err=%d)\n", ret); |
766 | "cannot register reboot notifier (err=%d)\n", ret); | ||
767 | goto err_out_release_region; | 751 | goto err_out_release_region; |
768 | } | 752 | } |
769 | 753 | ||
770 | if (pcipcwd_private.supports_temp) { | 754 | if (pcipcwd_private.supports_temp) { |
771 | ret = misc_register(&pcipcwd_temp_miscdev); | 755 | ret = misc_register(&pcipcwd_temp_miscdev); |
772 | if (ret != 0) { | 756 | if (ret != 0) { |
773 | printk(KERN_ERR PFX "cannot register miscdev on " | 757 | pr_err("cannot register miscdev on minor=%d (err=%d)\n", |
774 | "minor=%d (err=%d)\n", TEMP_MINOR, ret); | 758 | TEMP_MINOR, ret); |
775 | goto err_out_unregister_reboot; | 759 | goto err_out_unregister_reboot; |
776 | } | 760 | } |
777 | } | 761 | } |
778 | 762 | ||
779 | ret = misc_register(&pcipcwd_miscdev); | 763 | ret = misc_register(&pcipcwd_miscdev); |
780 | if (ret != 0) { | 764 | if (ret != 0) { |
781 | printk(KERN_ERR PFX | 765 | pr_err("cannot register miscdev on minor=%d (err=%d)\n", |
782 | "cannot register miscdev on minor=%d (err=%d)\n", | 766 | WATCHDOG_MINOR, ret); |
783 | WATCHDOG_MINOR, ret); | ||
784 | goto err_out_misc_deregister; | 767 | goto err_out_misc_deregister; |
785 | } | 768 | } |
786 | 769 | ||
787 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", | 770 | pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n", |
788 | heartbeat, nowayout); | 771 | heartbeat, nowayout); |
789 | 772 | ||
790 | return 0; | 773 | return 0; |
@@ -842,7 +825,7 @@ static void __exit pcipcwd_cleanup_module(void) | |||
842 | { | 825 | { |
843 | pci_unregister_driver(&pcipcwd_driver); | 826 | pci_unregister_driver(&pcipcwd_driver); |
844 | 827 | ||
845 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | 828 | pr_info("Watchdog Module Unloaded\n"); |
846 | } | 829 | } |
847 | 830 | ||
848 | module_init(pcipcwd_init_module); | 831 | module_init(pcipcwd_init_module); |