aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/transport.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-06-01 13:52:56 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-21 18:04:15 -0400
commit47104b0dd32cec467574822b0dc3517b3de3f0ad (patch)
tree7cc1a012b3351275249c15fbdfc608a1774762b4 /drivers/usb/storage/transport.c
parent7de18d8bf4b470752e799e219b38b6dff4b49993 (diff)
[PATCH] usb-storage: use usb_reset_composite_device
This patch (as701) modifies usb-storage to take advantage of the new usb_reset_composite_device() API. Now we will be able to safely request port resets even if other drivers are bound to a mass-storage device. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/transport.c')
-rw-r--r--drivers/usb/storage/transport.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 038f4582ca0b..19b25c5cafd4 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -703,16 +703,19 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
703 * device reset. */ 703 * device reset. */
704 Handle_Errors: 704 Handle_Errors:
705 705
706 /* Let the SCSI layer know we are doing a reset, set the 706 /* Set the RESETTING bit, and clear the ABORTING bit so that
707 * RESETTING bit, and clear the ABORTING bit so that the reset 707 * the reset may proceed. */
708 * may proceed. */
709 scsi_lock(us_to_host(us)); 708 scsi_lock(us_to_host(us));
710 usb_stor_report_bus_reset(us);
711 set_bit(US_FLIDX_RESETTING, &us->flags); 709 set_bit(US_FLIDX_RESETTING, &us->flags);
712 clear_bit(US_FLIDX_ABORTING, &us->flags); 710 clear_bit(US_FLIDX_ABORTING, &us->flags);
713 scsi_unlock(us_to_host(us)); 711 scsi_unlock(us_to_host(us));
714 712
713 /* We must release the device lock because the pre_reset routine
714 * will want to acquire it. */
715 mutex_unlock(&us->dev_mutex);
715 result = usb_stor_port_reset(us); 716 result = usb_stor_port_reset(us);
717 mutex_lock(&us->dev_mutex);
718
716 if (result < 0) { 719 if (result < 0) {
717 scsi_lock(us_to_host(us)); 720 scsi_lock(us_to_host(us));
718 usb_stor_report_device_reset(us); 721 usb_stor_report_device_reset(us);
@@ -1196,31 +1199,30 @@ int usb_stor_Bulk_reset(struct us_data *us)
1196 0, us->ifnum, NULL, 0); 1199 0, us->ifnum, NULL, 0);
1197} 1200}
1198 1201
1199/* Issue a USB port reset to the device. But don't do anything if 1202/* Issue a USB port reset to the device. The caller must not hold
1200 * there's more than one interface in the device, so that other users 1203 * us->dev_mutex.
1201 * are not affected. */ 1204 */
1202int usb_stor_port_reset(struct us_data *us) 1205int usb_stor_port_reset(struct us_data *us)
1203{ 1206{
1204 int result, rc; 1207 int result, rc_lock;
1205 1208
1206 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 1209 result = rc_lock =
1207 result = -EIO; 1210 usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
1208 US_DEBUGP("No reset during disconnect\n"); 1211 if (result < 0)
1209 } else if (us->pusb_dev->actconfig->desc.bNumInterfaces != 1) { 1212 US_DEBUGP("unable to lock device for reset: %d\n", result);
1210 result = -EBUSY; 1213 else {
1211 US_DEBUGP("Refusing to reset a multi-interface device\n"); 1214 /* Were we disconnected while waiting for the lock? */
1212 } else { 1215 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
1213 result = rc = 1216 result = -EIO;
1214 usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); 1217 US_DEBUGP("No reset during disconnect\n");
1215 if (result < 0) {
1216 US_DEBUGP("unable to lock device for reset: %d\n",
1217 result);
1218 } else { 1218 } else {
1219 result = usb_reset_device(us->pusb_dev); 1219 result = usb_reset_composite_device(
1220 if (rc) 1220 us->pusb_dev, us->pusb_intf);
1221 usb_unlock_device(us->pusb_dev); 1221 US_DEBUGP("usb_reset_composite_device returns %d\n",
1222 US_DEBUGP("usb_reset_device returns %d\n", result); 1222 result);
1223 } 1223 }
1224 if (rc_lock)
1225 usb_unlock_device(us->pusb_dev);
1224 } 1226 }
1225 return result; 1227 return result;
1226} 1228}