summaryrefslogtreecommitdiff
path: root/drivers/usb/storage/scsiglue.c
diff options
context:
space:
mode:
authorMatthew Dharm <mdharm-usb@one-eyed-alien.net>2005-06-06 17:21:41 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-27 14:44:03 -0700
commit4d07ef762fc8d6d35ecc1511a3b953a733a61a5f (patch)
tree9ea2bbce922ed74bcef3d26dd1843afaf6f7a877 /drivers/usb/storage/scsiglue.c
parent5203ad441310a4c2abd4fb79015a6bdadc2a5a4f (diff)
[PATCH] USB Storage: port reset on transport error
This patch causes a port reset whenever there's a transport error or abort. If that fails it reverts back to doing a mass-storage device reset. It started life as as497 and was rediffed by me. This makes error recovery a lot quicker and more reliable. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/scsiglue.c')
-rw-r--r--drivers/usb/storage/scsiglue.c45
1 files changed, 13 insertions, 32 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index e43eddc3d44b..da2bfa944b96 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -255,50 +255,23 @@ static int device_reset(struct scsi_cmnd *srb)
/* lock the device pointers and do the reset */
down(&(us->dev_semaphore));
- if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
- result = FAILED;
- US_DEBUGP("No reset during disconnect\n");
- } else
- result = us->transport_reset(us);
+ result = us->transport_reset(us);
up(&(us->dev_semaphore));
- return result;
+ return result < 0 ? FAILED : SUCCESS;
}
-/* This resets the device's USB port. */
-/* It refuses to work if there's more than one interface in
- * the device, so that other users are not affected. */
+/* Simulate a SCSI bus reset by resetting the device's USB port. */
/* This is always called with scsi_lock(host) held */
static int bus_reset(struct scsi_cmnd *srb)
{
struct us_data *us = host_to_us(srb->device->host);
- int result, rc;
+ int result;
US_DEBUGP("%s called\n", __FUNCTION__);
- /* The USB subsystem doesn't handle synchronisation between
- * a device's several drivers. Therefore we reset only devices
- * with just one interface, which we of course own. */
-
down(&(us->dev_semaphore));
- if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
- result = -EIO;
- US_DEBUGP("No reset during disconnect\n");
- } else if (us->pusb_dev->actconfig->desc.bNumInterfaces != 1) {
- result = -EBUSY;
- US_DEBUGP("Refusing to reset a multi-interface device\n");
- } else {
- rc = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
- if (rc < 0) {
- US_DEBUGP("unable to lock device for reset: %d\n", rc);
- result = rc;
- } else {
- result = usb_reset_device(us->pusb_dev);
- if (rc)
- usb_unlock_device(us->pusb_dev);
- US_DEBUGP("usb_reset_device returns %d\n", result);
- }
- }
+ result = usb_stor_port_reset(us);
up(&(us->dev_semaphore));
/* lock the host for the return */
@@ -320,6 +293,14 @@ void usb_stor_report_device_reset(struct us_data *us)
}
}
+/* Report a driver-initiated bus reset to the SCSI layer.
+ * Calling this for a SCSI-initiated reset is unnecessary but harmless.
+ * The caller must own the SCSI host lock. */
+void usb_stor_report_bus_reset(struct us_data *us)
+{
+ scsi_report_bus_reset(us_to_host(us), 0);
+}
+
/***********************************************************************
* /proc/scsi/ functions
***********************************************************************/