Commit 0d80c6f5 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] usb-storage: fix return codes...

Like the header says, this patch fixes up the various Transfer- and
Transport-level return codes.  There were a lot of places in the various
subdrivers that were not particularly careful about distinguishing the
two; it would help if the people currently maintaining those drivers could
take a look at my changes to make sure I haven't screwed anything up.

# Converted US_BULK_TRANSFER_xxx to USB_STOR_XFER_xxx, to make it more
# easily distinguishable from USB_STOR_TRANSPORT_xxx.  (Also, in the
# future these codes may apply to control transfers as well as to bulk
# transfers.)
#
# Changed USB_STOR_XFER_FAILED to USB_STOR_XFER_ERROR, since it implies
# a transport error rather than a transport failure.
#
# Added a USB_STOR_XFER_STALLED code, to indicate a transfer that was
# terminated by an endpoint stall.

This patch is in preparation for one in which usb_stor_transfer_partial()
and usb_stor_transfer() are replaced by usb_stor_bulk_transfer_buf() and
usb_stor_bulk_transfer_srb() respectively, with slightly different
argument lists.  Ultimately the subdrivers will be able to use these
routines in place of the slightly specialized versions they have now and
in place of the ones in raw_bulk.c.
parent 7e5b54d4
...@@ -70,7 +70,7 @@ datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) { ...@@ -70,7 +70,7 @@ datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("datafab_bulk_read: len = %d\n", len); US_DEBUGP("datafab_bulk_read: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len);
...@@ -82,7 +82,7 @@ datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) { ...@@ -82,7 +82,7 @@ datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) {
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("datafab_bulk_write: len = %d\n", len); US_DEBUGP("datafab_bulk_write: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len);
...@@ -144,12 +144,12 @@ static int datafab_read_data(struct us_data *us, ...@@ -144,12 +144,12 @@ static int datafab_read_data(struct us_data *us,
// send the read command // send the read command
result = datafab_bulk_write(us, command, sizeof(command)); result = datafab_bulk_write(us, command, sizeof(command));
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// read the result // read the result
result = datafab_bulk_read(us, ptr, len); result = datafab_bulk_read(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
sectors -= thistime; sectors -= thistime;
...@@ -171,7 +171,7 @@ static int datafab_read_data(struct us_data *us, ...@@ -171,7 +171,7 @@ static int datafab_read_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -243,17 +243,17 @@ static int datafab_write_data(struct us_data *us, ...@@ -243,17 +243,17 @@ static int datafab_write_data(struct us_data *us,
// send the command // send the command
result = datafab_bulk_write(us, command, sizeof(command)); result = datafab_bulk_write(us, command, sizeof(command));
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// send the data // send the data
result = datafab_bulk_write(us, ptr, len); result = datafab_bulk_write(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// read the result // read the result
result = datafab_bulk_read(us, reply, sizeof(reply)); result = datafab_bulk_read(us, reply, sizeof(reply));
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
if (reply[0] != 0x50 && reply[1] != 0) { if (reply[0] != 0x50 && reply[1] != 0) {
...@@ -280,7 +280,7 @@ static int datafab_write_data(struct us_data *us, ...@@ -280,7 +280,7 @@ static int datafab_write_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -308,11 +308,11 @@ static int datafab_determine_lun(struct us_data *us, ...@@ -308,11 +308,11 @@ static int datafab_determine_lun(struct us_data *us,
command[5] = 0xa0; command[5] = 0xa0;
rc = datafab_bulk_write(us, command, 8); rc = datafab_bulk_write(us, command, 8);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
rc = datafab_bulk_read(us, buf, sizeof(buf)); rc = datafab_bulk_read(us, buf, sizeof(buf));
if (rc == USB_STOR_TRANSPORT_GOOD) { if (rc == USB_STOR_XFER_GOOD) {
info->lun = 0; info->lun = 0;
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
} }
...@@ -320,11 +320,11 @@ static int datafab_determine_lun(struct us_data *us, ...@@ -320,11 +320,11 @@ static int datafab_determine_lun(struct us_data *us,
command[5] = 0xb0; command[5] = 0xb0;
rc = datafab_bulk_write(us, command, 8); rc = datafab_bulk_write(us, command, 8);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
rc = datafab_bulk_read(us, buf, sizeof(buf)); rc = datafab_bulk_read(us, buf, sizeof(buf));
if (rc == USB_STOR_TRANSPORT_GOOD) { if (rc == USB_STOR_XFER_GOOD) {
info->lun = 1; info->lun = 1;
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
} }
...@@ -332,7 +332,7 @@ static int datafab_determine_lun(struct us_data *us, ...@@ -332,7 +332,7 @@ static int datafab_determine_lun(struct us_data *us,
wait_ms(20); wait_ms(20);
} }
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
static int datafab_id_device(struct us_data *us, static int datafab_id_device(struct us_data *us,
...@@ -358,22 +358,23 @@ static int datafab_id_device(struct us_data *us, ...@@ -358,22 +358,23 @@ static int datafab_id_device(struct us_data *us,
command[5] += (info->lun << 4); command[5] += (info->lun << 4);
rc = datafab_bulk_write(us, command, 8); rc = datafab_bulk_write(us, command, 8);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
// we'll go ahead and extract the media capacity while we're here... // we'll go ahead and extract the media capacity while we're here...
// //
rc = datafab_bulk_read(us, reply, sizeof(reply)); rc = datafab_bulk_read(us, reply, sizeof(reply));
if (rc == USB_STOR_TRANSPORT_GOOD) { if (rc == USB_STOR_XFER_GOOD) {
// capacity is at word offset 57-58 // capacity is at word offset 57-58
// //
info->sectors = ((u32)(reply[117]) << 24) | info->sectors = ((u32)(reply[117]) << 24) |
((u32)(reply[116]) << 16) | ((u32)(reply[116]) << 16) |
((u32)(reply[115]) << 8) | ((u32)(reply[115]) << 8) |
((u32)(reply[114]) ); ((u32)(reply[114]) );
return USB_STOR_TRANSPORT_GOOD;
} }
return rc; return USB_STOR_TRANSPORT_ERROR;
} }
......
...@@ -197,7 +197,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -197,7 +197,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us,
/* has the current command been aborted? */ /* has the current command been aborted? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_readdata(): transfer aborted\n"); US_DEBUGP("freecom_readdata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -238,7 +238,7 @@ freecom_writedata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -238,7 +238,7 @@ freecom_writedata (Scsi_Cmnd *srb, struct us_data *us,
/* has the current command been aborted? */ /* has the current command been aborted? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_writedata(): transfer aborted\n"); US_DEBUGP("freecom_writedata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -301,7 +301,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -301,7 +301,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -316,7 +316,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -316,7 +316,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
US_DEBUG(pdump ((void *) fst, partial)); US_DEBUG(pdump ((void *) fst, partial));
...@@ -354,7 +354,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -354,7 +354,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -369,7 +369,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -369,7 +369,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
US_DEBUG(pdump ((void *) fst, partial)); US_DEBUG(pdump ((void *) fst, partial));
...@@ -430,7 +430,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -430,7 +430,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP ("freecom_transport: transfer aborted\n"); US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (partial != 4 || result != 0) if (partial != 4 || result != 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -459,7 +459,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -459,7 +459,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP ("freecom_transport: transfer aborted\n"); US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (partial != 4 || result != 0) if (partial != 4 || result != 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
......
...@@ -65,7 +65,7 @@ static inline int jumpshot_bulk_read(struct us_data *us, ...@@ -65,7 +65,7 @@ static inline int jumpshot_bulk_read(struct us_data *us,
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("jumpshot_bulk_read: len = %d\n", len); US_DEBUGP("jumpshot_bulk_read: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len);
...@@ -79,7 +79,7 @@ static inline int jumpshot_bulk_write(struct us_data *us, ...@@ -79,7 +79,7 @@ static inline int jumpshot_bulk_write(struct us_data *us,
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("jumpshot_bulk_write: len = %d\n", len); US_DEBUGP("jumpshot_bulk_write: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len);
...@@ -168,7 +168,7 @@ static int jumpshot_read_data(struct us_data *us, ...@@ -168,7 +168,7 @@ static int jumpshot_read_data(struct us_data *us,
// read the result // read the result
result = jumpshot_bulk_read(us, ptr, len); result = jumpshot_bulk_read(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
US_DEBUGP("jumpshot_read_data: %d bytes\n", len); US_DEBUGP("jumpshot_read_data: %d bytes\n", len);
...@@ -192,7 +192,7 @@ static int jumpshot_read_data(struct us_data *us, ...@@ -192,7 +192,7 @@ static int jumpshot_read_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -253,7 +253,7 @@ static int jumpshot_write_data(struct us_data *us, ...@@ -253,7 +253,7 @@ static int jumpshot_write_data(struct us_data *us,
// send the data // send the data
result = jumpshot_bulk_write(us, ptr, len); result = jumpshot_bulk_write(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// read the result. apparently the bulk write can complete // read the result. apparently the bulk write can complete
...@@ -288,7 +288,7 @@ static int jumpshot_write_data(struct us_data *us, ...@@ -288,7 +288,7 @@ static int jumpshot_write_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
static int jumpshot_id_device(struct us_data *us, static int jumpshot_id_device(struct us_data *us,
...@@ -314,8 +314,8 @@ static int jumpshot_id_device(struct us_data *us, ...@@ -314,8 +314,8 @@ static int jumpshot_id_device(struct us_data *us,
// read the reply // read the reply
rc = jumpshot_bulk_read(us, reply, sizeof(reply)); rc = jumpshot_bulk_read(us, reply, sizeof(reply));
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
info->sectors = ((u32)(reply[117]) << 24) | info->sectors = ((u32)(reply[117]) << 24) |
((u32)(reply[116]) << 16) | ((u32)(reply[116]) << 16) |
......
...@@ -61,7 +61,7 @@ usb_storage_send_control(struct us_data *us, ...@@ -61,7 +61,7 @@ usb_storage_send_control(struct us_data *us,
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_send_control(): transfer aborted\n"); US_DEBUGP("usb_stor_send_control(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
// Check the return code for the command. // Check the return code for the command.
...@@ -70,7 +70,7 @@ usb_storage_send_control(struct us_data *us, ...@@ -70,7 +70,7 @@ usb_storage_send_control(struct us_data *us,
/* a stall indicates a protocol error */ /* a stall indicates a protocol error */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("-- Stall on control pipe\n"); US_DEBUGP("-- Stall on control pipe\n");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
/* Uh oh... serious problem here */ /* Uh oh... serious problem here */
...@@ -100,14 +100,14 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -100,14 +100,14 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
" pipe 0x%x, stalled at %d bytes\n", " pipe 0x%x, stalled at %d bytes\n",
pipe, *act_len); pipe, *act_len);
if (usb_stor_clear_halt(us, pipe) < 0) if (usb_stor_clear_halt(us, pipe) < 0)
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
/* return US_BULK_TRANSFER_SHORT; */ return USB_STOR_XFER_STALLED;
} }
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_storage_raw_bulk(): transfer aborted\n"); US_DEBUGP("usb_storage_raw_bulk(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_XFER_ABORTED;
} }
if (result) { if (result) {
...@@ -122,13 +122,13 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -122,13 +122,13 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
US_DEBUGP("raw_bulk(): unknown error %d\n", US_DEBUGP("raw_bulk(): unknown error %d\n",
result); result);
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
} }
if (*act_len != len) { if (*act_len != len) {
US_DEBUGP("Warning: Transferred only %d of %d bytes\n", US_DEBUGP("Warning: Transferred only %d of %d bytes\n",
*act_len, len); *act_len, len);
return US_BULK_TRANSFER_SHORT; return USB_STOR_XFER_SHORT;
} }
#if 0 #if 0
...@@ -137,7 +137,7 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -137,7 +137,7 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
*act_len, len); *act_len, len);
#endif #endif
return US_BULK_TRANSFER_GOOD; return USB_STOR_XFER_GOOD;
} }
int int
...@@ -145,14 +145,14 @@ usb_storage_bulk_transport(struct us_data *us, int direction, ...@@ -145,14 +145,14 @@ usb_storage_bulk_transport(struct us_data *us, int direction,
unsigned char *data, unsigned int len, unsigned char *data, unsigned int len,
int use_sg) { int use_sg) {
int result = USB_STOR_TRANSPORT_GOOD; int result = USB_STOR_XFER_ERROR;
int transferred = 0; int transferred = 0;
int i; int i;
struct scatterlist *sg; struct scatterlist *sg;
unsigned int act_len; unsigned int act_len;
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
#if DEBUG_PRCT #if DEBUG_PRCT
...@@ -196,7 +196,7 @@ usb_storage_bulk_transport(struct us_data *us, int direction, ...@@ -196,7 +196,7 @@ usb_storage_bulk_transport(struct us_data *us, int direction,
result = usb_storage_raw_bulk(us, direction, result = usb_storage_raw_bulk(us, direction,
buf, length, &act_len); buf, length, &act_len);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
break; break;
transferred += length; transferred += length;
} }
......
...@@ -285,12 +285,14 @@ sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) { ...@@ -285,12 +285,14 @@ sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) {
} }
result = usb_storage_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen, &act_len); result = usb_storage_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen, &act_len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("request sense bulk in failed\n"); US_DEBUGP("request sense bulk in failed\n");
else return USB_STOR_TRANSPORT_ERROR;
}
else {
US_DEBUGP("request sense worked\n"); US_DEBUGP("request sense worked\n");
return USB_STOR_TRANSPORT_GOOD;
return result; }
} }
/* /*
...@@ -344,11 +346,12 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress, ...@@ -344,11 +346,12 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
buf, bulklen, use_sg); buf, bulklen, use_sg);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for bulk_transport in sddr09_read2%d %d\n", US_DEBUGP("Result for bulk_transport in sddr09_read2%d %d\n",
x, result); x, result);
return USB_STOR_TRANSPORT_ERROR;
return result; }
return USB_STOR_TRANSPORT_GOOD;
} }
/* /*
...@@ -510,11 +513,12 @@ sddr09_writeX(struct us_data *us, ...@@ -510,11 +513,12 @@ sddr09_writeX(struct us_data *us,
result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE,
buf, bulklen, use_sg); buf, bulklen, use_sg);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for bulk_transport in sddr09_writeX %d\n", US_DEBUGP("Result for bulk_transport in sddr09_writeX %d\n",
result); result);
return USB_STOR_TRANSPORT_ERROR;
return result; }
return USB_STOR_TRANSPORT_GOOD;
} }
/* erase address, write same address */ /* erase address, write same address */
...@@ -590,13 +594,14 @@ sddr09_read_sg_test_only(struct us_data *us) { ...@@ -590,13 +594,14 @@ sddr09_read_sg_test_only(struct us_data *us) {
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
buf, bulklen, 0); buf, bulklen, 0);
if (result != USB_STOR_TRANSPORT_GOOD) kfree(buf);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for bulk_transport in sddr09_read_sg %d\n", US_DEBUGP("Result for bulk_transport in sddr09_read_sg %d\n",
result); result);
return USB_STOR_TRANSPORT_ERROR;
}
kfree(buf); return USB_STOR_TRANSPORT_GOOD;
return result;
} }
#endif #endif
...@@ -629,7 +634,8 @@ sddr09_read_status(struct us_data *us, unsigned char *status) { ...@@ -629,7 +634,8 @@ sddr09_read_status(struct us_data *us, unsigned char *status) {
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
data, sizeof(data), 0); data, sizeof(data), 0);
*status = data[0]; *status = data[0];
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
static int static int
...@@ -953,7 +959,8 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { ...@@ -953,7 +959,8 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
deviceID[i] = content[i]; deviceID[i] = content[i];
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
static int static int
...@@ -1549,7 +1556,8 @@ int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1549,7 +1556,8 @@ int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us)
srb->request_bufflen, srb->request_bufflen,
srb->use_sg); srb->use_sg);
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
......
...@@ -101,16 +101,16 @@ static int sddr55_status(struct us_data *us) ...@@ -101,16 +101,16 @@ static int sddr55_status(struct us_data *us)
US_DEBUGP("Result for send_command in status %d\n", US_DEBUGP("Result for send_command in status %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
return result; return USB_STOR_TRANSPORT_ERROR;
} }
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 4); SCSI_DATA_READ, status, 4);
/* expect to get short transfer if no card fitted */ /* expect to get short transfer if no card fitted */
if (result == US_BULK_TRANSFER_SHORT) { if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) {
/* had a short transfer, no card inserted, free map memory */ /* had a short transfer, no card inserted, free map memory */
if (info->lba_to_pba) if (info->lba_to_pba)
kfree(info->lba_to_pba); kfree(info->lba_to_pba);
...@@ -123,12 +123,12 @@ static int sddr55_status(struct us_data *us) ...@@ -123,12 +123,12 @@ static int sddr55_status(struct us_data *us)
info->force_read_only = 0; info->force_read_only = 0;
set_sense_info (2, 0x3a, 0); /* not ready, medium not present */ set_sense_info (2, 0x3a, 0); /* not ready, medium not present */
return result; return USB_STOR_TRANSPORT_FAILED;
} }
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
return result; return USB_STOR_TRANSPORT_FAILED;
} }
/* check write protect status */ /* check write protect status */
...@@ -138,11 +138,12 @@ static int sddr55_status(struct us_data *us) ...@@ -138,11 +138,12 @@ static int sddr55_status(struct us_data *us)
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2); SCSI_DATA_READ, status, 2);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
} }
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_FAILED);
} }
...@@ -214,23 +215,29 @@ static int sddr55_read_data(struct us_data *us, ...@@ -214,23 +215,29 @@ static int sddr55_read_data(struct us_data *us,
US_DEBUGP("Result for send_command in read_data %d\n", US_DEBUGP("Result for send_command in read_data %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
goto leave; goto leave;
}
/* read data */ /* read data */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, ptr, SCSI_DATA_READ, ptr,
pages<<info->pageshift); pages<<info->pageshift);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
goto leave; goto leave;
}
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2); SCSI_DATA_READ, status, 2);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
goto leave; goto leave;
}
/* check status for error */ /* check status for error */
if (status[0] == 0xff && status[1] == 0x4) { if (status[0] == 0xff && status[1] == 0x4) {
...@@ -247,6 +254,7 @@ static int sddr55_read_data(struct us_data *us, ...@@ -247,6 +254,7 @@ static int sddr55_read_data(struct us_data *us,
} }
us_copy_to_sgbuf_all(buffer, len, content, use_sg); us_copy_to_sgbuf_all(buffer, len, content, use_sg);
result = USB_STOR_TRANSPORT_GOOD;
leave: leave:
if (use_sg) if (use_sg)
...@@ -374,12 +382,13 @@ static int sddr55_write_data(struct us_data *us, ...@@ -374,12 +382,13 @@ static int sddr55_write_data(struct us_data *us,
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8); SCSI_DATA_WRITE, command, 8);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for send_command in write_data %d\n", US_DEBUGP("Result for send_command in write_data %d\n",
result); result);
/* set_sense_info is superfluous here? */ /* set_sense_info is superfluous here? */
set_sense_info (3, 0x3, 0);/* peripheral write error */ set_sense_info (3, 0x3, 0);/* peripheral write error */
result = USB_STOR_TRANSPORT_FAILED;
goto leave; goto leave;
} }
...@@ -388,24 +397,26 @@ static int sddr55_write_data(struct us_data *us, ...@@ -388,24 +397,26 @@ static int sddr55_write_data(struct us_data *us,
SCSI_DATA_WRITE, ptr, SCSI_DATA_WRITE, ptr,
pages<<info->pageshift); pages<<info->pageshift);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for send_data in write_data %d\n", US_DEBUGP("Result for send_data in write_data %d\n",
result); result);
/* set_sense_info is superfluous here? */ /* set_sense_info is superfluous here? */
set_sense_info (3, 0x3, 0);/* peripheral write error */ set_sense_info (3, 0x3, 0);/* peripheral write error */
result = USB_STOR_TRANSPORT_FAILED;
goto leave; goto leave;
} }
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6); result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for get_status in write_data %d\n", US_DEBUGP("Result for get_status in write_data %d\n",
result); result);
/* set_sense_info is superfluous here? */ /* set_sense_info is superfluous here? */
set_sense_info (3, 0x3, 0);/* peripheral write error */ set_sense_info (3, 0x3, 0);/* peripheral write error */
result = USB_STOR_TRANSPORT_FAILED;
goto leave; goto leave;
} }
...@@ -446,6 +457,7 @@ static int sddr55_write_data(struct us_data *us, ...@@ -446,6 +457,7 @@ static int sddr55_write_data(struct us_data *us,
sectors -= pages >> info->smallpageshift; sectors -= pages >> info->smallpageshift;
ptr += (pages << info->pageshift); ptr += (pages << info->pageshift);
} }
result = USB_STOR_TRANSPORT_GOOD;
leave: leave:
if (use_sg) if (use_sg)
...@@ -468,14 +480,14 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -468,14 +480,14 @@ static int sddr55_read_deviceID(struct us_data *us,
US_DEBUGP("Result of send_control for device ID is %d\n", US_DEBUGP("Result of send_control for device ID is %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, content, 4); SCSI_DATA_READ, content, 4);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
*manufacturerID = content[0]; *manufacturerID = content[0];
*deviceID = content[1]; *deviceID = content[1];
...@@ -485,7 +497,7 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -485,7 +497,7 @@ static int sddr55_read_deviceID(struct us_data *us,
SCSI_DATA_READ, content, 2); SCSI_DATA_READ, content, 2);
} }
return result; return USB_STOR_TRANSPORT_GOOD;
} }
...@@ -510,7 +522,7 @@ static unsigned long sddr55_get_capacity(struct us_data *us) { ...@@ -510,7 +522,7 @@ static unsigned long sddr55_get_capacity(struct us_data *us) {
US_DEBUGP("Result of read_deviceID is %d\n", US_DEBUGP("Result of read_deviceID is %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return 0; return 0;
US_DEBUGP("Device ID = %02X\n", deviceID); US_DEBUGP("Device ID = %02X\n", deviceID);
...@@ -603,21 +615,21 @@ static int sddr55_read_map(struct us_data *us) { ...@@ -603,21 +615,21 @@ static int sddr55_read_map(struct us_data *us) {
result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8); result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8);
if ( result != US_BULK_TRANSFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
result = sddr55_bulk_transport(us, SCSI_DATA_READ, buffer, numblocks * 2); result = sddr55_bulk_transport(us, SCSI_DATA_READ, buffer, numblocks * 2);
if ( result != US_BULK_TRANSFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2); result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2);
if ( result != US_BULK_TRANSFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
......
...@@ -153,7 +153,8 @@ int usbat_read_block(struct us_data *us, ...@@ -153,7 +153,8 @@ int usbat_read_block(struct us_data *us,
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, len, use_sg); result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, len, use_sg);
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
/* /*
...@@ -234,8 +235,8 @@ int usbat_write_block(struct us_data *us, ...@@ -234,8 +235,8 @@ int usbat_write_block(struct us_data *us,
result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg); result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
return usbat_wait_not_busy(us, minutes); return usbat_wait_not_busy(us, minutes);
} }
...@@ -309,8 +310,8 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -309,8 +310,8 @@ int usbat_rw_block_test(struct us_data *us,
SCSI_DATA_WRITE, SCSI_DATA_WRITE,
data, num_registers*2, 0); data, num_registers*2, 0);
if (result!=USB_STOR_TRANSPORT_GOOD) if (result!=USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -341,7 +342,8 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -341,7 +342,8 @@ int usbat_rw_block_test(struct us_data *us,
* transferred. * transferred.
*/ */
if (result == US_BULK_TRANSFER_SHORT) { if (result == USB_STOR_XFER_SHORT ||
result == USB_STOR_XFER_STALLED) {
/* /*
* If we're reading and we stalled, then clear * If we're reading and we stalled, then clear
...@@ -373,8 +375,8 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -373,8 +375,8 @@ int usbat_rw_block_test(struct us_data *us,
US_DEBUGP("Redoing %s\n", US_DEBUGP("Redoing %s\n",
direction==SCSI_DATA_WRITE ? "write" : "read"); direction==SCSI_DATA_WRITE ? "write" : "read");
} else if (result != US_BULK_TRANSFER_GOOD) } else if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
else else
return usbat_wait_not_busy(us, minutes); return usbat_wait_not_busy(us, minutes);
...@@ -425,8 +427,8 @@ int usbat_multiple_write(struct us_data *us, ...@@ -425,8 +427,8 @@ int usbat_multiple_write(struct us_data *us,
result = usb_storage_bulk_transport(us, result = usb_storage_bulk_transport(us,
SCSI_DATA_WRITE, data, num_registers*2, 0); SCSI_DATA_WRITE, data, num_registers*2, 0);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
return usbat_wait_not_busy(us, 0); return usbat_wait_not_busy(us, 0);
} }
......
...@@ -572,36 +572,37 @@ int usb_stor_transfer_partial(struct us_data *us, char *buf, int length) ...@@ -572,36 +572,37 @@ int usb_stor_transfer_partial(struct us_data *us, char *buf, int length)
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
if (usb_stor_clear_halt(us, pipe) < 0) if (usb_stor_clear_halt(us, pipe) < 0)
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
return USB_STOR_XFER_STALLED;
} }
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_transfer_partial(): transfer aborted\n"); US_DEBUGP("usb_stor_transfer_partial(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_XFER_ABORTED;
}
/* did we send all the data? */
if (partial == length) {
US_DEBUGP("usb_stor_transfer_partial(): transfer complete\n");
return US_BULK_TRANSFER_GOOD;
} }
/* NAK - that means we've retried a few times already */ /* NAK - that means we've retried a few times already */
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
US_DEBUGP("usb_stor_transfer_partial(): device NAKed\n"); US_DEBUGP("usb_stor_transfer_partial(): device NAKed\n");
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
} }
/* the catch-all error case */ /* the catch-all error case */
if (result) { if (result) {
US_DEBUGP("usb_stor_transfer_partial(): unknown error\n"); US_DEBUGP("usb_stor_transfer_partial(): unknown error\n");
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
}
/* did we send all the data? */
if (partial == length) {
US_DEBUGP("usb_stor_transfer_partial(): transfer complete\n");
return USB_STOR_XFER_GOOD;
} }
/* no error code, so we must have transferred some data, /* no error code, so we must have transferred some data,
* just not all of it */ * just not all of it */
return US_BULK_TRANSFER_SHORT; return USB_STOR_XFER_SHORT;
} }
/* /*
...@@ -739,7 +740,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -739,7 +740,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
* Also, if we have a short transfer on a command that can't have * Also, if we have a short transfer on a command that can't have
* a short transfer, we're going to do this. * a short transfer, we're going to do this.
*/ */
if ((srb->result == US_BULK_TRANSFER_SHORT) && if ((srb->result == USB_STOR_XFER_SHORT) &&
!((srb->cmnd[0] == REQUEST_SENSE) || !((srb->cmnd[0] == REQUEST_SENSE) ||
(srb->cmnd[0] == INQUIRY) || (srb->cmnd[0] == INQUIRY) ||
(srb->cmnd[0] == MODE_SENSE) || (srb->cmnd[0] == MODE_SENSE) ||
...@@ -995,13 +996,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -995,13 +996,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_control_msg(): transfer aborted\n"); US_DEBUGP("usb_stor_control_msg(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* a stall indicates a protocol error */ /* a stall indicates a protocol error */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("-- Stall on control pipe\n"); US_DEBUGP("-- Stall on control pipe\n");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
if (result < 0) { if (result < 0) {
...@@ -1017,13 +1018,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1017,13 +1018,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("CBI data stage result is 0x%x\n", result); US_DEBUGP("CBI data stage result is 0x%x\n", result);
/* report any errors */ /* report any errors */
if (result == US_BULK_TRANSFER_ABORTED) { if (result == USB_STOR_XFER_ABORTED) {
clear_bit(US_FLIDX_IP_WANTED, &us->flags); clear_bit(US_FLIDX_IP_WANTED, &us->flags);
return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result == US_BULK_TRANSFER_FAILED) { if (result == USB_STOR_XFER_ERROR) {
clear_bit(US_FLIDX_IP_WANTED, &us->flags); clear_bit(US_FLIDX_IP_WANTED, &us->flags);
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
} }
...@@ -1103,13 +1104,13 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1103,13 +1104,13 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_CB_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_CB_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* a stall indicates a protocol error */ /* a stall indicates a protocol error */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("-- Stall on control pipe\n"); US_DEBUGP("-- Stall on control pipe\n");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
/* Uh oh... serious problem here */ /* Uh oh... serious problem here */
...@@ -1124,11 +1125,11 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1124,11 +1125,11 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("CB data stage result is 0x%x\n", result); US_DEBUGP("CB data stage result is 0x%x\n", result);
/* report any errors */ /* report any errors */
if (result == US_BULK_TRANSFER_ABORTED) { if (result == USB_STOR_XFER_ABORTED) {
return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result == US_BULK_TRANSFER_FAILED) { if (result == USB_STOR_XFER_ERROR) {
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
} }
...@@ -1207,7 +1208,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1207,7 +1208,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* if we stall, we need to clear it before we go on */ /* if we stall, we need to clear it before we go on */
...@@ -1218,7 +1219,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1218,7 +1219,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result < 0) if (result < 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -1237,7 +1238,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1237,7 +1238,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("Bulk data transfer result 0x%x\n", result); US_DEBUGP("Bulk data transfer result 0x%x\n", result);
/* if it was aborted, we need to indicate that */ /* if it was aborted, we need to indicate that */
if (result == US_BULK_TRANSFER_ABORTED) if (result == USB_STOR_XFER_ABORTED)
return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
} }
...@@ -1257,7 +1258,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1257,7 +1258,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* did the attempt to read the CSW fail? */ /* did the attempt to read the CSW fail? */
...@@ -1268,7 +1269,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1268,7 +1269,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result < 0) if (result < 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -1281,7 +1282,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1281,7 +1282,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* if it fails again, we need a reset and return an error*/ /* if it fails again, we need a reset and return an error*/
...@@ -1292,7 +1293,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1292,7 +1293,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
} }
......
...@@ -115,12 +115,13 @@ struct bulk_cs_wrap { ...@@ -115,12 +115,13 @@ struct bulk_cs_wrap {
#define US_BULK_GET_MAX_LUN 0xfe #define US_BULK_GET_MAX_LUN 0xfe
/* /*
* usb_stor_transfer() return codes * usb_stor_transfer() return codes, in order of severity
*/ */
#define US_BULK_TRANSFER_GOOD 0 /* good transfer */ #define USB_STOR_XFER_GOOD 0 /* good transfer */
#define US_BULK_TRANSFER_SHORT 1 /* transfered less than expected */ #define USB_STOR_XFER_SHORT 1 /* transfered less than expected */
#define US_BULK_TRANSFER_FAILED 2 /* transfer died in the middle */ #define USB_STOR_XFER_STALLED 2 /* endpoint stalled */
#define US_BULK_TRANSFER_ABORTED 3 /* transfer canceled */ #define USB_STOR_XFER_ERROR 3 /* transfer died in the middle */
#define USB_STOR_XFER_ABORTED 4 /* transfer canceled */
/* /*
* Transport return codes * Transport return codes
......
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