aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/adutux.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 17:19:17 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 17:19:17 -0400
commit50f732ee63b91eb08a29974b36bd63e1150bb642 (patch)
treefdfc63411a34ffbe26a3b0a997aaeff742a0301b /drivers/usb/misc/adutux.c
parentaa5bc2b58e3344da57f26b62e99e13e91c9e0a94 (diff)
parenta7205b30106a2d4ee268132644cdb292da2d9b41 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6: (78 commits) USB: update MAINAINERS and CREDITS for Freescale USB driver USB: update gadget files for fsl_usb2_udc driver USB: add Freescale high-speed USB SOC device controller driver USB: quirk for broken suspend of IT8152F/G USB: iowarrior.c: timeouts too small in usb_control_msg calls USB: dell device id for option.c USB: Remove Huawei unusual_devs entry USB: CP2101 New Device IDs USB: add picdem device to ldusb usbfs micro optimitation USB: remove ancient/broken CRIS hcd usb ethernet gadget, workaround network stack API glitch USB: add "busnum" attribute for USB devices USB: cxacru: ADSL state management usbatm: Detect usb device shutdown and ignore failed urbs USB: Remove duplicate define of OHCI_QUIRK_ZFMICRO USB: BandRich BandLuxe HSDPA Data Card Driver USB gadget rndis: fix struct rndis_packet_msg_type unaligned bug USB Elan FTDI: check for driver registration status USB: sierra: add more checks on shutdown ...
Diffstat (limited to 'drivers/usb/misc/adutux.c')
-rw-r--r--drivers/usb/misc/adutux.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 75bfab95ab3c..77145f9db043 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -285,23 +285,24 @@ static int adu_open(struct inode *inode, struct file *file)
285 /* save device in the file's private structure */ 285 /* save device in the file's private structure */
286 file->private_data = dev; 286 file->private_data = dev;
287 287
288 /* initialize in direction */ 288 if (dev->open_count == 1) {
289 dev->read_buffer_length = 0; 289 /* initialize in direction */
290 290 dev->read_buffer_length = 0;
291 /* fixup first read by having urb waiting for it */
292 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
293 usb_rcvintpipe(dev->udev,
294 dev->interrupt_in_endpoint->bEndpointAddress),
295 dev->interrupt_in_buffer,
296 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
297 adu_interrupt_in_callback, dev,
298 dev->interrupt_in_endpoint->bInterval);
299 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
300 dev->read_urb_finished = 0;
301 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
302 /* we ignore failure */
303 /* end of fixup for first read */
304 291
292 /* fixup first read by having urb waiting for it */
293 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
294 usb_rcvintpipe(dev->udev,
295 dev->interrupt_in_endpoint->bEndpointAddress),
296 dev->interrupt_in_buffer,
297 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
298 adu_interrupt_in_callback, dev,
299 dev->interrupt_in_endpoint->bInterval);
300 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
301 dev->read_urb_finished = 0;
302 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
303 if (retval)
304 --dev->open_count;
305 }
305 up(&dev->sem); 306 up(&dev->sem);
306 307
307exit_no_device: 308exit_no_device:
@@ -469,7 +470,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
469 adu_interrupt_in_callback, 470 adu_interrupt_in_callback,
470 dev, 471 dev,
471 dev->interrupt_in_endpoint->bInterval); 472 dev->interrupt_in_endpoint->bInterval);
472 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL); 473 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
473 if (!retval) { 474 if (!retval) {
474 spin_unlock_irqrestore(&dev->buflock, flags); 475 spin_unlock_irqrestore(&dev->buflock, flags);
475 dbg(2," %s : submitted OK", __FUNCTION__); 476 dbg(2," %s : submitted OK", __FUNCTION__);
@@ -539,7 +540,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
539 size_t bytes_written = 0; 540 size_t bytes_written = 0;
540 size_t bytes_to_write; 541 size_t bytes_to_write;
541 size_t buffer_size; 542 size_t buffer_size;
542 int retval = 0; 543 int retval;
543 int timeout = 0; 544 int timeout = 0;
544 545
545 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count); 546 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count);
@@ -547,7 +548,9 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
547 dev = file->private_data; 548 dev = file->private_data;
548 549
549 /* lock this object */ 550 /* lock this object */
550 down_interruptible(&dev->sem); 551 retval = down_interruptible(&dev->sem);
552 if (retval)
553 goto exit_nolock;
551 554
552 /* verify that the device wasn't unplugged */ 555 /* verify that the device wasn't unplugged */
553 if (dev->udev == NULL || dev->minor == 0) { 556 if (dev->udev == NULL || dev->minor == 0) {
@@ -575,7 +578,11 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
575 } 578 }
576 up(&dev->sem); 579 up(&dev->sem);
577 timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout); 580 timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout);
578 down_interruptible(&dev->sem); 581 retval = down_interruptible(&dev->sem);
582 if (retval) {
583 retval = bytes_written ? bytes_written : retval;
584 goto exit_nolock;
585 }
579 if (timeout > 0) { 586 if (timeout > 0) {
580 break; 587 break;
581 } 588 }
@@ -637,6 +644,7 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
637exit: 644exit:
638 /* unlock the device */ 645 /* unlock the device */
639 up(&dev->sem); 646 up(&dev->sem);
647exit_nolock:
640 648
641 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 649 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
642 650