# 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.579.9.4 -> 1.579.9.5 # drivers/usb/storage/shuttle_usbat.c 1.11 -> 1.12 # drivers/usb/storage/jumpshot.c 1.12 -> 1.13 # drivers/usb/storage/sddr55.c 1.3 -> 1.4 # drivers/usb/storage/transport.c 1.34 -> 1.35 # drivers/usb/storage/transport.h 1.9 -> 1.10 # drivers/usb/storage/raw_bulk.c 1.4 -> 1.5 # drivers/usb/storage/sddr09.c 1.17 -> 1.18 # drivers/usb/storage/datafab.c 1.11 -> 1.12 # drivers/usb/storage/freecom.c 1.14 -> 1.15 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/09/23 stern@rowland.org 1.579.9.5 # [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. # -------------------------------------------- # diff -Nru a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c --- a/drivers/usb/storage/datafab.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/datafab.c Mon Sep 23 15:15:58 2002 @@ -70,7 +70,7 @@ unsigned int act_len; /* ignored */ if (len == 0) - return USB_STOR_TRANSPORT_GOOD; + return USB_STOR_XFER_GOOD; US_DEBUGP("datafab_bulk_read: len = %d\n", len); return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len); @@ -82,7 +82,7 @@ unsigned int act_len; /* ignored */ if (len == 0) - return USB_STOR_TRANSPORT_GOOD; + return USB_STOR_XFER_GOOD; US_DEBUGP("datafab_bulk_write: len = %d\n", len); return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len); @@ -144,12 +144,12 @@ // send the read command result = datafab_bulk_write(us, command, sizeof(command)); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; // read the result result = datafab_bulk_read(us, ptr, len); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; sectors -= thistime; @@ -171,7 +171,7 @@ leave: if (use_sg) kfree(buffer); - return result; + return USB_STOR_TRANSPORT_ERROR; } @@ -243,17 +243,17 @@ // send the command result = datafab_bulk_write(us, command, sizeof(command)); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; // send the data result = datafab_bulk_write(us, ptr, len); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; // read the result result = datafab_bulk_read(us, reply, sizeof(reply)); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; if (reply[0] != 0x50 && reply[1] != 0) { @@ -280,7 +280,7 @@ leave: if (use_sg) kfree(buffer); - return result; + return USB_STOR_TRANSPORT_ERROR; } @@ -308,11 +308,11 @@ command[5] = 0xa0; rc = datafab_bulk_write(us, command, 8); - if (rc != USB_STOR_TRANSPORT_GOOD) - return rc; + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; rc = datafab_bulk_read(us, buf, sizeof(buf)); - if (rc == USB_STOR_TRANSPORT_GOOD) { + if (rc == USB_STOR_XFER_GOOD) { info->lun = 0; return USB_STOR_TRANSPORT_GOOD; } @@ -320,11 +320,11 @@ command[5] = 0xb0; rc = datafab_bulk_write(us, command, 8); - if (rc != USB_STOR_TRANSPORT_GOOD) - return rc; + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; rc = datafab_bulk_read(us, buf, sizeof(buf)); - if (rc == USB_STOR_TRANSPORT_GOOD) { + if (rc == USB_STOR_XFER_GOOD) { info->lun = 1; return USB_STOR_TRANSPORT_GOOD; } @@ -332,7 +332,7 @@ wait_ms(20); } - return USB_STOR_TRANSPORT_FAILED; + return USB_STOR_TRANSPORT_ERROR; } static int datafab_id_device(struct us_data *us, @@ -358,22 +358,23 @@ command[5] += (info->lun << 4); rc = datafab_bulk_write(us, command, 8); - if (rc != USB_STOR_TRANSPORT_GOOD) - return rc; + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; // we'll go ahead and extract the media capacity while we're here... // 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 // info->sectors = ((u32)(reply[117]) << 24) | ((u32)(reply[116]) << 16) | ((u32)(reply[115]) << 8) | ((u32)(reply[114]) ); + return USB_STOR_TRANSPORT_GOOD; } - return rc; + return USB_STOR_TRANSPORT_ERROR; } diff -Nru a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c --- a/drivers/usb/storage/freecom.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/freecom.c Mon Sep 23 15:15:58 2002 @@ -197,7 +197,7 @@ /* has the current command been aborted? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("freecom_readdata(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } return USB_STOR_TRANSPORT_ERROR; @@ -238,7 +238,7 @@ /* has the current command been aborted? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("freecom_writedata(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } return USB_STOR_TRANSPORT_ERROR; @@ -301,7 +301,7 @@ /* we canceled this transfer */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("freecom_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } return USB_STOR_TRANSPORT_ERROR; @@ -316,7 +316,7 @@ /* we canceled this transfer */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("freecom_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } US_DEBUG(pdump ((void *) fst, partial)); @@ -354,7 +354,7 @@ /* we canceled this transfer */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("freecom_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } return USB_STOR_TRANSPORT_ERROR; @@ -369,7 +369,7 @@ /* we canceled this transfer */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("freecom_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } US_DEBUG(pdump ((void *) fst, partial)); @@ -430,7 +430,7 @@ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP ("freecom_transport: transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } if (partial != 4 || result != 0) return USB_STOR_TRANSPORT_ERROR; @@ -459,7 +459,7 @@ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP ("freecom_transport: transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } if (partial != 4 || result != 0) return USB_STOR_TRANSPORT_ERROR; diff -Nru a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c --- a/drivers/usb/storage/jumpshot.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/jumpshot.c Mon Sep 23 15:15:58 2002 @@ -65,7 +65,7 @@ unsigned int act_len; /* ignored */ if (len == 0) - return USB_STOR_TRANSPORT_GOOD; + return USB_STOR_XFER_GOOD; US_DEBUGP("jumpshot_bulk_read: len = %d\n", len); return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len); @@ -79,7 +79,7 @@ unsigned int act_len; /* ignored */ if (len == 0) - return USB_STOR_TRANSPORT_GOOD; + return USB_STOR_XFER_GOOD; US_DEBUGP("jumpshot_bulk_write: len = %d\n", len); return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len); @@ -168,7 +168,7 @@ // read the result result = jumpshot_bulk_read(us, ptr, len); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; US_DEBUGP("jumpshot_read_data: %d bytes\n", len); @@ -192,7 +192,7 @@ leave: if (use_sg) kfree(buffer); - return result; + return USB_STOR_TRANSPORT_ERROR; } @@ -253,7 +253,7 @@ // send the data result = jumpshot_bulk_write(us, ptr, len); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result != USB_STOR_XFER_GOOD) goto leave; // read the result. apparently the bulk write can complete @@ -288,7 +288,7 @@ leave: if (use_sg) kfree(buffer); - return result; + return USB_STOR_TRANSPORT_ERROR; } static int jumpshot_id_device(struct us_data *us, @@ -314,8 +314,8 @@ // read the reply rc = jumpshot_bulk_read(us, reply, sizeof(reply)); - if (rc != USB_STOR_TRANSPORT_GOOD) - return rc; + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; info->sectors = ((u32)(reply[117]) << 24) | ((u32)(reply[116]) << 16) | diff -Nru a/drivers/usb/storage/raw_bulk.c b/drivers/usb/storage/raw_bulk.c --- a/drivers/usb/storage/raw_bulk.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/raw_bulk.c Mon Sep 23 15:15:58 2002 @@ -61,7 +61,7 @@ /* 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; + return USB_STOR_TRANSPORT_ABORTED; } // Check the return code for the command. @@ -70,7 +70,7 @@ /* a stall indicates a protocol error */ if (result == -EPIPE) { US_DEBUGP("-- Stall on control pipe\n"); - return USB_STOR_TRANSPORT_FAILED; + return USB_STOR_TRANSPORT_ERROR; } /* Uh oh... serious problem here */ @@ -100,14 +100,14 @@ " pipe 0x%x, stalled at %d bytes\n", pipe, *act_len); if (usb_stor_clear_halt(us, pipe) < 0) - return US_BULK_TRANSFER_FAILED; - /* return US_BULK_TRANSFER_SHORT; */ + return USB_STOR_XFER_ERROR; + return USB_STOR_XFER_STALLED; } /* 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; + return USB_STOR_XFER_ABORTED; } if (result) { @@ -122,13 +122,13 @@ US_DEBUGP("raw_bulk(): unknown error %d\n", result); - return US_BULK_TRANSFER_FAILED; + return USB_STOR_XFER_ERROR; } if (*act_len != len) { US_DEBUGP("Warning: Transferred only %d of %d bytes\n", *act_len, len); - return US_BULK_TRANSFER_SHORT; + return USB_STOR_XFER_SHORT; } #if 0 @@ -137,7 +137,7 @@ *act_len, len); #endif - return US_BULK_TRANSFER_GOOD; + return USB_STOR_XFER_GOOD; } int @@ -145,14 +145,14 @@ unsigned char *data, unsigned int len, int use_sg) { - int result = USB_STOR_TRANSPORT_GOOD; + int result = USB_STOR_XFER_ERROR; int transferred = 0; int i; struct scatterlist *sg; unsigned int act_len; if (len == 0) - return USB_STOR_TRANSPORT_GOOD; + return USB_STOR_XFER_GOOD; #if DEBUG_PRCT @@ -196,7 +196,7 @@ result = usb_storage_raw_bulk(us, direction, buf, length, &act_len); - if (result != US_BULK_TRANSFER_GOOD) + if (result != USB_STOR_XFER_GOOD) break; transferred += length; } diff -Nru a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c --- a/drivers/usb/storage/sddr09.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/sddr09.c Mon Sep 23 15:15:58 2002 @@ -285,12 +285,14 @@ } 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"); - else + return USB_STOR_TRANSPORT_ERROR; + } + else { US_DEBUGP("request sense worked\n"); - - return result; + return USB_STOR_TRANSPORT_GOOD; + } } /* @@ -344,11 +346,12 @@ result = usb_storage_bulk_transport(us, SCSI_DATA_READ, 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", x, result); - - return result; + return USB_STOR_TRANSPORT_ERROR; + } + return USB_STOR_TRANSPORT_GOOD; } /* @@ -510,11 +513,12 @@ result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, 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", result); - - return result; + return USB_STOR_TRANSPORT_ERROR; + } + return USB_STOR_TRANSPORT_GOOD; } /* erase address, write same address */ @@ -590,13 +594,14 @@ result = usb_storage_bulk_transport(us, SCSI_DATA_READ, 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", result); + return USB_STOR_TRANSPORT_ERROR; + } - kfree(buf); - - return result; + return USB_STOR_TRANSPORT_GOOD; } #endif @@ -629,7 +634,8 @@ result = usb_storage_bulk_transport(us, SCSI_DATA_READ, data, sizeof(data), 0); *status = data[0]; - return result; + return (result == USB_STOR_XFER_GOOD ? + USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); } static int @@ -953,7 +959,8 @@ for (i = 0; i < 4; i++) deviceID[i] = content[i]; - return result; + return (result == USB_STOR_XFER_GOOD ? + USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); } static int @@ -1549,7 +1556,8 @@ srb->request_bufflen, srb->use_sg); - return result; + return (result == USB_STOR_XFER_GOOD ? + USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); } return USB_STOR_TRANSPORT_GOOD; diff -Nru a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c --- a/drivers/usb/storage/sddr55.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/sddr55.c Mon Sep 23 15:15:58 2002 @@ -101,16 +101,16 @@ US_DEBUGP("Result for send_command in status %d\n", result); - if (result != US_BULK_TRANSFER_GOOD) { + if (result != USB_STOR_XFER_GOOD) { set_sense_info (4, 0, 0); /* hardware error */ - return result; + return USB_STOR_TRANSPORT_ERROR; } result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 4); /* 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 */ if (info->lba_to_pba) kfree(info->lba_to_pba); @@ -123,12 +123,12 @@ info->force_read_only = 0; 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 */ - return result; + return USB_STOR_TRANSPORT_FAILED; } /* check write protect status */ @@ -138,11 +138,12 @@ result = sddr55_bulk_transport(us, 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 */ } - return result; + return (result == USB_STOR_XFER_GOOD ? + USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_FAILED); } @@ -214,23 +215,29 @@ US_DEBUGP("Result for send_command in read_data %d\n", result); - if (result != US_BULK_TRANSFER_GOOD) + if (result != USB_STOR_XFER_GOOD) { + result = USB_STOR_TRANSPORT_ERROR; goto leave; + } /* read data */ result = sddr55_bulk_transport(us, SCSI_DATA_READ, ptr, pages<pageshift); - if (result != US_BULK_TRANSFER_GOOD) + if (result != USB_STOR_XFER_GOOD) { + result = USB_STOR_TRANSPORT_ERROR; goto leave; + } /* now read status */ result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 2); - if (result != US_BULK_TRANSFER_GOOD) + if (result != USB_STOR_XFER_GOOD) { + result = USB_STOR_TRANSPORT_ERROR; goto leave; + } /* check status for error */ if (status[0] == 0xff && status[1] == 0x4) { @@ -247,6 +254,7 @@ } us_copy_to_sgbuf_all(buffer, len, content, use_sg); + result = USB_STOR_TRANSPORT_GOOD; leave: if (use_sg) @@ -374,12 +382,13 @@ result = sddr55_bulk_transport(us, 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", result); /* set_sense_info is superfluous here? */ set_sense_info (3, 0x3, 0);/* peripheral write error */ + result = USB_STOR_TRANSPORT_FAILED; goto leave; } @@ -388,24 +397,26 @@ SCSI_DATA_WRITE, ptr, pages<pageshift); - if (result != US_BULK_TRANSFER_GOOD) { + if (result != USB_STOR_XFER_GOOD) { US_DEBUGP("Result for send_data in write_data %d\n", result); /* set_sense_info is superfluous here? */ set_sense_info (3, 0x3, 0);/* peripheral write error */ + result = USB_STOR_TRANSPORT_FAILED; goto leave; } /* now read status */ 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", result); /* set_sense_info is superfluous here? */ set_sense_info (3, 0x3, 0);/* peripheral write error */ + result = USB_STOR_TRANSPORT_FAILED; goto leave; } @@ -446,6 +457,7 @@ sectors -= pages >> info->smallpageshift; ptr += (pages << info->pageshift); } + result = USB_STOR_TRANSPORT_GOOD; leave: if (use_sg) @@ -468,14 +480,14 @@ US_DEBUGP("Result of send_control for device ID is %d\n", result); - if (result != US_BULK_TRANSFER_GOOD) - return result; + if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; result = sddr55_bulk_transport(us, SCSI_DATA_READ, content, 4); - if (result != US_BULK_TRANSFER_GOOD) - return result; + if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; *manufacturerID = content[0]; *deviceID = content[1]; @@ -485,7 +497,7 @@ SCSI_DATA_READ, content, 2); } - return result; + return USB_STOR_TRANSPORT_GOOD; } @@ -510,7 +522,7 @@ US_DEBUGP("Result of read_deviceID is %d\n", result); - if (result != US_BULK_TRANSFER_GOOD) + if (result != USB_STOR_XFER_GOOD) return 0; US_DEBUGP("Device ID = %02X\n", deviceID); @@ -603,21 +615,21 @@ result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8); - if ( result != US_BULK_TRANSFER_GOOD) { + if ( result != USB_STOR_XFER_GOOD) { kfree (buffer); return -1; } 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); return -1; } result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2); - if ( result != US_BULK_TRANSFER_GOOD) { + if ( result != USB_STOR_XFER_GOOD) { kfree (buffer); return -1; } diff -Nru a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c --- a/drivers/usb/storage/shuttle_usbat.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/shuttle_usbat.c Mon Sep 23 15:15:58 2002 @@ -153,7 +153,8 @@ 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 @@ result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg); - if (result != USB_STOR_TRANSPORT_GOOD) - return result; + if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; return usbat_wait_not_busy(us, minutes); } @@ -309,8 +310,8 @@ SCSI_DATA_WRITE, data, num_registers*2, 0); - if (result!=USB_STOR_TRANSPORT_GOOD) - return result; + if (result!=USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; } @@ -341,7 +342,8 @@ * 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 @@ -373,8 +375,8 @@ US_DEBUGP("Redoing %s\n", direction==SCSI_DATA_WRITE ? "write" : "read"); - } else if (result != US_BULK_TRANSFER_GOOD) - return result; + } else if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; else return usbat_wait_not_busy(us, minutes); @@ -425,8 +427,8 @@ result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, data, num_registers*2, 0); - if (result != USB_STOR_TRANSPORT_GOOD) - return result; + if (result != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; return usbat_wait_not_busy(us, 0); } diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/transport.c Mon Sep 23 15:15:58 2002 @@ -572,36 +572,37 @@ if (result == -EPIPE) { US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); 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? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("usb_stor_transfer_partial(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; - } - - /* did we send all the data? */ - if (partial == length) { - US_DEBUGP("usb_stor_transfer_partial(): transfer complete\n"); - return US_BULK_TRANSFER_GOOD; + return USB_STOR_XFER_ABORTED; } /* NAK - that means we've retried a few times already */ if (result == -ETIMEDOUT) { US_DEBUGP("usb_stor_transfer_partial(): device NAKed\n"); - return US_BULK_TRANSFER_FAILED; + return USB_STOR_XFER_ERROR; } /* the catch-all error case */ if (result) { 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, * just not all of it */ - return US_BULK_TRANSFER_SHORT; + return USB_STOR_XFER_SHORT; } /* @@ -739,7 +740,7 @@ * Also, if we have a short transfer on a command that can't have * 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] == INQUIRY) || (srb->cmnd[0] == MODE_SENSE) || @@ -995,13 +996,13 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { 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 */ if (result == -EPIPE) { US_DEBUGP("-- Stall on control pipe\n"); - return USB_STOR_TRANSPORT_FAILED; + return USB_STOR_TRANSPORT_ERROR; } if (result < 0) { @@ -1017,13 +1018,13 @@ US_DEBUGP("CBI data stage result is 0x%x\n", result); /* report any errors */ - if (result == US_BULK_TRANSFER_ABORTED) { + if (result == USB_STOR_XFER_ABORTED) { clear_bit(US_FLIDX_IP_WANTED, &us->flags); 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); - return USB_STOR_TRANSPORT_FAILED; + return USB_STOR_TRANSPORT_ERROR; } } @@ -1103,13 +1104,13 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { 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 */ if (result == -EPIPE) { US_DEBUGP("-- Stall on control pipe\n"); - return USB_STOR_TRANSPORT_FAILED; + return USB_STOR_TRANSPORT_ERROR; } /* Uh oh... serious problem here */ @@ -1124,11 +1125,11 @@ US_DEBUGP("CB data stage result is 0x%x\n", result); /* report any errors */ - if (result == US_BULK_TRANSFER_ABORTED) { + if (result == USB_STOR_XFER_ABORTED) { return USB_STOR_TRANSPORT_ABORTED; } - if (result == US_BULK_TRANSFER_FAILED) { - return USB_STOR_TRANSPORT_FAILED; + if (result == USB_STOR_XFER_ERROR) { + return USB_STOR_TRANSPORT_ERROR; } } @@ -1207,7 +1208,7 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { 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 */ @@ -1218,7 +1219,7 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } if (result < 0) return USB_STOR_TRANSPORT_ERROR; @@ -1237,7 +1238,7 @@ US_DEBUGP("Bulk data transfer result 0x%x\n", result); /* 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; } } @@ -1257,7 +1258,7 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { 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? */ @@ -1268,7 +1269,7 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } if (result < 0) return USB_STOR_TRANSPORT_ERROR; @@ -1281,7 +1282,7 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { 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*/ @@ -1292,7 +1293,7 @@ /* did we abort this command? */ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); - return US_BULK_TRANSFER_ABORTED; + return USB_STOR_TRANSPORT_ABORTED; } return USB_STOR_TRANSPORT_ERROR; } diff -Nru a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h --- a/drivers/usb/storage/transport.h Mon Sep 23 15:15:58 2002 +++ b/drivers/usb/storage/transport.h Mon Sep 23 15:15:58 2002 @@ -115,12 +115,13 @@ #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 US_BULK_TRANSFER_SHORT 1 /* transfered less than expected */ -#define US_BULK_TRANSFER_FAILED 2 /* transfer died in the middle */ -#define US_BULK_TRANSFER_ABORTED 3 /* transfer canceled */ +#define USB_STOR_XFER_GOOD 0 /* good transfer */ +#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