diff options
Diffstat (limited to 'drivers/usb/storage/scsiglue.c')
-rw-r--r-- | drivers/usb/storage/scsiglue.c | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index e43eddc3d44b..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) | |||
155 | * If this device makes that mistake, tell the sd driver. */ | 155 | * If this device makes that mistake, tell the sd driver. */ |
156 | if (us->flags & US_FL_FIX_CAPACITY) | 156 | if (us->flags & US_FL_FIX_CAPACITY) |
157 | sdev->fix_capacity = 1; | 157 | sdev->fix_capacity = 1; |
158 | |||
159 | /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable | ||
160 | * Hardware Error) when any low-level error occurs, | ||
161 | * recoverable or not. Setting this flag tells the SCSI | ||
162 | * midlayer to retry such commands, which frequently will | ||
163 | * succeed and fix the error. The worst this can lead to | ||
164 | * is an occasional series of retries that will all fail. */ | ||
165 | sdev->retry_hwerror = 1; | ||
166 | |||
158 | } else { | 167 | } else { |
159 | 168 | ||
160 | /* Non-disk-type devices don't need to blacklist any pages | 169 | /* Non-disk-type devices don't need to blacklist any pages |
@@ -255,50 +264,23 @@ static int device_reset(struct scsi_cmnd *srb) | |||
255 | 264 | ||
256 | /* lock the device pointers and do the reset */ | 265 | /* lock the device pointers and do the reset */ |
257 | down(&(us->dev_semaphore)); | 266 | down(&(us->dev_semaphore)); |
258 | if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { | 267 | result = us->transport_reset(us); |
259 | result = FAILED; | ||
260 | US_DEBUGP("No reset during disconnect\n"); | ||
261 | } else | ||
262 | result = us->transport_reset(us); | ||
263 | up(&(us->dev_semaphore)); | 268 | up(&(us->dev_semaphore)); |
264 | 269 | ||
265 | return result; | 270 | return result < 0 ? FAILED : SUCCESS; |
266 | } | 271 | } |
267 | 272 | ||
268 | /* This resets the device's USB port. */ | 273 | /* Simulate a SCSI bus reset by resetting the device's USB port. */ |
269 | /* It refuses to work if there's more than one interface in | ||
270 | * the device, so that other users are not affected. */ | ||
271 | /* This is always called with scsi_lock(host) held */ | 274 | /* This is always called with scsi_lock(host) held */ |
272 | static int bus_reset(struct scsi_cmnd *srb) | 275 | static int bus_reset(struct scsi_cmnd *srb) |
273 | { | 276 | { |
274 | struct us_data *us = host_to_us(srb->device->host); | 277 | struct us_data *us = host_to_us(srb->device->host); |
275 | int result, rc; | 278 | int result; |
276 | 279 | ||
277 | US_DEBUGP("%s called\n", __FUNCTION__); | 280 | US_DEBUGP("%s called\n", __FUNCTION__); |
278 | 281 | ||
279 | /* The USB subsystem doesn't handle synchronisation between | ||
280 | * a device's several drivers. Therefore we reset only devices | ||
281 | * with just one interface, which we of course own. */ | ||
282 | |||
283 | down(&(us->dev_semaphore)); | 282 | down(&(us->dev_semaphore)); |
284 | if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { | 283 | result = usb_stor_port_reset(us); |
285 | result = -EIO; | ||
286 | US_DEBUGP("No reset during disconnect\n"); | ||
287 | } else if (us->pusb_dev->actconfig->desc.bNumInterfaces != 1) { | ||
288 | result = -EBUSY; | ||
289 | US_DEBUGP("Refusing to reset a multi-interface device\n"); | ||
290 | } else { | ||
291 | rc = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); | ||
292 | if (rc < 0) { | ||
293 | US_DEBUGP("unable to lock device for reset: %d\n", rc); | ||
294 | result = rc; | ||
295 | } else { | ||
296 | result = usb_reset_device(us->pusb_dev); | ||
297 | if (rc) | ||
298 | usb_unlock_device(us->pusb_dev); | ||
299 | US_DEBUGP("usb_reset_device returns %d\n", result); | ||
300 | } | ||
301 | } | ||
302 | up(&(us->dev_semaphore)); | 284 | up(&(us->dev_semaphore)); |
303 | 285 | ||
304 | /* lock the host for the return */ | 286 | /* lock the host for the return */ |
@@ -320,6 +302,14 @@ void usb_stor_report_device_reset(struct us_data *us) | |||
320 | } | 302 | } |
321 | } | 303 | } |
322 | 304 | ||
305 | /* Report a driver-initiated bus reset to the SCSI layer. | ||
306 | * Calling this for a SCSI-initiated reset is unnecessary but harmless. | ||
307 | * The caller must own the SCSI host lock. */ | ||
308 | void usb_stor_report_bus_reset(struct us_data *us) | ||
309 | { | ||
310 | scsi_report_bus_reset(us_to_host(us), 0); | ||
311 | } | ||
312 | |||
323 | /*********************************************************************** | 313 | /*********************************************************************** |
324 | * /proc/scsi/ functions | 314 | * /proc/scsi/ functions |
325 | ***********************************************************************/ | 315 | ***********************************************************************/ |