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

[PATCH] USB storage: fix result code checks

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