Commit 01c0c43a authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] USB-storage: final abort handler cleanup

This should be the final patch to make the abort mechanisms work properly.
parent 7d822283
......@@ -434,6 +434,12 @@ static int isd200_transfer_partial( struct us_data *us,
return ISD200_TRANSPORT_GOOD;
}
/* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("isd200_transfer_partial(): transfer aborted\n");
return ISD200_TRANSFER_ABORTED;
}
/* uh oh... we have an error code, so something went wrong. */
if (result) {
/* NAK - that means we've retried a few times already */
......@@ -442,12 +448,6 @@ static int isd200_transfer_partial( struct us_data *us,
return ISD200_TRANSPORT_FAILED;
}
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
US_DEBUGP("isd200_transfer_partial(): transfer aborted\n");
return ISD200_TRANSPORT_ABORTED;
}
/* the catch-all case */
US_DEBUGP("isd200_transfer_partial(): unknown error\n");
return ISD200_TRANSPORT_FAILED;
......@@ -581,8 +581,11 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
&partial);
US_DEBUGP("Bulk command transfer result=%d\n", result);
if (result == -ENOENT)
return ISD200_TRANSPORT_ABORTED;
/* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
return ISD200_TRANSFER_ABORTED;
}
else if (result == -EPIPE) {
/* if we stall, we need to clear it before we go on */
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
......@@ -610,8 +613,10 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
US_DEBUGP("Attempting to get CSW...\n");
result = usb_stor_bulk_msg(us, &bcs, pipe, US_BULK_CS_WRAP_LEN,
&partial);
if (result == -ENOENT)
return ISD200_TRANSPORT_ABORTED;
/* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
return ISD200_TRANSFER_ABORTED;
}
/* did the attempt to read the CSW fail? */
if (result == -EPIPE) {
......@@ -624,8 +629,9 @@ int isd200_Bulk_transport( struct us_data *us, Scsi_Cmnd *srb,
US_BULK_CS_WRAP_LEN, &partial);
/* if the command was aborted, indicate that */
if (result == -ENOENT)
return ISD200_TRANSPORT_ABORTED;
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
return ISD200_TRANSFER_ABORTED;
}
/* if it fails again, we need a reset and return an error*/
if (result == -EPIPE) {
......
......@@ -3,7 +3,7 @@
* Unrelated to CF/SM - just USB stuff.
*
* This is mostly a thin layer on top of transport.c.
* It converts routines that return values like -ENOENT and -EPIPE
* It converts routines that return values like -EPIPE
* into routines that return USB_STOR_TRANSPORT_ABORTED etc.
*
* There is also some debug printing here.
......@@ -58,13 +58,14 @@ usb_storage_send_control(struct us_data *us,
request, requesttype, value, index,
xfer_data, xfer_len);
/* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_send_control(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
// Check the return code for the command.
if (result < 0) {
/* if the command was aborted, indicate that */
if (result == -ENOENT)
return USB_STOR_TRANSPORT_ABORTED;
/* a stall is a fatal condition from the device */
if (result == -EPIPE) {
......@@ -105,13 +106,13 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
/* return US_BULK_TRANSFER_SHORT; */
}
if (result) {
/* -ENOENT -- we canceled this transfer */
if (result == -ENOENT) {
US_DEBUGP("raw_bulk(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
/* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_storage_raw_bulk(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
if (result) {
/* NAK - that means we've retried a few times already */
if (result == -ETIMEDOUT)
US_DEBUGP("raw_bulk(): device NAKed\n");
......
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