aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/pcwd_usb.c
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2008-08-06 16:19:41 -0400
committerWim Van Sebroeck <wim@iguana.be>2008-08-06 16:19:41 -0400
commit7944d3a5a70ee5c1904ed1e8b1d71ff0af2854d9 (patch)
treefe6ec1a557a4b27712266d9d86f791c69e8e2596 /drivers/watchdog/pcwd_usb.c
parent12b7a1523eda9cd72362fdda928ddb995ecdc06d (diff)
[WATCHDOG] more coding style clean-up's
More coding style clean-up's. Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/pcwd_usb.c')
-rw-r--r--drivers/watchdog/pcwd_usb.c61
1 files changed, 29 insertions, 32 deletions
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index 8c582bc0588e..c1685c942de6 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -87,7 +87,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" _
87#define USB_PCWD_PRODUCT_ID 0x1140 87#define USB_PCWD_PRODUCT_ID 0x1140
88 88
89/* table of devices that work with this driver */ 89/* table of devices that work with this driver */
90static struct usb_device_id usb_pcwd_table [] = { 90static struct usb_device_id usb_pcwd_table[] = {
91 { USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) }, 91 { USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) },
92 { } /* Terminating entry */ 92 { } /* Terminating entry */
93}; 93};
@@ -109,7 +109,7 @@ MODULE_DEVICE_TABLE (usb, usb_pcwd_table);
109#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG 109#define CMD_DISABLE_WATCHDOG CMD_ENABLE_WATCHDOG
110 110
111/* Watchdog's Dip Switch heartbeat values */ 111/* Watchdog's Dip Switch heartbeat values */
112static const int heartbeat_tbl [] = { 112static const int heartbeat_tbl[] = {
113 5, /* OFF-OFF-OFF = 5 Sec */ 113 5, /* OFF-OFF-OFF = 5 Sec */
114 10, /* OFF-OFF-ON = 10 Sec */ 114 10, /* OFF-OFF-ON = 10 Sec */
115 30, /* OFF-ON-OFF = 30 Sec */ 115 30, /* OFF-ON-OFF = 30 Sec */
@@ -129,15 +129,15 @@ static char expect_release;
129 129
130/* Structure to hold all of our device specific stuff */ 130/* Structure to hold all of our device specific stuff */
131struct usb_pcwd_private { 131struct usb_pcwd_private {
132 struct usb_device * udev; /* save off the usb device pointer */ 132 struct usb_device *udev; /* save off the usb device pointer */
133 struct usb_interface * interface; /* the interface for this device */ 133 struct usb_interface *interface; /* the interface for this device */
134 134
135 unsigned int interface_number; /* the interface number used for cmd's */ 135 unsigned int interface_number; /* the interface number used for cmd's */
136 136
137 unsigned char * intr_buffer; /* the buffer to intr data */ 137 unsigned char *intr_buffer; /* the buffer to intr data */
138 dma_addr_t intr_dma; /* the dma address for the intr buffer */ 138 dma_addr_t intr_dma; /* the dma address for the intr buffer */
139 size_t intr_size; /* the size of the intr buffer */ 139 size_t intr_size; /* the size of the intr buffer */
140 struct urb * intr_urb; /* the urb used for the intr pipe */ 140 struct urb *intr_urb; /* the urb used for the intr pipe */
141 141
142 unsigned char cmd_command; /* The command that is reported back */ 142 unsigned char cmd_command; /* The command that is reported back */
143 unsigned char cmd_data_msb; /* The data MSB that is reported back */ 143 unsigned char cmd_data_msb; /* The data MSB that is reported back */
@@ -153,8 +153,8 @@ static struct usb_pcwd_private *usb_pcwd_device;
153static DEFINE_MUTEX(disconnect_mutex); 153static DEFINE_MUTEX(disconnect_mutex);
154 154
155/* local function prototypes */ 155/* local function prototypes */
156static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); 156static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_device_id *id);
157static void usb_pcwd_disconnect (struct usb_interface *interface); 157static void usb_pcwd_disconnect(struct usb_interface *interface);
158 158
159/* usb specific object needed to register this driver with the usb subsystem */ 159/* usb specific object needed to register this driver with the usb subsystem */
160static struct usb_driver usb_pcwd_driver = { 160static struct usb_driver usb_pcwd_driver = {
@@ -194,10 +194,10 @@ static void usb_pcwd_intr_done(struct urb *urb)
194 usb_pcwd->cmd_data_lsb = data[2]; 194 usb_pcwd->cmd_data_lsb = data[2];
195 195
196 /* notify anyone waiting that the cmd has finished */ 196 /* notify anyone waiting that the cmd has finished */
197 atomic_set (&usb_pcwd->cmd_received, 1); 197 atomic_set(&usb_pcwd->cmd_received, 1);
198 198
199resubmit: 199resubmit:
200 retval = usb_submit_urb (urb, GFP_ATOMIC); 200 retval = usb_submit_urb(urb, GFP_ATOMIC);
201 if (retval) 201 if (retval)
202 printk(KERN_ERR PFX "can't resubmit intr, usb_submit_urb failed with result %d\n", 202 printk(KERN_ERR PFX "can't resubmit intr, usb_submit_urb failed with result %d\n",
203 retval); 203 retval);
@@ -223,7 +223,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned cha
223 dbg("sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x", 223 dbg("sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x",
224 buf[0], buf[1], buf[2]); 224 buf[0], buf[1], buf[2]);
225 225
226 atomic_set (&usb_pcwd->cmd_received, 0); 226 atomic_set(&usb_pcwd->cmd_received, 0);
227 227
228 if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0), 228 if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
229 HID_REQ_SET_REPORT, HID_DT_REPORT, 229 HID_REQ_SET_REPORT, HID_DT_REPORT,
@@ -236,7 +236,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned cha
236 got_response = 0; 236 got_response = 0;
237 for (count = 0; (count < USB_COMMAND_TIMEOUT) && (!got_response); count++) { 237 for (count = 0; (count < USB_COMMAND_TIMEOUT) && (!got_response); count++) {
238 mdelay(1); 238 mdelay(1);
239 if (atomic_read (&usb_pcwd->cmd_received)) 239 if (atomic_read(&usb_pcwd->cmd_received))
240 got_response = 1; 240 got_response = 1;
241 } 241 }
242 242
@@ -355,7 +355,7 @@ static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
355 /* scan to see whether or not we got the magic character */ 355 /* scan to see whether or not we got the magic character */
356 for (i = 0; i != len; i++) { 356 for (i = 0; i != len; i++) {
357 char c; 357 char c;
358 if(get_user(c, data+i)) 358 if (get_user(c, data + i))
359 return -EFAULT; 359 return -EFAULT;
360 if (c == 'V') 360 if (c == 'V')
361 expect_release = 42; 361 expect_release = 42;
@@ -383,8 +383,7 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
383 383
384 switch (cmd) { 384 switch (cmd) {
385 case WDIOC_GETSUPPORT: 385 case WDIOC_GETSUPPORT:
386 return copy_to_user(argp, &ident, 386 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
387 sizeof (ident)) ? -EFAULT : 0;
388 387
389 case WDIOC_GETSTATUS: 388 case WDIOC_GETSTATUS:
390 case WDIOC_GETBOOTSTATUS: 389 case WDIOC_GETBOOTSTATUS:
@@ -404,7 +403,7 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
404 { 403 {
405 int new_options, retval = -EINVAL; 404 int new_options, retval = -EINVAL;
406 405
407 if (get_user (new_options, p)) 406 if (get_user(new_options, p))
408 return -EFAULT; 407 return -EFAULT;
409 408
410 if (new_options & WDIOS_DISABLECARD) { 409 if (new_options & WDIOS_DISABLECARD) {
@@ -518,10 +517,8 @@ static int usb_pcwd_temperature_release(struct inode *inode, struct file *file)
518 517
519static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) 518static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
520{ 519{
521 if (code==SYS_DOWN || code==SYS_HALT) { 520 if (code == SYS_DOWN || code == SYS_HALT)
522 /* Turn the WDT off */ 521 usb_pcwd_stop(usb_pcwd_device); /* Turn the WDT off */
523 usb_pcwd_stop(usb_pcwd_device);
524 }
525 522
526 return NOTIFY_DONE; 523 return NOTIFY_DONE;
527} 524}
@@ -566,13 +563,13 @@ static struct notifier_block usb_pcwd_notifier = {
566/** 563/**
567 * usb_pcwd_delete 564 * usb_pcwd_delete
568 */ 565 */
569static inline void usb_pcwd_delete (struct usb_pcwd_private *usb_pcwd) 566static inline void usb_pcwd_delete(struct usb_pcwd_private *usb_pcwd)
570{ 567{
571 usb_free_urb(usb_pcwd->intr_urb); 568 usb_free_urb(usb_pcwd->intr_urb);
572 if (usb_pcwd->intr_buffer != NULL) 569 if (usb_pcwd->intr_buffer != NULL)
573 usb_buffer_free(usb_pcwd->udev, usb_pcwd->intr_size, 570 usb_buffer_free(usb_pcwd->udev, usb_pcwd->intr_size,
574 usb_pcwd->intr_buffer, usb_pcwd->intr_dma); 571 usb_pcwd->intr_buffer, usb_pcwd->intr_dma);
575 kfree (usb_pcwd); 572 kfree(usb_pcwd);
576} 573}
577 574
578/** 575/**
@@ -625,7 +622,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
625 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 622 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
626 623
627 /* allocate memory for our device and initialize it */ 624 /* allocate memory for our device and initialize it */
628 usb_pcwd = kzalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL); 625 usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL);
629 if (usb_pcwd == NULL) { 626 if (usb_pcwd == NULL) {
630 printk(KERN_ERR PFX "Out of memory\n"); 627 printk(KERN_ERR PFX "Out of memory\n");
631 goto error; 628 goto error;
@@ -640,7 +637,8 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
640 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); 637 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8);
641 638
642 /* set up the memory buffer's */ 639 /* set up the memory buffer's */
643 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma))) { 640 usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma);
641 if (!usb_pcwd->intr_buffer) {
644 printk(KERN_ERR PFX "Out of memory\n"); 642 printk(KERN_ERR PFX "Out of memory\n");
645 goto error; 643 goto error;
646 } 644 }
@@ -674,11 +672,10 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
674 672
675 /* Get the Firmware Version */ 673 /* Get the Firmware Version */
676 got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); 674 got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor);
677 if (got_fw_rev) { 675 if (got_fw_rev)
678 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); 676 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
679 } else { 677 else
680 sprintf(fw_ver_str, "<card no answer>"); 678 sprintf(fw_ver_str, "<card no answer>");
681 }
682 679
683 printk(KERN_INFO PFX "Found card (Firmware: %s) with temp option\n", 680 printk(KERN_INFO PFX "Found card (Firmware: %s) with temp option\n",
684 fw_ver_str); 681 fw_ver_str);
@@ -724,7 +721,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
724 } 721 }
725 722
726 /* we can register the device now, as it is ready */ 723 /* we can register the device now, as it is ready */
727 usb_set_intfdata (interface, usb_pcwd); 724 usb_set_intfdata(interface, usb_pcwd);
728 725
729 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", 726 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
730 heartbeat, nowayout); 727 heartbeat, nowayout);
@@ -758,8 +755,8 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
758 /* prevent races with open() */ 755 /* prevent races with open() */
759 mutex_lock(&disconnect_mutex); 756 mutex_lock(&disconnect_mutex);
760 757
761 usb_pcwd = usb_get_intfdata (interface); 758 usb_pcwd = usb_get_intfdata(interface);
762 usb_set_intfdata (interface, NULL); 759 usb_set_intfdata(interface, NULL);
763 760
764 mutex_lock(&usb_pcwd->mtx); 761 mutex_lock(&usb_pcwd->mtx);
765 762
@@ -819,5 +816,5 @@ static void __exit usb_pcwd_exit(void)
819} 816}
820 817
821 818
822module_init (usb_pcwd_init); 819module_init(usb_pcwd_init);
823module_exit (usb_pcwd_exit); 820module_exit(usb_pcwd_exit);