ChangeSet 1.855.9.11, 2002/11/05 11:17:12-08:00, mdharm-usb@one-eyed-alien.net [PATCH] USB storage: fix result code checks This patch fixes up some result-code tests that were missed in previous patches. diff -Nru a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c --- a/drivers/usb/storage/freecom.c Tue Nov 5 16:10:21 2002 +++ b/drivers/usb/storage/freecom.c Tue Nov 5 16:10:21 2002 @@ -127,7 +127,7 @@ /* Issue the transfer command. */ result = usb_stor_bulk_msg (us, fxfr, opipe, FCM_PACKET_LENGTH, &partial); - if (result != 0) { + if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("Freecom readdata xpot failure: r=%d, p=%d\n", result, partial); @@ -146,7 +146,9 @@ result = usb_stor_bulk_transfer_srb(us, ipipe, srb, count); US_DEBUGP("freecom_readdata done!\n"); - return result; + if (result > USB_STOR_XFER_SHORT) + return USB_STOR_TRANSPORT_ERROR; + return USB_STOR_TRANSPORT_GOOD; } static int @@ -168,7 +170,7 @@ /* Issue the transfer command. */ result = usb_stor_bulk_msg (us, fxfr, opipe, FCM_PACKET_LENGTH, &partial); - if (result != 0) { + if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("Freecom writedata xpot failure: r=%d, p=%d\n", result, partial); @@ -188,7 +190,9 @@ result = usb_stor_bulk_transfer_srb(us, opipe, srb, count); US_DEBUGP("freecom_writedata done!\n"); - return result; + if (result > USB_STOR_XFER_SHORT) + return USB_STOR_TRANSPORT_ERROR; + return USB_STOR_TRANSPORT_GOOD; } /* @@ -231,7 +235,7 @@ /* The Freecom device will only fail if there is something wrong in * USB land. It returns the status in its own registers, which * come back in the bulk pipe. */ - if (result != 0) { + if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("freecom xport failure: r=%d, p=%d\n", result, partial); @@ -255,6 +259,8 @@ US_DEBUGP("freecom_transport(): transfer aborted\n"); return USB_STOR_TRANSPORT_ABORTED; } + if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; US_DEBUG(pdump ((void *) fst, partial)); @@ -284,7 +290,7 @@ * wrong in USB land. It returns the status in its own * registers, which come back in the bulk pipe. */ - if (result != 0) { + if (result != USB_STOR_XFER_GOOD) { US_DEBUGP ("freecom xport failure: r=%d, p=%d\n", result, partial); @@ -308,13 +314,14 @@ US_DEBUGP("freecom_transport(): transfer aborted\n"); return USB_STOR_TRANSPORT_ABORTED; } + if (result > USB_STOR_XFER_SHORT) + return USB_STOR_TRANSPORT_ERROR; US_DEBUG(pdump ((void *) fst, partial)); } - if (partial != 4 || result != 0) { + if (partial != 4) return USB_STOR_TRANSPORT_ERROR; - } if ((fst->Status & 1) != 0) { US_DEBUGP("operation failed\n"); return USB_STOR_TRANSPORT_FAILED; @@ -369,7 +376,7 @@ US_DEBUGP ("freecom_transport: transfer aborted\n"); return USB_STOR_TRANSPORT_ABORTED; } - if (partial != 4 || result != 0) + if (partial != 4 || result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & ERR_STAT) != 0) { US_DEBUGP("operation failed\n"); @@ -398,7 +405,7 @@ US_DEBUGP ("freecom_transport: transfer aborted\n"); return USB_STOR_TRANSPORT_ABORTED; } - if (partial != 4 || result != 0) + if (partial != 4 || result > USB_STOR_XFER_SHORT) return USB_STOR_TRANSPORT_ERROR; if ((fst->Status & ERR_STAT) != 0) { US_DEBUGP("operation failed\n"); diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c --- a/drivers/usb/storage/isd200.c Tue Nov 5 16:10:21 2002 +++ b/drivers/usb/storage/isd200.c Tue Nov 5 16:10:21 2002 @@ -660,6 +660,8 @@ switch (bcs.Status) { case US_BULK_STAT_OK: /* command good -- note that we could be short on data */ + if (srb->resid > 0) + return ISD200_TRANSPORT_SHORT; return ISD200_TRANSPORT_GOOD; case US_BULK_STAT_FAIL: @@ -764,7 +766,8 @@ } status = isd200_Bulk_transport(us, &srb, &ata, sizeof(ata.generic)); - if (status != ISD200_TRANSPORT_GOOD) { + if (status != ISD200_TRANSPORT_GOOD && + status != ISD200_TRANSPORT_SHORT) { US_DEBUGP(" isd200_action(0x%02x) error: %d\n",action,status); status = ISD200_ERROR; /* need to reset device here */ @@ -846,6 +849,7 @@ break; case ISD200_TRANSPORT_SHORT: + srb->result = GOOD << 1; if (!((srb->cmnd[0] == REQUEST_SENSE) || (srb->cmnd[0] == INQUIRY) || (srb->cmnd[0] == MODE_SENSE) || diff -Nru a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c --- a/drivers/usb/storage/shuttle_usbat.c Tue Nov 5 16:10:21 2002 +++ b/drivers/usb/storage/shuttle_usbat.c Tue Nov 5 16:10:21 2002 @@ -804,7 +804,8 @@ result = usbat_read(us, USBAT_ATA, 0x17, &status); US_DEBUGP("Status = %02X\n", status); - + if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; if (srb->cmnd[0] == TEST_UNIT_READY) transferred = 0;