Commit 88142a11 authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] USB storage: check for abort at higher levels

This patch adds tests for an aborted command to higher-level functions.
This allows faster exit from a couple of paths and will allow code
consolidation in the lower-level transport functions.
parent b2f45fd6
......@@ -818,11 +818,22 @@ void isd200_invoke_transport( struct us_data *us,
{
int need_auto_sense = 0;
int transferStatus;
int result;
/* send the command to the transport layer */
srb->resid = 0;
transferStatus = isd200_Bulk_transport(us, srb, ataCdb,
sizeof(ataCdb->generic));
/* if the command gets aborted by the higher layers, we need to
* short-circuit all other processing
*/
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("-- transport indicates command was aborted\n");
srb->result = DID_ABORT << 16;
return;
}
switch (transferStatus) {
case ISD200_TRANSPORT_GOOD:
......@@ -866,9 +877,14 @@ void isd200_invoke_transport( struct us_data *us,
}
if (need_auto_sense)
if (isd200_read_regs(us) == ISD200_GOOD)
if (need_auto_sense) {
result = isd200_read_regs(us);
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("-- auto-sense aborted\n");
srb->result = DID_ABORT << 16;
} else if (result == ISD200_GOOD)
isd200_build_sense(us, srb);
}
/* Regardless of auto-sense, if we _know_ we have an error
* condition, show that in the result code
......
......@@ -790,13 +790,14 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
/* if the command gets aborted by the higher layers, we need to
* short-circuit all other processing
*/
if (result == USB_STOR_TRANSPORT_ABORTED) {
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("-- transport indicates command was aborted\n");
srb->result = DID_ABORT << 16;
return;
}
/* if there is a transport error, reset and don't auto-sense */
/* What if we want to abort during the reset? */
if (result == USB_STOR_TRANSPORT_ERROR) {
US_DEBUGP("-- transport indicates error, resetting\n");
us->transport_reset(us);
......@@ -904,7 +905,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
srb->sc_data_direction = old_sc_data_direction;
memcpy(srb->cmnd, old_cmnd, MAX_COMMAND_SIZE);
if (temp_result == USB_STOR_TRANSPORT_ABORTED) {
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("-- auto-sense aborted\n");
srb->result = DID_ABORT << 16;
return;
......@@ -917,6 +918,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
* auto-sense is perfectly valid
*/
if (!(us->flags & US_FL_SCM_MULT_TARG)) {
/* What if we try to abort during the reset? */
us->transport_reset(us);
}
srb->result = DID_ERROR << 16;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment