ChangeSet 1.823.3.1, 2002/11/11 13:12:39-08:00, mdharm-usb@one-eyed-alien.net [PATCH] usb storage: remmove unneeded abort checks Since we now test for aborts at a higher level, the low-level end of the drivers don't need to be constantly testing for aborts. This patch removes that excess logic. diff -Nru a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c --- a/drivers/usb/storage/freecom.c Thu Nov 14 14:13:13 2002 +++ b/drivers/usb/storage/freecom.c Thu Nov 14 14:13:13 2002 @@ -130,13 +130,6 @@ if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("Freecom readdata xpot failure: r=%d, p=%d\n", result, partial); - - /* has the current command been aborted? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("freecom_readdata(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - return USB_STOR_TRANSPORT_ERROR; } US_DEBUGP("Done issuing read request: %d %d\n", result, partial); @@ -173,13 +166,6 @@ if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("Freecom writedata xpot failure: r=%d, p=%d\n", result, partial); - - /* has the current command been aborted? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("freecom_writedata(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - return USB_STOR_TRANSPORT_ERROR; } US_DEBUGP("Done issuing write request: %d %d\n", @@ -238,13 +224,6 @@ if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("freecom xport failure: r=%d, p=%d\n", result, partial); - - /* we canceled this transfer */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("freecom_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - return USB_STOR_TRANSPORT_ERROR; } @@ -253,12 +232,6 @@ result = usb_stor_bulk_msg (us, fst, ipipe, FCM_PACKET_LENGTH, &partial); US_DEBUGP("foo Status result %d %d\n", result, partial); - - /* we canceled this transfer */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("freecom_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; @@ -293,13 +266,6 @@ if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("freecom xport failure: r=%d, p=%d\n", result, partial); - - /* we canceled this transfer */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("freecom_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - return USB_STOR_TRANSPORT_ERROR; } @@ -308,12 +274,6 @@ FCM_PACKET_LENGTH, &partial); US_DEBUGP("bar Status result %d %d\n", result, partial); - - /* we canceled this transfer */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("freecom_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } if (result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; @@ -372,10 +332,6 @@ FCM_PACKET_LENGTH, &partial); US_DEBUG(pdump ((void *) fst, partial)); - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP ("freecom_transport: transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } if (partial != 4 || result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & ERR_STAT) != 0) { @@ -401,10 +357,6 @@ result = usb_stor_bulk_msg (us, fst, ipipe, FCM_PACKET_LENGTH, &partial); - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP ("freecom_transport: transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } if (partial != 4 || result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & ERR_STAT) != 0) { diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c --- a/drivers/usb/storage/isd200.c Thu Nov 14 14:13:13 2002 +++ b/drivers/usb/storage/isd200.c Thu Nov 14 14:13:13 2002 @@ -130,7 +130,6 @@ #define ISD200_TRANSPORT_GOOD 0 /* Transport good, command good */ #define ISD200_TRANSPORT_FAILED 1 /* Transport good, command failed */ #define ISD200_TRANSPORT_ERROR 2 /* Transport bad (i.e. device dead) */ -#define ISD200_TRANSPORT_ABORTED 3 /* Transport aborted */ #define ISD200_TRANSPORT_SHORT 4 /* Transport short */ /* driver action codes */ @@ -436,11 +435,6 @@ result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, (char *) &bcb, US_BULK_CB_WRAP_LEN, NULL); US_DEBUGP("Bulk command transfer result=%d\n", result); - - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - return ISD200_TRANSPORT_ABORTED; - } if (result != USB_STOR_XFER_GOOD) return ISD200_TRANSPORT_ERROR; @@ -451,10 +445,6 @@ result = usb_stor_bulk_transfer_srb(us, pipe, srb, transfer_length); US_DEBUGP("Bulk data transfer result 0x%x\n", result); - - /* if it was aborted, we need to indicate that */ - if (result == USB_STOR_XFER_ABORTED) - return ISD200_TRANSPORT_ABORTED; if (result == USB_STOR_XFER_ERROR) return ISD200_TRANSPORT_ERROR; } @@ -468,11 +458,6 @@ result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, (char *) &bcs, US_BULK_CS_WRAP_LEN, NULL); - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - return ISD200_TRANSPORT_ABORTED; - } - /* did the attempt to read the CSW fail? */ if (result == USB_STOR_XFER_STALLED) { @@ -480,11 +465,6 @@ US_DEBUGP("Attempting to get CSW (2nd try)...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, (char *) &bcs, US_BULK_CS_WRAP_LEN, NULL); - - /* if the command was aborted, indicate that */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - return ISD200_TRANSPORT_ABORTED; - } } /* if we still have a failure at this point, we're in trouble */ @@ -686,14 +666,6 @@ case ISD200_TRANSPORT_GOOD: /* Indicate a good result */ srb->result = GOOD << 1; - break; - - case ISD200_TRANSPORT_ABORTED: - /* if the command gets aborted by the higher layers, we need to - * short-circuit all other processing - */ - US_DEBUGP("-- transport indicates command was aborted\n"); - srb->result = DID_ABORT << 16; break; case ISD200_TRANSPORT_FAILED: diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Thu Nov 14 14:13:13 2002 +++ b/drivers/usb/storage/transport.c Thu Nov 14 14:13:13 2002 @@ -562,12 +562,6 @@ value, index, data, size); US_DEBUGP("usb_stor_control_msg returned %d\n", result); - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("-- transfer aborted\n"); - return USB_STOR_XFER_ABORTED; - } - /* a stall indicates a protocol error */ if (result == -EPIPE) { US_DEBUGP("-- stall on control pipe\n"); @@ -624,12 +618,6 @@ return USB_STOR_XFER_STALLED; } - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("-- transfer aborted\n"); - return USB_STOR_XFER_ABORTED; - } - /* NAK - that means we've retried a few times already */ if (result == -ETIMEDOUT) { US_DEBUGP("-- device NAKed\n"); @@ -1116,15 +1104,6 @@ if (result != USB_STOR_XFER_GOOD) { /* Reset flag for status notification */ clear_bit(US_FLIDX_IP_WANTED, &us->flags); - } - - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("usb_stor_control_msg(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - - if (result != USB_STOR_XFER_GOOD) { /* Uh oh... serious problem here */ return USB_STOR_TRANSPORT_ERROR; } @@ -1137,12 +1116,6 @@ result = usb_stor_bulk_transfer_srb(us, pipe, srb, transfer_length); US_DEBUGP("CBI data stage result is 0x%x\n", result); - - /* report any errors */ - if (result == USB_STOR_XFER_ABORTED) { - clear_bit(US_FLIDX_IP_WANTED, &us->flags); - return USB_STOR_TRANSPORT_ABORTED; - } if (result == USB_STOR_XFER_ERROR) { clear_bit(US_FLIDX_IP_WANTED, &us->flags); return USB_STOR_TRANSPORT_ERROR; @@ -1157,7 +1130,7 @@ /* has the current command been aborted? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("CBI interrupt aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; + return USB_STOR_TRANSPORT_ERROR; } US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", @@ -1222,13 +1195,6 @@ /* check the return code for the command */ US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result); - - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("usb_stor_CB_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - if (result != USB_STOR_XFER_GOOD) { /* Uh oh... serious problem here */ return USB_STOR_TRANSPORT_ERROR; @@ -1242,14 +1208,8 @@ result = usb_stor_bulk_transfer_srb(us, pipe, srb, transfer_length); US_DEBUGP("CB data stage result is 0x%x\n", result); - - /* report any errors */ - if (result == USB_STOR_XFER_ABORTED) { - return USB_STOR_TRANSPORT_ABORTED; - } - if (result == USB_STOR_XFER_ERROR) { + if (result == USB_STOR_XFER_ERROR) return USB_STOR_TRANSPORT_ERROR; - } } /* STATUS STAGE */ @@ -1319,12 +1279,6 @@ result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, (char *) &bcb, US_BULK_CB_WRAP_LEN, NULL); US_DEBUGP("Bulk command transfer result=%d\n", result); - - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; @@ -1336,10 +1290,6 @@ result = usb_stor_bulk_transfer_srb(us, pipe, srb, transfer_length); US_DEBUGP("Bulk data transfer result 0x%x\n", result); - - /* if it was aborted, we need to indicate that */ - if (result == USB_STOR_XFER_ABORTED) - return USB_STOR_TRANSPORT_ABORTED; if (result == USB_STOR_XFER_ERROR) return USB_STOR_TRANSPORT_ERROR; } @@ -1353,12 +1303,6 @@ result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, (char *) &bcs, US_BULK_CS_WRAP_LEN, NULL); - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } - /* did the attempt to read the CSW fail? */ if (result == USB_STOR_XFER_STALLED) { @@ -1366,12 +1310,6 @@ US_DEBUGP("Attempting to get CSW (2nd try)...\n"); result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, (char *) &bcs, US_BULK_CS_WRAP_LEN, NULL); - - /* did we abort this command? */ - if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { - US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); - return USB_STOR_TRANSPORT_ABORTED; - } } /* if we still have a failure at this point, we're in trouble */ diff -Nru a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h --- a/drivers/usb/storage/transport.h Thu Nov 14 14:13:13 2002 +++ b/drivers/usb/storage/transport.h Thu Nov 14 14:13:13 2002 @@ -121,7 +121,6 @@ #define USB_STOR_XFER_SHORT 1 /* transfered less than expected */ #define USB_STOR_XFER_STALLED 2 /* endpoint stalled */ #define USB_STOR_XFER_ERROR 3 /* transfer died in the middle */ -#define USB_STOR_XFER_ABORTED 4 /* transfer canceled */ /* * Transport return codes