aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/scsiglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage/scsiglue.c')
-rw-r--r--drivers/usb/storage/scsiglue.c67
1 files changed, 24 insertions, 43 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 22e48a2b0bd1..af294bb68c35 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -155,6 +155,15 @@ static int slave_configure(struct scsi_device *sdev)
* If this device makes that mistake, tell the sd driver. */
if (us->flags & US_FL_FIX_CAPACITY)
sdev->fix_capacity = 1;
+
+ /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable
+ * Hardware Error) when any low-level error occurs,
+ * recoverable or not. Setting this flag tells the SCSI
+ * midlayer to retry such commands, which frequently will
+ * succeed and fix the error. The worst this can lead to
+ * is an occasional series of retries that will all fail. */
+ sdev->retry_hwerror = 1;
+
} else {
/* Non-disk-type devices don't need to blacklist any pages
@@ -233,13 +242,11 @@ static int command_abort(struct scsi_cmnd *srb)
set_bit(US_FLIDX_ABORTING, &us->flags);
usb_stor_stop_transport(us);
}
- scsi_unlock(us_to_host(us));
/* Wait for the aborted command to finish */
wait_for_completion(&us->notify);
/* Reacquire the lock and allow USB transfers to resume */
- scsi_lock(us_to_host(us));
clear_bit(US_FLIDX_ABORTING, &us->flags);
clear_bit(US_FLIDX_TIMED_OUT, &us->flags);
return SUCCESS;
@@ -255,62 +262,28 @@ static int device_reset(struct scsi_cmnd *srb)
US_DEBUGP("%s called\n", __FUNCTION__);
- scsi_unlock(us_to_host(us));
-
/* 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));
- /* lock the host for the return */
- scsi_lock(us_to_host(us));
- 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__);
- scsi_unlock(us_to_host(us));
-
- /* 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 */
- scsi_lock(us_to_host(us));
return result < 0 ? FAILED : SUCCESS;
}
@@ -329,6 +302,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
***********************************************************************/
@@ -407,7 +388,7 @@ US_DO_ALL_FLAGS
***********************************************************************/
/* Output routine for the sysfs max_sectors file */
-static ssize_t show_max_sectors(struct device *dev, char *buf)
+static ssize_t show_max_sectors(struct device *dev, struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
@@ -415,7 +396,7 @@ static ssize_t show_max_sectors(struct device *dev, char *buf)
}
/* Input routine for the sysfs max_sectors file */
-static ssize_t store_max_sectors(struct device *dev, const char *buf,
+static ssize_t store_max_sectors(struct device *dev, struct device_attribute *attr, const char *buf,
size_t count)
{
struct scsi_device *sdev = to_scsi_device(dev);