aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/misc/adutux.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index ce109b7aed14..3b154bd804be 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -147,10 +147,10 @@ static void adu_abort_transfers(struct adu_device *dev)
147{ 147{
148 unsigned long flags; 148 unsigned long flags;
149 149
150 dbg(2," %s : enter", __func__); 150 dbg(2, " %s : enter", __func__);
151 151
152 if (dev->udev == NULL) { 152 if (dev->udev == NULL) {
153 dbg(1," %s : udev is null", __func__); 153 dbg(1, " %s : udev is null", __func__);
154 goto exit; 154 goto exit;
155 } 155 }
156 156
@@ -172,7 +172,7 @@ static void adu_abort_transfers(struct adu_device *dev)
172 spin_unlock_irqrestore(&dev->buflock, flags); 172 spin_unlock_irqrestore(&dev->buflock, flags);
173 173
174exit: 174exit:
175 dbg(2," %s : leave", __func__); 175 dbg(2, " %s : leave", __func__);
176} 176}
177 177
178static void adu_delete(struct adu_device *dev) 178static void adu_delete(struct adu_device *dev)
@@ -196,7 +196,7 @@ static void adu_interrupt_in_callback(struct urb *urb)
196 struct adu_device *dev = urb->context; 196 struct adu_device *dev = urb->context;
197 int status = urb->status; 197 int status = urb->status;
198 198
199 dbg(4," %s : enter, status %d", __func__, status); 199 dbg(4, " %s : enter, status %d", __func__, status);
200 adu_debug_data(5, __func__, urb->actual_length, 200 adu_debug_data(5, __func__, urb->actual_length,
201 urb->transfer_buffer); 201 urb->transfer_buffer);
202 202
@@ -205,7 +205,7 @@ static void adu_interrupt_in_callback(struct urb *urb)
205 if (status != 0) { 205 if (status != 0) {
206 if ((status != -ENOENT) && (status != -ECONNRESET) && 206 if ((status != -ENOENT) && (status != -ECONNRESET) &&
207 (status != -ESHUTDOWN)) { 207 (status != -ESHUTDOWN)) {
208 dbg(1," %s : nonzero status received: %d", 208 dbg(1, " %s : nonzero status received: %d",
209 __func__, status); 209 __func__, status);
210 } 210 }
211 goto exit; 211 goto exit;
@@ -220,10 +220,10 @@ static void adu_interrupt_in_callback(struct urb *urb)
220 dev->interrupt_in_buffer, urb->actual_length); 220 dev->interrupt_in_buffer, urb->actual_length);
221 221
222 dev->read_buffer_length += urb->actual_length; 222 dev->read_buffer_length += urb->actual_length;
223 dbg(2," %s reading %d ", __func__, 223 dbg(2, " %s reading %d ", __func__,
224 urb->actual_length); 224 urb->actual_length);
225 } else { 225 } else {
226 dbg(1," %s : read_buffer overflow", __func__); 226 dbg(1, " %s : read_buffer overflow", __func__);
227 } 227 }
228 } 228 }
229 229
@@ -234,7 +234,7 @@ exit:
234 wake_up_interruptible(&dev->read_wait); 234 wake_up_interruptible(&dev->read_wait);
235 adu_debug_data(5, __func__, urb->actual_length, 235 adu_debug_data(5, __func__, urb->actual_length,
236 urb->transfer_buffer); 236 urb->transfer_buffer);
237 dbg(4," %s : leave, status %d", __func__, status); 237 dbg(4, " %s : leave, status %d", __func__, status);
238} 238}
239 239
240static void adu_interrupt_out_callback(struct urb *urb) 240static void adu_interrupt_out_callback(struct urb *urb)
@@ -242,8 +242,8 @@ static void adu_interrupt_out_callback(struct urb *urb)
242 struct adu_device *dev = urb->context; 242 struct adu_device *dev = urb->context;
243 int status = urb->status; 243 int status = urb->status;
244 244
245 dbg(4," %s : enter, status %d", __func__, status); 245 dbg(4, " %s : enter, status %d", __func__, status);
246 adu_debug_data(5,__func__, urb->actual_length, urb->transfer_buffer); 246 adu_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
247 247
248 if (status != 0) { 248 if (status != 0) {
249 if ((status != -ENOENT) && 249 if ((status != -ENOENT) &&
@@ -262,7 +262,7 @@ exit:
262 262
263 adu_debug_data(5, __func__, urb->actual_length, 263 adu_debug_data(5, __func__, urb->actual_length,
264 urb->transfer_buffer); 264 urb->transfer_buffer);
265 dbg(4," %s : leave, status %d", __func__, status); 265 dbg(4, " %s : leave, status %d", __func__, status);
266} 266}
267 267
268static int adu_open(struct inode *inode, struct file *file) 268static int adu_open(struct inode *inode, struct file *file)
@@ -272,7 +272,7 @@ static int adu_open(struct inode *inode, struct file *file)
272 int subminor; 272 int subminor;
273 int retval; 273 int retval;
274 274
275 dbg(2,"%s : enter", __func__); 275 dbg(2, "%s : enter", __func__);
276 276
277 subminor = iminor(inode); 277 subminor = iminor(inode);
278 278
@@ -302,7 +302,7 @@ static int adu_open(struct inode *inode, struct file *file)
302 } 302 }
303 303
304 ++dev->open_count; 304 ++dev->open_count;
305 dbg(2,"%s : open count %d", __func__, dev->open_count); 305 dbg(2, "%s : open count %d", __func__, dev->open_count);
306 306
307 /* save device in the file's private structure */ 307 /* save device in the file's private structure */
308 file->private_data = dev; 308 file->private_data = dev;
@@ -311,7 +311,7 @@ static int adu_open(struct inode *inode, struct file *file)
311 dev->read_buffer_length = 0; 311 dev->read_buffer_length = 0;
312 312
313 /* fixup first read by having urb waiting for it */ 313 /* fixup first read by having urb waiting for it */
314 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 314 usb_fill_int_urb(dev->interrupt_in_urb, dev->udev,
315 usb_rcvintpipe(dev->udev, 315 usb_rcvintpipe(dev->udev,
316 dev->interrupt_in_endpoint->bEndpointAddress), 316 dev->interrupt_in_endpoint->bEndpointAddress),
317 dev->interrupt_in_buffer, 317 dev->interrupt_in_buffer,
@@ -332,23 +332,23 @@ static int adu_open(struct inode *inode, struct file *file)
332exit_no_device: 332exit_no_device:
333 mutex_unlock(&adutux_mutex); 333 mutex_unlock(&adutux_mutex);
334exit_no_lock: 334exit_no_lock:
335 dbg(2,"%s : leave, return value %d ", __func__, retval); 335 dbg(2, "%s : leave, return value %d ", __func__, retval);
336 return retval; 336 return retval;
337} 337}
338 338
339static void adu_release_internal(struct adu_device *dev) 339static void adu_release_internal(struct adu_device *dev)
340{ 340{
341 dbg(2," %s : enter", __func__); 341 dbg(2, " %s : enter", __func__);
342 342
343 /* decrement our usage count for the device */ 343 /* decrement our usage count for the device */
344 --dev->open_count; 344 --dev->open_count;
345 dbg(2," %s : open count %d", __func__, dev->open_count); 345 dbg(2, " %s : open count %d", __func__, dev->open_count);
346 if (dev->open_count <= 0) { 346 if (dev->open_count <= 0) {
347 adu_abort_transfers(dev); 347 adu_abort_transfers(dev);
348 dev->open_count = 0; 348 dev->open_count = 0;
349 } 349 }
350 350
351 dbg(2," %s : leave", __func__); 351 dbg(2, " %s : leave", __func__);
352} 352}
353 353
354static int adu_release(struct inode *inode, struct file *file) 354static int adu_release(struct inode *inode, struct file *file)
@@ -356,17 +356,17 @@ static int adu_release(struct inode *inode, struct file *file)
356 struct adu_device *dev; 356 struct adu_device *dev;
357 int retval = 0; 357 int retval = 0;
358 358
359 dbg(2," %s : enter", __func__); 359 dbg(2, " %s : enter", __func__);
360 360
361 if (file == NULL) { 361 if (file == NULL) {
362 dbg(1," %s : file is NULL", __func__); 362 dbg(1, " %s : file is NULL", __func__);
363 retval = -ENODEV; 363 retval = -ENODEV;
364 goto exit; 364 goto exit;
365 } 365 }
366 366
367 dev = file->private_data; 367 dev = file->private_data;
368 if (dev == NULL) { 368 if (dev == NULL) {
369 dbg(1," %s : object is NULL", __func__); 369 dbg(1, " %s : object is NULL", __func__);
370 retval = -ENODEV; 370 retval = -ENODEV;
371 goto exit; 371 goto exit;
372 } 372 }
@@ -374,7 +374,7 @@ static int adu_release(struct inode *inode, struct file *file)
374 mutex_lock(&adutux_mutex); /* not interruptible */ 374 mutex_lock(&adutux_mutex); /* not interruptible */
375 375
376 if (dev->open_count <= 0) { 376 if (dev->open_count <= 0) {
377 dbg(1," %s : device not opened", __func__); 377 dbg(1, " %s : device not opened", __func__);
378 retval = -ENODEV; 378 retval = -ENODEV;
379 goto unlock; 379 goto unlock;
380 } 380 }
@@ -388,7 +388,7 @@ static int adu_release(struct inode *inode, struct file *file)
388unlock: 388unlock:
389 mutex_unlock(&adutux_mutex); 389 mutex_unlock(&adutux_mutex);
390exit: 390exit:
391 dbg(2," %s : leave, return value %d", __func__, retval); 391 dbg(2, " %s : leave, return value %d", __func__, retval);
392 return retval; 392 return retval;
393} 393}
394 394
@@ -405,10 +405,10 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
405 unsigned long flags; 405 unsigned long flags;
406 DECLARE_WAITQUEUE(wait, current); 406 DECLARE_WAITQUEUE(wait, current);
407 407
408 dbg(2," %s : enter, count = %Zd, file=%p", __func__, count, file); 408 dbg(2, " %s : enter, count = %Zd, file=%p", __func__, count, file);
409 409
410 dev = file->private_data; 410 dev = file->private_data;
411 dbg(2," %s : dev=%p", __func__, dev); 411 dbg(2, " %s : dev=%p", __func__, dev);
412 412
413 if (mutex_lock_interruptible(&dev->mtx)) 413 if (mutex_lock_interruptible(&dev->mtx))
414 return -ERESTARTSYS; 414 return -ERESTARTSYS;
@@ -423,15 +423,15 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
423 423
424 /* verify that some data was requested */ 424 /* verify that some data was requested */
425 if (count == 0) { 425 if (count == 0) {
426 dbg(1," %s : read request of 0 bytes", __func__); 426 dbg(1, " %s : read request of 0 bytes", __func__);
427 goto exit; 427 goto exit;
428 } 428 }
429 429
430 timeout = COMMAND_TIMEOUT; 430 timeout = COMMAND_TIMEOUT;
431 dbg(2," %s : about to start looping", __func__); 431 dbg(2, " %s : about to start looping", __func__);
432 while (bytes_to_read) { 432 while (bytes_to_read) {
433 int data_in_secondary = dev->secondary_tail - dev->secondary_head; 433 int data_in_secondary = dev->secondary_tail - dev->secondary_head;
434 dbg(2," %s : while, data_in_secondary=%d, status=%d", 434 dbg(2, " %s : while, data_in_secondary=%d, status=%d",
435 __func__, data_in_secondary, 435 __func__, data_in_secondary,
436 dev->interrupt_in_urb->status); 436 dev->interrupt_in_urb->status);
437 437
@@ -456,7 +456,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
456 if (dev->read_buffer_length) { 456 if (dev->read_buffer_length) {
457 /* we secure access to the primary */ 457 /* we secure access to the primary */
458 char *tmp; 458 char *tmp;
459 dbg(2," %s : swap, read_buffer_length = %d", 459 dbg(2, " %s : swap, read_buffer_length = %d",
460 __func__, dev->read_buffer_length); 460 __func__, dev->read_buffer_length);
461 tmp = dev->read_buffer_secondary; 461 tmp = dev->read_buffer_secondary;
462 dev->read_buffer_secondary = dev->read_buffer_primary; 462 dev->read_buffer_secondary = dev->read_buffer_primary;
@@ -472,14 +472,14 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
472 if (!dev->read_urb_finished) { 472 if (!dev->read_urb_finished) {
473 /* somebody is doing IO */ 473 /* somebody is doing IO */
474 spin_unlock_irqrestore(&dev->buflock, flags); 474 spin_unlock_irqrestore(&dev->buflock, flags);
475 dbg(2," %s : submitted already", __func__); 475 dbg(2, " %s : submitted already", __func__);
476 } else { 476 } else {
477 /* we must initiate input */ 477 /* we must initiate input */
478 dbg(2," %s : initiate input", __func__); 478 dbg(2, " %s : initiate input", __func__);
479 dev->read_urb_finished = 0; 479 dev->read_urb_finished = 0;
480 spin_unlock_irqrestore(&dev->buflock, flags); 480 spin_unlock_irqrestore(&dev->buflock, flags);
481 481
482 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 482 usb_fill_int_urb(dev->interrupt_in_urb, dev->udev,
483 usb_rcvintpipe(dev->udev, 483 usb_rcvintpipe(dev->udev,
484 dev->interrupt_in_endpoint->bEndpointAddress), 484 dev->interrupt_in_endpoint->bEndpointAddress),
485 dev->interrupt_in_buffer, 485 dev->interrupt_in_buffer,
@@ -493,7 +493,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
493 if (retval == -ENOMEM) { 493 if (retval == -ENOMEM) {
494 retval = bytes_read ? bytes_read : -ENOMEM; 494 retval = bytes_read ? bytes_read : -ENOMEM;
495 } 495 }
496 dbg(2," %s : submit failed", __func__); 496 dbg(2, " %s : submit failed", __func__);
497 goto exit; 497 goto exit;
498 } 498 }
499 } 499 }
@@ -512,13 +512,13 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
512 remove_wait_queue(&dev->read_wait, &wait); 512 remove_wait_queue(&dev->read_wait, &wait);
513 513
514 if (timeout <= 0) { 514 if (timeout <= 0) {
515 dbg(2," %s : timeout", __func__); 515 dbg(2, " %s : timeout", __func__);
516 retval = bytes_read ? bytes_read : -ETIMEDOUT; 516 retval = bytes_read ? bytes_read : -ETIMEDOUT;
517 goto exit; 517 goto exit;
518 } 518 }
519 519
520 if (signal_pending(current)) { 520 if (signal_pending(current)) {
521 dbg(2," %s : signal pending", __func__); 521 dbg(2, " %s : signal pending", __func__);
522 retval = bytes_read ? bytes_read : -EINTR; 522 retval = bytes_read ? bytes_read : -EINTR;
523 goto exit; 523 goto exit;
524 } 524 }
@@ -532,7 +532,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
532 if (should_submit && dev->read_urb_finished) { 532 if (should_submit && dev->read_urb_finished) {
533 dev->read_urb_finished = 0; 533 dev->read_urb_finished = 0;
534 spin_unlock_irqrestore(&dev->buflock, flags); 534 spin_unlock_irqrestore(&dev->buflock, flags);
535 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev, 535 usb_fill_int_urb(dev->interrupt_in_urb, dev->udev,
536 usb_rcvintpipe(dev->udev, 536 usb_rcvintpipe(dev->udev,
537 dev->interrupt_in_endpoint->bEndpointAddress), 537 dev->interrupt_in_endpoint->bEndpointAddress),
538 dev->interrupt_in_buffer, 538 dev->interrupt_in_buffer,
@@ -551,7 +551,7 @@ exit:
551 /* unlock the device */ 551 /* unlock the device */
552 mutex_unlock(&dev->mtx); 552 mutex_unlock(&dev->mtx);
553 553
554 dbg(2," %s : leave, return value %d", __func__, retval); 554 dbg(2, " %s : leave, return value %d", __func__, retval);
555 return retval; 555 return retval;
556} 556}
557 557
@@ -566,7 +566,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
566 unsigned long flags; 566 unsigned long flags;
567 int retval; 567 int retval;
568 568
569 dbg(2," %s : enter, count = %Zd", __func__, count); 569 dbg(2, " %s : enter, count = %Zd", __func__, count);
570 570
571 dev = file->private_data; 571 dev = file->private_data;
572 572
@@ -584,7 +584,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
584 584
585 /* verify that we actually have some data to write */ 585 /* verify that we actually have some data to write */
586 if (count == 0) { 586 if (count == 0) {
587 dbg(1," %s : write request of 0 bytes", __func__); 587 dbg(1, " %s : write request of 0 bytes", __func__);
588 goto exit; 588 goto exit;
589 } 589 }
590 590
@@ -597,7 +597,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
597 597
598 mutex_unlock(&dev->mtx); 598 mutex_unlock(&dev->mtx);
599 if (signal_pending(current)) { 599 if (signal_pending(current)) {
600 dbg(1," %s : interrupted", __func__); 600 dbg(1, " %s : interrupted", __func__);
601 set_current_state(TASK_RUNNING); 601 set_current_state(TASK_RUNNING);
602 retval = -EINTR; 602 retval = -EINTR;
603 goto exit_onqueue; 603 goto exit_onqueue;
@@ -614,17 +614,17 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
614 goto exit_nolock; 614 goto exit_nolock;
615 } 615 }
616 616
617 dbg(4," %s : in progress, count = %Zd", __func__, count); 617 dbg(4, " %s : in progress, count = %Zd", __func__, count);
618 } else { 618 } else {
619 spin_unlock_irqrestore(&dev->buflock, flags); 619 spin_unlock_irqrestore(&dev->buflock, flags);
620 set_current_state(TASK_RUNNING); 620 set_current_state(TASK_RUNNING);
621 remove_wait_queue(&dev->write_wait, &waita); 621 remove_wait_queue(&dev->write_wait, &waita);
622 dbg(4," %s : sending, count = %Zd", __func__, count); 622 dbg(4, " %s : sending, count = %Zd", __func__, count);
623 623
624 /* write the data into interrupt_out_buffer from userspace */ 624 /* write the data into interrupt_out_buffer from userspace */
625 buffer_size = usb_endpoint_maxp(dev->interrupt_out_endpoint); 625 buffer_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);
626 bytes_to_write = count > buffer_size ? buffer_size : count; 626 bytes_to_write = count > buffer_size ? buffer_size : count;
627 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd", 627 dbg(4, " %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
628 __func__, buffer_size, count, bytes_to_write); 628 __func__, buffer_size, count, bytes_to_write);
629 629
630 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) { 630 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) {
@@ -664,7 +664,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
664exit: 664exit:
665 mutex_unlock(&dev->mtx); 665 mutex_unlock(&dev->mtx);
666exit_nolock: 666exit_nolock:
667 dbg(2," %s : leave, return value %d", __func__, retval); 667 dbg(2, " %s : leave, return value %d", __func__, retval);
668 return retval; 668 return retval;
669 669
670exit_onqueue: 670exit_onqueue:
@@ -710,7 +710,7 @@ static int adu_probe(struct usb_interface *interface,
710 int out_end_size; 710 int out_end_size;
711 int i; 711 int i;
712 712
713 dbg(2," %s : enter", __func__); 713 dbg(2, " %s : enter", __func__);
714 714
715 if (udev == NULL) { 715 if (udev == NULL) {
716 dev_err(&interface->dev, "udev is NULL.\n"); 716 dev_err(&interface->dev, "udev is NULL.\n");
@@ -811,7 +811,7 @@ static int adu_probe(struct usb_interface *interface,
811 dev_err(&interface->dev, "Could not retrieve serial number\n"); 811 dev_err(&interface->dev, "Could not retrieve serial number\n");
812 goto error; 812 goto error;
813 } 813 }
814 dbg(2," %s : serial_number=%s", __func__, dev->serial_number); 814 dbg(2, " %s : serial_number=%s", __func__, dev->serial_number);
815 815
816 /* we can register the device now, as it is ready */ 816 /* we can register the device now, as it is ready */
817 usb_set_intfdata(interface, dev); 817 usb_set_intfdata(interface, dev);
@@ -832,7 +832,7 @@ static int adu_probe(struct usb_interface *interface,
832 udev->descriptor.idProduct, dev->serial_number, 832 udev->descriptor.idProduct, dev->serial_number,
833 (dev->minor - ADU_MINOR_BASE)); 833 (dev->minor - ADU_MINOR_BASE));
834exit: 834exit:
835 dbg(2," %s : leave, return value %p (dev)", __func__, dev); 835 dbg(2, " %s : leave, return value %p (dev)", __func__, dev);
836 836
837 return retval; 837 return retval;
838 838
@@ -851,7 +851,7 @@ static void adu_disconnect(struct usb_interface *interface)
851 struct adu_device *dev; 851 struct adu_device *dev;
852 int minor; 852 int minor;
853 853
854 dbg(2," %s : enter", __func__); 854 dbg(2, " %s : enter", __func__);
855 855
856 dev = usb_get_intfdata(interface); 856 dev = usb_get_intfdata(interface);
857 857
@@ -865,7 +865,7 @@ static void adu_disconnect(struct usb_interface *interface)
865 usb_set_intfdata(interface, NULL); 865 usb_set_intfdata(interface, NULL);
866 866
867 /* if the device is not opened, then we clean up right now */ 867 /* if the device is not opened, then we clean up right now */
868 dbg(2," %s : open count %d", __func__, dev->open_count); 868 dbg(2, " %s : open count %d", __func__, dev->open_count);
869 if (!dev->open_count) 869 if (!dev->open_count)
870 adu_delete(dev); 870 adu_delete(dev);
871 871
@@ -874,7 +874,7 @@ static void adu_disconnect(struct usb_interface *interface)
874 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n", 874 dev_info(&interface->dev, "ADU device adutux%d now disconnected\n",
875 (minor - ADU_MINOR_BASE)); 875 (minor - ADU_MINOR_BASE));
876 876
877 dbg(2," %s : leave", __func__); 877 dbg(2, " %s : leave", __func__);
878} 878}
879 879
880/* usb specific object needed to register this driver with the usb subsystem */ 880/* usb specific object needed to register this driver with the usb subsystem */