aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/cdc-wdm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/class/cdc-wdm.c')
-rw-r--r--drivers/usb/class/cdc-wdm.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 0bb2b3248dad..5d151653ae43 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -369,6 +369,7 @@ static ssize_t wdm_write
369 r = usb_autopm_get_interface(desc->intf); 369 r = usb_autopm_get_interface(desc->intf);
370 if (r < 0) { 370 if (r < 0) {
371 kfree(buf); 371 kfree(buf);
372 rv = usb_translate_errors(r);
372 goto outnp; 373 goto outnp;
373 } 374 }
374 375
@@ -384,6 +385,7 @@ static ssize_t wdm_write
384 385
385 if (r < 0) { 386 if (r < 0) {
386 kfree(buf); 387 kfree(buf);
388 rv = r;
387 goto out; 389 goto out;
388 } 390 }
389 391
@@ -415,6 +417,7 @@ static ssize_t wdm_write
415 desc->outbuf = NULL; 417 desc->outbuf = NULL;
416 clear_bit(WDM_IN_USE, &desc->flags); 418 clear_bit(WDM_IN_USE, &desc->flags);
417 dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); 419 dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
420 rv = usb_translate_errors(rv);
418 } else { 421 } else {
419 dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d", 422 dev_dbg(&desc->intf->dev, "Tx URB has been submitted index=%d",
420 req->wIndex); 423 req->wIndex);
@@ -534,7 +537,7 @@ static int wdm_flush(struct file *file, fl_owner_t id)
534 dev_err(&desc->intf->dev, "Error in flush path: %d\n", 537 dev_err(&desc->intf->dev, "Error in flush path: %d\n",
535 desc->werr); 538 desc->werr);
536 539
537 return desc->werr; 540 return usb_translate_errors(desc->werr);
538} 541}
539 542
540static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait) 543static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
@@ -596,6 +599,7 @@ static int wdm_open(struct inode *inode, struct file *file)
596 desc->count--; 599 desc->count--;
597 dev_err(&desc->intf->dev, 600 dev_err(&desc->intf->dev,
598 "Error submitting int urb - %d\n", rv); 601 "Error submitting int urb - %d\n", rv);
602 rv = usb_translate_errors(rv);
599 } 603 }
600 } else { 604 } else {
601 rv = 0; 605 rv = 0;
@@ -623,8 +627,12 @@ static int wdm_release(struct inode *inode, struct file *file)
623 if (!desc->count) { 627 if (!desc->count) {
624 dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); 628 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
625 kill_urbs(desc); 629 kill_urbs(desc);
626 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) 630 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
627 desc->manage_power(desc->intf, 0); 631 desc->manage_power(desc->intf, 0);
632 } else {
633 dev_dbg(&desc->intf->dev, "%s: device gone - cleaning up\n", __func__);
634 cleanup(desc);
635 }
628 } 636 }
629 mutex_unlock(&wdm_mutex); 637 mutex_unlock(&wdm_mutex);
630 return 0; 638 return 0;
@@ -898,6 +906,8 @@ static void wdm_disconnect(struct usb_interface *intf)
898 mutex_unlock(&desc->rlock); 906 mutex_unlock(&desc->rlock);
899 if (!desc->count) 907 if (!desc->count)
900 cleanup(desc); 908 cleanup(desc);
909 else
910 dev_dbg(&intf->dev, "%s: %d open files - postponing cleanup\n", __func__, desc->count);
901 mutex_unlock(&wdm_mutex); 911 mutex_unlock(&wdm_mutex);
902} 912}
903 913