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.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)
255 255
256 /* lock the device pointers and do the reset */ 256 /* lock the device pointers and do the reset */
257 down(&(us->dev_semaphore)); 257 down(&(us->dev_semaphore));
258 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 258 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)); 259 up(&(us->dev_semaphore));
264 260
265 return result; 261 return result < 0 ? FAILED : SUCCESS;
266} 262}
267 263
268/* This resets the device's USB port. */ 264/* 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 */ 265/* This is always called with scsi_lock(host) held */
272static int bus_reset(struct scsi_cmnd *srb) 266static int bus_reset(struct scsi_cmnd *srb)
273{ 267{
274 struct us_data *us = host_to_us(srb->device->host); 268 struct us_data *us = host_to_us(srb->device->host);
275 int result, rc; 269 int result;
276 270
277 US_DEBUGP("%s called\n", __FUNCTION__); 271 US_DEBUGP("%s called\n", __FUNCTION__);
278 272
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)); 273 down(&(us->dev_semaphore));
284 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 274 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)); 275 up(&(us->dev_semaphore));
303 276
304 /* lock the host for the return */ 277 /* lock the host for the return */
@@ -320,6 +293,14 @@ void usb_stor_report_device_reset(struct us_data *us)
320 } 293 }
321} 294}
322 295
296/* Report a driver-initiated bus reset to the SCSI layer.
297 * Calling this for a SCSI-initiated reset is unnecessary but harmless.
298 * The caller must own the SCSI host lock. */
299void usb_stor_report_bus_reset(struct us_data *us)
300{
301 scsi_report_bus_reset(us_to_host(us), 0);
302}
303
323/*********************************************************************** 304/***********************************************************************
324 * /proc/scsi/ functions 305 * /proc/scsi/ functions
325 ***********************************************************************/ 306 ***********************************************************************/