aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/pcwd_usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/pcwd_usb.c')
-rw-r--r--drivers/watchdog/pcwd_usb.c78
1 files changed, 37 insertions, 41 deletions
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index d8de1ddd176a..7b14d1847927 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -24,6 +24,8 @@
24 * http://www.berkprod.com/ or http://www.pcwatchdog.com/ 24 * http://www.berkprod.com/ or http://www.pcwatchdog.com/
25 */ 25 */
26 26
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
27#include <linux/module.h> /* For module specific items */ 29#include <linux/module.h> /* For module specific items */
28#include <linux/moduleparam.h> /* For new moduleparam's */ 30#include <linux/moduleparam.h> /* For new moduleparam's */
29#include <linux/types.h> /* For standard types (like size_t) */ 31#include <linux/types.h> /* For standard types (like size_t) */
@@ -42,17 +44,23 @@
42#include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */ 44#include <linux/hid.h> /* For HID_REQ_SET_REPORT & HID_DT_REPORT */
43#include <linux/uaccess.h> /* For copy_to_user/put_user/... */ 45#include <linux/uaccess.h> /* For copy_to_user/put_user/... */
44 46
45
46#ifdef CONFIG_USB_DEBUG 47#ifdef CONFIG_USB_DEBUG
47 static int debug = 1; 48static int debug = 1;
48#else 49#else
49 static int debug; 50static int debug;
50#endif 51#endif
51 52
52/* Use our own dbg macro */ 53/* Use our own dbg macro */
54
53#undef dbg 55#undef dbg
54#define dbg(format, arg...) \ 56#ifndef DEBUG
55 do { if (debug) printk(KERN_DEBUG PFX format "\n" , ## arg); } while (0) 57#define DEBUG
58#endif
59#define dbg(format, ...) \
60do { \
61 if (debug) \
62 pr_debug(format "\n", ##__VA_ARGS__); \
63} while (0)
56 64
57/* Module and Version Information */ 65/* Module and Version Information */
58#define DRIVER_VERSION "1.02" 66#define DRIVER_VERSION "1.02"
@@ -60,7 +68,6 @@
60#define DRIVER_DESC "Berkshire USB-PC Watchdog driver" 68#define DRIVER_DESC "Berkshire USB-PC Watchdog driver"
61#define DRIVER_LICENSE "GPL" 69#define DRIVER_LICENSE "GPL"
62#define DRIVER_NAME "pcwd_usb" 70#define DRIVER_NAME "pcwd_usb"
63#define PFX DRIVER_NAME ": "
64 71
65MODULE_AUTHOR(DRIVER_AUTHOR); 72MODULE_AUTHOR(DRIVER_AUTHOR);
66MODULE_DESCRIPTION(DRIVER_DESC); 73MODULE_DESCRIPTION(DRIVER_DESC);
@@ -80,8 +87,8 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. "
80 "(0<heartbeat<65536 or 0=delay-time from dip-switches, default=" 87 "(0<heartbeat<65536 or 0=delay-time from dip-switches, default="
81 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 88 __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
82 89
83static int nowayout = WATCHDOG_NOWAYOUT; 90static bool nowayout = WATCHDOG_NOWAYOUT;
84module_param(nowayout, int, 0); 91module_param(nowayout, bool, 0);
85MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 92MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
86 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 93 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
87 94
@@ -220,8 +227,8 @@ static void usb_pcwd_intr_done(struct urb *urb)
220resubmit: 227resubmit:
221 retval = usb_submit_urb(urb, GFP_ATOMIC); 228 retval = usb_submit_urb(urb, GFP_ATOMIC);
222 if (retval) 229 if (retval)
223 printk(KERN_ERR PFX "can't resubmit intr, " 230 pr_err("can't resubmit intr, usb_submit_urb failed with result %d\n",
224 "usb_submit_urb failed with result %d\n", retval); 231 retval);
225} 232}
226 233
227static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, 234static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
@@ -284,8 +291,7 @@ static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd)
284 &msb, &lsb); 291 &msb, &lsb);
285 292
286 if ((retval == 0) || (lsb == 0)) { 293 if ((retval == 0) || (lsb == 0)) {
287 printk(KERN_ERR PFX 294 pr_err("Card did not acknowledge enable attempt\n");
288 "Card did not acknowledge enable attempt\n");
289 return -1; 295 return -1;
290 } 296 }
291 297
@@ -303,8 +309,7 @@ static int usb_pcwd_stop(struct usb_pcwd_private *usb_pcwd)
303 &msb, &lsb); 309 &msb, &lsb);
304 310
305 if ((retval == 0) || (lsb != 0)) { 311 if ((retval == 0) || (lsb != 0)) {
306 printk(KERN_ERR PFX 312 pr_err("Card did not acknowledge disable attempt\n");
307 "Card did not acknowledge disable attempt\n");
308 return -1; 313 return -1;
309 } 314 }
310 315
@@ -506,8 +511,7 @@ static int usb_pcwd_release(struct inode *inode, struct file *file)
506 if (expect_release == 42) { 511 if (expect_release == 42) {
507 usb_pcwd_stop(usb_pcwd_device); 512 usb_pcwd_stop(usb_pcwd_device);
508 } else { 513 } else {
509 printk(KERN_CRIT PFX 514 pr_crit("Unexpected close, not stopping watchdog!\n");
510 "Unexpected close, not stopping watchdog!\n");
511 usb_pcwd_keepalive(usb_pcwd_device); 515 usb_pcwd_keepalive(usb_pcwd_device);
512 } 516 }
513 expect_release = 0; 517 expect_release = 0;
@@ -627,7 +631,7 @@ static int usb_pcwd_probe(struct usb_interface *interface,
627 631
628 cards_found++; 632 cards_found++;
629 if (cards_found > 1) { 633 if (cards_found > 1) {
630 printk(KERN_ERR PFX "This driver only supports 1 device\n"); 634 pr_err("This driver only supports 1 device\n");
631 return -ENODEV; 635 return -ENODEV;
632 } 636 }
633 637
@@ -636,8 +640,7 @@ static int usb_pcwd_probe(struct usb_interface *interface,
636 640
637 /* check out that we have a HID device */ 641 /* check out that we have a HID device */
638 if (!(iface_desc->desc.bInterfaceClass == USB_CLASS_HID)) { 642 if (!(iface_desc->desc.bInterfaceClass == USB_CLASS_HID)) {
639 printk(KERN_ERR PFX 643 pr_err("The device isn't a Human Interface Device\n");
640 "The device isn't a Human Interface Device\n");
641 return -ENODEV; 644 return -ENODEV;
642 } 645 }
643 646
@@ -646,7 +649,7 @@ static int usb_pcwd_probe(struct usb_interface *interface,
646 649
647 if (!usb_endpoint_is_int_in(endpoint)) { 650 if (!usb_endpoint_is_int_in(endpoint)) {
648 /* we didn't find a Interrupt endpoint with direction IN */ 651 /* we didn't find a Interrupt endpoint with direction IN */
649 printk(KERN_ERR PFX "Couldn't find an INTR & IN endpoint\n"); 652 pr_err("Couldn't find an INTR & IN endpoint\n");
650 return -ENODEV; 653 return -ENODEV;
651 } 654 }
652 655
@@ -657,7 +660,7 @@ static int usb_pcwd_probe(struct usb_interface *interface,
657 /* allocate memory for our device and initialize it */ 660 /* allocate memory for our device and initialize it */
658 usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL); 661 usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL);
659 if (usb_pcwd == NULL) { 662 if (usb_pcwd == NULL) {
660 printk(KERN_ERR PFX "Out of memory\n"); 663 pr_err("Out of memory\n");
661 goto error; 664 goto error;
662 } 665 }
663 666
@@ -674,14 +677,14 @@ static int usb_pcwd_probe(struct usb_interface *interface,
674 usb_pcwd->intr_buffer = usb_alloc_coherent(udev, usb_pcwd->intr_size, 677 usb_pcwd->intr_buffer = usb_alloc_coherent(udev, usb_pcwd->intr_size,
675 GFP_ATOMIC, &usb_pcwd->intr_dma); 678 GFP_ATOMIC, &usb_pcwd->intr_dma);
676 if (!usb_pcwd->intr_buffer) { 679 if (!usb_pcwd->intr_buffer) {
677 printk(KERN_ERR PFX "Out of memory\n"); 680 pr_err("Out of memory\n");
678 goto error; 681 goto error;
679 } 682 }
680 683
681 /* allocate the urb's */ 684 /* allocate the urb's */
682 usb_pcwd->intr_urb = usb_alloc_urb(0, GFP_KERNEL); 685 usb_pcwd->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
683 if (!usb_pcwd->intr_urb) { 686 if (!usb_pcwd->intr_urb) {
684 printk(KERN_ERR PFX "Out of memory\n"); 687 pr_err("Out of memory\n");
685 goto error; 688 goto error;
686 } 689 }
687 690
@@ -694,7 +697,7 @@ static int usb_pcwd_probe(struct usb_interface *interface,
694 697
695 /* register our interrupt URB with the USB system */ 698 /* register our interrupt URB with the USB system */
696 if (usb_submit_urb(usb_pcwd->intr_urb, GFP_KERNEL)) { 699 if (usb_submit_urb(usb_pcwd->intr_urb, GFP_KERNEL)) {
697 printk(KERN_ERR PFX "Problem registering interrupt URB\n"); 700 pr_err("Problem registering interrupt URB\n");
698 retval = -EIO; /* failure */ 701 retval = -EIO; /* failure */
699 goto error; 702 goto error;
700 } 703 }
@@ -713,15 +716,13 @@ static int usb_pcwd_probe(struct usb_interface *interface,
713 else 716 else
714 sprintf(fw_ver_str, "<card no answer>"); 717 sprintf(fw_ver_str, "<card no answer>");
715 718
716 printk(KERN_INFO PFX "Found card (Firmware: %s) with temp option\n", 719 pr_info("Found card (Firmware: %s) with temp option\n", fw_ver_str);
717 fw_ver_str);
718 720
719 /* Get switch settings */ 721 /* Get switch settings */
720 usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy, 722 usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy,
721 &option_switches); 723 &option_switches);
722 724
723 printk(KERN_INFO PFX "Option switches (0x%02x): " 725 pr_info("Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
724 "Temperature Reset Enable=%s, Power On Delay=%s\n",
725 option_switches, 726 option_switches,
726 ((option_switches & 0x10) ? "ON" : "OFF"), 727 ((option_switches & 0x10) ? "ON" : "OFF"),
727 ((option_switches & 0x08) ? "ON" : "OFF")); 728 ((option_switches & 0x08) ? "ON" : "OFF"));
@@ -734,39 +735,34 @@ static int usb_pcwd_probe(struct usb_interface *interface,
734 * if not reset to the default */ 735 * if not reset to the default */
735 if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { 736 if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) {
736 usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); 737 usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT);
737 printk(KERN_INFO PFX 738 pr_info("heartbeat value must be 0<heartbeat<65536, using %d\n",
738 "heartbeat value must be 0<heartbeat<65536, using %d\n",
739 WATCHDOG_HEARTBEAT); 739 WATCHDOG_HEARTBEAT);
740 } 740 }
741 741
742 retval = register_reboot_notifier(&usb_pcwd_notifier); 742 retval = register_reboot_notifier(&usb_pcwd_notifier);
743 if (retval != 0) { 743 if (retval != 0) {
744 printk(KERN_ERR PFX 744 pr_err("cannot register reboot notifier (err=%d)\n", retval);
745 "cannot register reboot notifier (err=%d)\n",
746 retval);
747 goto error; 745 goto error;
748 } 746 }
749 747
750 retval = misc_register(&usb_pcwd_temperature_miscdev); 748 retval = misc_register(&usb_pcwd_temperature_miscdev);
751 if (retval != 0) { 749 if (retval != 0) {
752 printk(KERN_ERR PFX 750 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
753 "cannot register miscdev on minor=%d (err=%d)\n", 751 TEMP_MINOR, retval);
754 TEMP_MINOR, retval);
755 goto err_out_unregister_reboot; 752 goto err_out_unregister_reboot;
756 } 753 }
757 754
758 retval = misc_register(&usb_pcwd_miscdev); 755 retval = misc_register(&usb_pcwd_miscdev);
759 if (retval != 0) { 756 if (retval != 0) {
760 printk(KERN_ERR PFX 757 pr_err("cannot register miscdev on minor=%d (err=%d)\n",
761 "cannot register miscdev on minor=%d (err=%d)\n", 758 WATCHDOG_MINOR, retval);
762 WATCHDOG_MINOR, retval);
763 goto err_out_misc_deregister; 759 goto err_out_misc_deregister;
764 } 760 }
765 761
766 /* we can register the device now, as it is ready */ 762 /* we can register the device now, as it is ready */
767 usb_set_intfdata(interface, usb_pcwd); 763 usb_set_intfdata(interface, usb_pcwd);
768 764
769 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", 765 pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
770 heartbeat, nowayout); 766 heartbeat, nowayout);
771 767
772 return 0; 768 return 0;
@@ -824,7 +820,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
824 820
825 mutex_unlock(&disconnect_mutex); 821 mutex_unlock(&disconnect_mutex);
826 822
827 printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); 823 pr_info("USB PC Watchdog disconnected\n");
828} 824}
829 825
830module_usb_driver(usb_pcwd_driver); 826module_usb_driver(usb_pcwd_driver);