.. | .. |
---|
411 | 411 | ***********************************************************************/ |
---|
412 | 412 | |
---|
413 | 413 | /* Command timeout and abort */ |
---|
414 | | -static int command_abort(struct scsi_cmnd *srb) |
---|
| 414 | +static int command_abort_matching(struct us_data *us, struct scsi_cmnd *srb_match) |
---|
415 | 415 | { |
---|
416 | | - struct us_data *us = host_to_us(srb->device->host); |
---|
417 | | - |
---|
418 | | - usb_stor_dbg(us, "%s called\n", __func__); |
---|
419 | | - |
---|
420 | 416 | /* |
---|
421 | 417 | * us->srb together with the TIMED_OUT, RESETTING, and ABORTING |
---|
422 | 418 | * bits are protected by the host lock. |
---|
423 | 419 | */ |
---|
424 | 420 | scsi_lock(us_to_host(us)); |
---|
425 | 421 | |
---|
426 | | - /* Is this command still active? */ |
---|
427 | | - if (us->srb != srb) { |
---|
| 422 | + /* is there any active pending command to abort ? */ |
---|
| 423 | + if (!us->srb) { |
---|
428 | 424 | scsi_unlock(us_to_host(us)); |
---|
429 | 425 | usb_stor_dbg(us, "-- nothing to abort\n"); |
---|
| 426 | + return SUCCESS; |
---|
| 427 | + } |
---|
| 428 | + |
---|
| 429 | + /* Does the command match the passed srb if any ? */ |
---|
| 430 | + if (srb_match && us->srb != srb_match) { |
---|
| 431 | + scsi_unlock(us_to_host(us)); |
---|
| 432 | + usb_stor_dbg(us, "-- pending command mismatch\n"); |
---|
430 | 433 | return FAILED; |
---|
431 | 434 | } |
---|
432 | 435 | |
---|
.. | .. |
---|
449 | 452 | return SUCCESS; |
---|
450 | 453 | } |
---|
451 | 454 | |
---|
| 455 | +static int command_abort(struct scsi_cmnd *srb) |
---|
| 456 | +{ |
---|
| 457 | + struct us_data *us = host_to_us(srb->device->host); |
---|
| 458 | + |
---|
| 459 | + usb_stor_dbg(us, "%s called\n", __func__); |
---|
| 460 | + return command_abort_matching(us, srb); |
---|
| 461 | +} |
---|
| 462 | + |
---|
452 | 463 | /* |
---|
453 | 464 | * This invokes the transport reset mechanism to reset the state of the |
---|
454 | 465 | * device |
---|
.. | .. |
---|
460 | 471 | |
---|
461 | 472 | usb_stor_dbg(us, "%s called\n", __func__); |
---|
462 | 473 | |
---|
| 474 | + /* abort any pending command before reset */ |
---|
| 475 | + command_abort_matching(us, NULL); |
---|
| 476 | + |
---|
463 | 477 | /* lock the device pointers and do the reset */ |
---|
464 | 478 | mutex_lock(&(us->dev_mutex)); |
---|
465 | 479 | result = us->transport_reset(us); |
---|