# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.493 -> 1.494 # drivers/usb/storage/raw_bulk.c 1.1 -> 1.2 # drivers/usb/storage/isd200.c 1.11 -> 1.12 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/08/18 mdharm-usb@one-eyed-alien.net 1.494 # [PATCH] USB-storage: final abort handler cleanup # # This should be the final patch to make the abort mechanisms work properly. # -------------------------------------------- # diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c --- a/drivers/usb/storage/isd200.c Sun Aug 18 20:48:23 2002 +++ b/drivers/usb/storage/isd200.c Sun Aug 18 20:48:23 2002 @@ -434,6 +434,12 @@ 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 @@ 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 @@ &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 @@ 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 @@ 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) { diff -Nru a/drivers/usb/storage/raw_bulk.c b/drivers/usb/storage/raw_bulk.c --- a/drivers/usb/storage/raw_bulk.c Sun Aug 18 20:48:23 2002 +++ b/drivers/usb/storage/raw_bulk.c Sun Aug 18 20:48:23 2002 @@ -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 @@ 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 @@ /* 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");