ChangeSet 1.738.5.26, 2002/10/13 13:48:37-07:00, [EMAIL PROTECTED]

[PATCH] usb-storage: convert to common transfer functions

This patch makes all sub-drivers use the same data-moving functions.  It
also eliminates the duplicate functions from raw_bulk.c


diff -Nru a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
--- a/drivers/usb/storage/datafab.c     Sun Oct 13 17:08:37 2002
+++ b/drivers/usb/storage/datafab.c     Sun Oct 13 17:08:37 2002
@@ -67,25 +67,23 @@
 
 static inline int
 datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
-       unsigned int act_len;   /* ignored */
-
        if (len == 0)
                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);
+       return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+                       data, len, NULL);
 }
 
 
 static inline int
 datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) {
-       unsigned int act_len;   /* ignored */
-
        if (len == 0)
                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);
+       return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
+                       data, len, NULL);
 }
 
 
diff -Nru a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
--- a/drivers/usb/storage/jumpshot.c    Sun Oct 13 17:08:36 2002
+++ b/drivers/usb/storage/jumpshot.c    Sun Oct 13 17:08:36 2002
@@ -62,13 +62,12 @@
                                     unsigned char *data, 
                                     unsigned int len)
 {
-       unsigned int act_len;   /* ignored */
-
        if (len == 0)
                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);
+       return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+                       data, len, NULL);
 }
 
 
@@ -76,13 +75,12 @@
                                      unsigned char *data, 
                                      unsigned int len)
 {
-       unsigned int act_len;   /* ignored */
-
        if (len == 0)
                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);
+       return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
+                       data, len, NULL);
 }
 
 
@@ -95,11 +93,11 @@
                return USB_STOR_TRANSPORT_ERROR;
 
        // send the setup
-       rc = usb_storage_send_control(us, us->recv_ctrl_pipe,
+       rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
                                   0, 0xA0, 0, 7, &reply, 1);
 
-       if (rc != USB_STOR_TRANSPORT_GOOD)
-               return rc;
+       if (rc != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        if (reply != 0x50) {
                US_DEBUGP("jumpshot_get_status:  0x%2x\n",
@@ -159,9 +157,9 @@
                command[5] |= (sector >> 24) & 0x0F;
 
                // send the setup + command
-               result = usb_storage_send_control(us, us->send_ctrl_pipe,
+               result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
                                               0, 0x20, 0, 1, command, 7);
-               if (result != USB_STOR_TRANSPORT_GOOD)
+               if (result != USB_STOR_XFER_GOOD)
                        goto leave;
 
                // read the result
@@ -245,8 +243,10 @@
                command[5] |= (sector >> 24) & 0x0F;
 
                // send the setup + command
-               result = usb_storage_send_control(us, us->send_ctrl_pipe,
+               result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
                        0, 0x20, 0, 1, command, 7);
+               if (result != USB_STOR_XFER_GOOD)
+                       goto leave;
 
                // send the data
                result = jumpshot_bulk_write(us, ptr, len);
@@ -299,10 +299,10 @@
                return USB_STOR_TRANSPORT_ERROR;
 
        // send the setup
-       rc = usb_storage_send_control(us, us->send_ctrl_pipe,
+       rc = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
                                   0, 0x20, 0, 6, command, 2);
 
-       if (rc != USB_STOR_TRANSPORT_GOOD) {
+       if (rc != USB_STOR_XFER_GOOD) {
                US_DEBUGP("jumpshot_id_device:  Gah! "
                          "send_control for read_capacity failed\n");
                return rc;
diff -Nru a/drivers/usb/storage/raw_bulk.c b/drivers/usb/storage/raw_bulk.c
--- a/drivers/usb/storage/raw_bulk.c    Sun Oct 13 17:08:36 2002
+++ b/drivers/usb/storage/raw_bulk.c    Sun Oct 13 17:08:36 2002
@@ -13,219 +13,6 @@
 #include "transport.h"
 #include "raw_bulk.h"
 
-#ifdef CONFIG_USB_STORAGE_DEBUG
-#define DEBUG_PRCT 12
-#else
-#define DEBUG_PRCT 0
-#endif
-
-/*
- * Send a control message and wait for the response.
- *
- * us - the pointer to the us_data structure for the device to use
- *
- * request - the URB Setup Packet's first 6 bytes. The first byte always
- *  corresponds to the request type, and the second byte always corresponds
- *  to the request.  The other 4 bytes do not correspond to value and index,
- *  since they are used in a custom way by the SCM protocol.
- *
- * xfer_data - a buffer from which to get, or to which to store, any data
- *  that gets send or received, respectively, with the URB. Even though
- *  it looks like we allocate a buffer in this code for the data, xfer_data
- *  must contain enough allocated space.
- *
- * xfer_len - the number of bytes to send or receive with the URB.
- *
- */
-
-int
-usb_storage_send_control(struct us_data *us,
-                        unsigned int pipe,
-                        unsigned char request,
-                        unsigned char requesttype,
-                        unsigned int value,
-                        unsigned int index,
-                        unsigned char *xfer_data,
-                        unsigned int xfer_len) {
-
-       int result;
-
-       // Send the URB to the device and wait for a response.
-
-       /* Why are request and request type reversed in this call? */
-
-       result = usb_stor_control_msg(us, pipe,
-                       request, requesttype, value, index,
-                       xfer_data, xfer_len);
-
-       /* did we abort this command? */
-       if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
-               US_DEBUGP("usb_stor_send_control(): transfer aborted\n");
-               return USB_STOR_TRANSPORT_ABORTED;
-       }
-
-       // Check the return code for the command.
-       if (result < 0) {
-
-               /* a stall indicates a protocol error */
-               if (result == -EPIPE) {
-                       US_DEBUGP("-- Stall on control pipe\n");
-                       return USB_STOR_TRANSPORT_ERROR;
-               }
-
-               /* Uh oh... serious problem here */
-               return USB_STOR_TRANSPORT_ERROR;
-       }
-
-       return USB_STOR_TRANSPORT_GOOD;
-}
-
-int
-usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
-                    unsigned int len, unsigned int *act_len) {
-
-       int result;
-       unsigned int pipe;
-
-       if (direction == SCSI_DATA_READ)
-               pipe = us->recv_bulk_pipe;
-       else
-               pipe = us->send_bulk_pipe;
-
-       result = usb_stor_bulk_msg(us, data, pipe, len, act_len);
-
-       /* if we stall, we need to clear it before we go on */
-       if (result == -EPIPE) {
-               US_DEBUGP("EPIPE: clearing endpoint halt for"
-                         " pipe 0x%x, stalled at %d bytes\n",
-                         pipe, *act_len);
-               if (usb_stor_clear_halt(us, pipe) < 0)
-                       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 USB_STOR_XFER_ABORTED;
-       }
-
-       if (result) {
-               /* NAK - that means we've retried a few times already */
-                       if (result == -ETIMEDOUT)
-                       US_DEBUGP("raw_bulk(): device NAKed\n");
-               else if (result == -EOVERFLOW)
-                       US_DEBUGP("raw_bulk(): babble/overflow\n");
-               else if (result == -ECONNRESET)
-                       US_DEBUGP("raw_bulk(): asynchronous reset\n");
-               else if (result != -EPIPE)
-                       US_DEBUGP("raw_bulk(): unknown error %d\n",
-                                 result);
-
-               return USB_STOR_XFER_ERROR;
-       }
-
-       if (*act_len != len) {
-               US_DEBUGP("Warning: Transferred only %d of %d bytes\n",
-                         *act_len, len);
-               return USB_STOR_XFER_SHORT;
-       }
-
-#if 0
-       US_DEBUGP("raw_bulk(): Transferred %s %d of %d bytes\n",
-                 (direction == SCSI_DATA_READ) ? "in" : "out",
-                 *act_len, len);
-#endif
-
-       return USB_STOR_XFER_GOOD;
-}
-
-int
-usb_storage_bulk_transport(struct us_data *us, int direction,
-                          unsigned char *data, unsigned int len,
-                          int use_sg) {
-
-       int result = USB_STOR_XFER_ERROR;
-       int transferred = 0;
-       int i;
-       struct scatterlist *sg;
-       unsigned int act_len;
-
-       if (len == 0)
-               return USB_STOR_XFER_GOOD;
-
-#if DEBUG_PRCT
-
-       if (direction == SCSI_DATA_WRITE && !use_sg) {
-               char string[64];
-
-               /* Debug-print the first N bytes of the write transfer */
-
-               strcpy(string, "wr: ");
-               for (i=0; i<len && i<DEBUG_PRCT; i++) {
-                       sprintf(string+strlen(string), "%02X ", data[i]);
-                       if ((i%16) == 15) {
-                               US_DEBUGP("%s\n", string);
-                               strcpy(string, "wr: ");
-                       }
-               }
-               if ((i%16)!=0)
-                       US_DEBUGP("%s\n", string);
-       }
-
-       US_DEBUGP("SCM data %s transfer %d sg buffers %d\n",
-                 (direction == SCSI_DATA_READ) ? "in" : "out",
-                 len, use_sg);
-
-#endif /* DEBUG_PRCT */
-
-       if (!use_sg)
-               result = usb_storage_raw_bulk(us, direction,
-                                             data, len, &act_len);
-       else {
-               sg = (struct scatterlist *)data;
-
-               for (i=0; i<use_sg && transferred<len; i++) {
-                       unsigned char *buf;
-                       unsigned int length;
-
-                       buf = sg_address(sg[i]);
-                       length = len-transferred;
-                       if (length > sg[i].length)
-                               length = sg[i].length;
-
-                       result = usb_storage_raw_bulk(us, direction,
-                                                     buf, length, &act_len);
-                       if (result != USB_STOR_XFER_GOOD)
-                               break;
-                       transferred += length;
-               }
-       }
-
-#if DEBUG_PRCT
-
-       if (direction == SCSI_DATA_READ && !use_sg) {
-               char string[64];
-
-               /* Debug-print the first N bytes of the read transfer */
-
-               strcpy(string, "rd: ");
-               for (i=0; i<len && i<act_len && i<DEBUG_PRCT; i++) {
-                       sprintf(string+strlen(string), "%02X ", data[i]);
-                       if ((i%16) == 15) {
-                               US_DEBUGP("%s\n", string);
-                               strcpy(string, "rd: ");
-                       }
-               }
-               if ((i%16)!=0)
-                       US_DEBUGP("%s\n", string);
-       }
-
-#endif /* DEBUG_PRCT */
-
-       return result;
-}
-
 /*
  * The routines below convert scatter-gather to single buffer.
  * Some drivers claim this is necessary.
diff -Nru a/drivers/usb/storage/raw_bulk.h b/drivers/usb/storage/raw_bulk.h
--- a/drivers/usb/storage/raw_bulk.h    Sun Oct 13 17:08:36 2002
+++ b/drivers/usb/storage/raw_bulk.h    Sun Oct 13 17:08:36 2002
@@ -1,21 +1,6 @@
 #ifndef _USB_STORAGE_RAW_BULK_H_
 #define _USB_STORAGE_RAW_BULK_H_
 
-/* usb bulk */
-extern int usb_storage_send_control(
-       struct us_data *us, unsigned int pipe,
-       unsigned char request, unsigned char requesttype,
-       unsigned int value, unsigned int index,
-       unsigned char *xfer_data, unsigned int xfer_len);
-
-extern int usb_storage_raw_bulk(
-       struct us_data *us, int direction,
-       unsigned char *data, unsigned int len, unsigned int *act_len);
-
-extern int usb_storage_bulk_transport(
-       struct us_data *us, int direction,
-       unsigned char *data, unsigned int len, int use_sg);
-
 /* scatter-gather */
 extern unsigned char *us_copy_from_sgbuf(
        unsigned char *content, int buflen,
diff -Nru a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
--- a/drivers/usb/storage/sddr09.c      Sun Oct 13 17:08:37 2002
+++ b/drivers/usb/storage/sddr09.c      Sun Oct 13 17:08:37 2002
@@ -226,6 +226,7 @@
                    unsigned int xfer_len) {
        unsigned int pipe;
        unsigned char requesttype = (0x41 | direction);
+       int rc;
 
        // Get the receive or send control pipe number
 
@@ -234,8 +235,10 @@
        else
                pipe = us->send_ctrl_pipe;
 
-       return usb_storage_send_control(us, pipe, request, requesttype,
+       rc = usb_stor_ctrl_transfer(us, pipe, request, requesttype,
                                   0, 0, xfer_data, xfer_len);
+       return (rc == USB_STOR_XFER_GOOD ? USB_STOR_TRANSPORT_GOOD :
+                       USB_STOR_TRANSPORT_ERROR);
 }
 
 static int
@@ -276,7 +279,6 @@
                0x03, LUNBITS, 0, 0, buflen, 0, 0, 0, 0, 0, 0, 0
        };
        int result;
-       unsigned int act_len;
 
        result = sddr09_send_scsi_command(us, command, sizeof(command));
        if (result != USB_STOR_TRANSPORT_GOOD) {
@@ -284,7 +286,8 @@
                return result;
        }
 
-       result = usb_storage_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen, &act_len);
+       result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+                       sensebuf, buflen, NULL);
        if (result != USB_STOR_XFER_GOOD) {
                US_DEBUGP("request sense bulk in failed\n");
                return USB_STOR_TRANSPORT_ERROR;
@@ -343,11 +346,11 @@
                return result;
        }
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
-                                      buf, bulklen, use_sg);
+       result = usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe,
+                                      buf, bulklen, use_sg, NULL);
 
        if (result != USB_STOR_XFER_GOOD) {
-               US_DEBUGP("Result for bulk_transport in sddr09_read2%d %d\n",
+               US_DEBUGP("Result for bulk_transfer in sddr09_read2%d %d\n",
                          x, result);
                return USB_STOR_TRANSPORT_ERROR;
        }
@@ -510,11 +513,11 @@
                return result;
        }
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE,
-                                      buf, bulklen, use_sg);
+       result = usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe,
+                                      buf, bulklen, use_sg, NULL);
 
        if (result != USB_STOR_XFER_GOOD) {
-               US_DEBUGP("Result for bulk_transport in sddr09_writeX %d\n",
+               US_DEBUGP("Result for bulk_transfer in sddr09_writeX %d\n",
                          result);
                return USB_STOR_TRANSPORT_ERROR;
        }
@@ -592,11 +595,11 @@
        if (!buf)
                return USB_STOR_TRANSPORT_ERROR;
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
-                                      buf, bulklen, 0);
+       result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+                                      buf, bulklen, NULL);
        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_transfer in sddr09_read_sg %d\n",
                          result);
                return USB_STOR_TRANSPORT_ERROR;
        }
@@ -631,8 +634,8 @@
        if (result != USB_STOR_TRANSPORT_GOOD)
                return result;
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
-                                      data, sizeof(data), 0);
+       result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+                                      data, sizeof(data), NULL);
        *status = data[0];
        return (result == USB_STOR_XFER_GOOD ?
                        USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
@@ -954,7 +957,8 @@
        if (result != USB_STOR_TRANSPORT_GOOD)
                return result;
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, 64, 0);
+       result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
+                       content, 64, NULL);
 
        for (i = 0; i < 4; i++)
                deviceID[i] = content[i];
@@ -1545,17 +1549,16 @@
 
        if (srb->sc_data_direction == SCSI_DATA_WRITE ||
            srb->sc_data_direction == SCSI_DATA_READ) {
+               unsigned int pipe = (srb->sc_data_direction == SCSI_DATA_WRITE)
+                               ? us->send_bulk_pipe : us->recv_bulk_pipe;
 
                US_DEBUGP("SDDR09: %s %d bytes\n",
                          (srb->sc_data_direction == SCSI_DATA_WRITE) ?
                          "sending" : "receiving",
                          srb->request_bufflen);
 
-               result = usb_storage_bulk_transport(us,
-                                              srb->sc_data_direction,
-                                              srb->request_buffer, 
-                                              srb->request_bufflen,
-                                              srb->use_sg);
+               result = usb_stor_bulk_transfer_srb(us, pipe, srb,
+                                                       srb->request_bufflen);
 
                return (result == USB_STOR_XFER_GOOD ?
                        USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
diff -Nru a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c
--- a/drivers/usb/storage/sddr55.c      Sun Oct 13 17:08:36 2002
+++ b/drivers/usb/storage/sddr55.c      Sun Oct 13 17:08:36 2002
@@ -75,10 +75,13 @@
 sddr55_bulk_transport(struct us_data *us, int direction,
                      unsigned char *data, unsigned int len) {
        struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra;
+       unsigned int pipe = (direction == SCSI_DATA_READ) ?
+                       us->recv_bulk_pipe : us->send_bulk_pipe;
 
-       if (len)
-               info->last_access = jiffies;
-       return usb_storage_bulk_transport(us, direction, data, len, 0);
+       if (!len)
+               return USB_STOR_XFER_GOOD;
+       info->last_access = jiffies;
+       return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL);
 }
 
 /* check if card inserted, if there is, update read_only status
diff -Nru a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
--- a/drivers/usb/storage/shuttle_usbat.c       Sun Oct 13 17:08:36 2002
+++ b/drivers/usb/storage/shuttle_usbat.c       Sun Oct 13 17:08:36 2002
@@ -63,7 +63,7 @@
 
        int result;
 
-       result = usb_storage_send_control(us,
+       result = usb_stor_ctrl_transfer(us,
                us->recv_ctrl_pipe,
                access,
                0xC0,
@@ -82,7 +82,7 @@
 
        int result;
 
-       result = usb_storage_send_control(us,
+       result = usb_stor_ctrl_transfer(us,
                us->send_ctrl_pipe,
                access|0x01,
                0x40,
@@ -108,7 +108,7 @@
                test_pattern, mask_byte, subcountL, subcountH
        };
 
-       result = usb_storage_send_control(us,
+       result = usb_stor_ctrl_transfer(us,
                us->send_ctrl_pipe,
                0x80,
                0x40,
@@ -133,7 +133,10 @@
                LSB_of(len), MSB_of(len)
        };
 
-       result = usb_storage_send_control(us,
+       if (!len)
+               return USB_STOR_TRANSPORT_GOOD;
+
+       result = usb_stor_ctrl_transfer(us,
                us->send_ctrl_pipe,
                0x80,
                0x40,
@@ -142,10 +145,11 @@
                command,
                8);
 
-       if (result != USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (result != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, len, use_sg);
+       result = usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe,
+                       content, len, use_sg, NULL);
 
        return (result == USB_STOR_XFER_GOOD ?
                        USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
@@ -172,8 +176,8 @@
 
                result = usbat_read(us, USBAT_ATA, 0x17, &status);
 
-               if (result!=USB_STOR_TRANSPORT_GOOD)
-                       return result;
+               if (result!=USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
                if (status&0x01) { // check condition
                        result = usbat_read(us, USBAT_ATA, 0x10, &status);
                        return USB_STOR_TRANSPORT_FAILED;
@@ -215,7 +219,10 @@
                LSB_of(len), MSB_of(len)
        };
 
-       result = usb_storage_send_control(us,
+       if (!len)
+               return USB_STOR_TRANSPORT_GOOD;
+
+       result = usb_stor_ctrl_transfer(us,
                us->send_ctrl_pipe,
                0x80,
                0x40,
@@ -224,10 +231,11 @@
                command,
                8);
 
-       if (result != USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (result != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
-       result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg);
+       result = usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe,
+                       content, len, use_sg, NULL);
 
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -251,6 +259,8 @@
             int minutes) {
 
        int result;
+       unsigned int pipe = (direction == SCSI_DATA_READ) ?
+                       us->recv_bulk_pipe : us->send_bulk_pipe;
 
        // Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here,
        // but that's what came out of the trace every single time.
@@ -286,7 +296,7 @@
                 * that, we just return a failure.
                 */
 
-               result = usb_storage_send_control(us,
+               result = usb_stor_ctrl_transfer(us,
                        us->send_ctrl_pipe,
                        0x80,
                        0x40,
@@ -295,16 +305,16 @@
                        (i==0 ? command : command+8),
                        (i==0 ? 16 : 8));
 
-               if (result != USB_STOR_TRANSPORT_GOOD)
-                       return result;
+               if (result != USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
 
                if (i==0) {
 
-                       result = usb_storage_bulk_transport(us,
-                               SCSI_DATA_WRITE, 
-                               data, num_registers*2, 0);
+                       result = usb_stor_bulk_transfer_buf(us,
+                                       us->send_bulk_pipe,
+                                       data, num_registers*2, NULL);
 
-                       if (result!=USB_STOR_XFER_GOOD)
+                       if (result != USB_STOR_XFER_GOOD)
                                return USB_STOR_TRANSPORT_ERROR;
 
                }
@@ -314,8 +324,8 @@
                //      direction == SCSI_DATA_WRITE ? "out" : "in",
                //      len, use_sg);
 
-               result = usb_storage_bulk_transport(us,
-                       direction, content, len, use_sg);
+               result = usb_stor_bulk_transfer_sg(us,
+                       pipe, content, len, use_sg, NULL);
 
                /*
                 * If we get a stall on the bulk download, we'll retry
@@ -358,8 +368,8 @@
                                direction==SCSI_DATA_WRITE ? 0x17 : 0x0E, 
                                &status);
 
-                       if (result!=USB_STOR_TRANSPORT_GOOD)
-                               return result;
+                       if (result!=USB_STOR_XFER_GOOD)
+                               return USB_STOR_TRANSPORT_ERROR;
                        if (status&0x01) // check condition
                                return USB_STOR_TRANSPORT_FAILED;
                        if (status&0x20) // device fault
@@ -405,7 +415,7 @@
                data[1+(i<<1)] = data_out[i];
        }
 
-       result = usb_storage_send_control(us,
+       result = usb_stor_ctrl_transfer(us,
                us->send_ctrl_pipe,
                0x80,
                0x40,
@@ -414,11 +424,11 @@
                command,
                8);
 
-       if (result != USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (result != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
-       result = usb_storage_bulk_transport(us,
-               SCSI_DATA_WRITE, data, num_registers*2, 0);
+       result = usb_stor_bulk_transfer_buf(us,
+               us->send_bulk_pipe, data, num_registers*2, NULL);
 
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -431,7 +441,7 @@
 
        int result;
 
-       result = usb_storage_send_control(us,
+       result = usb_stor_ctrl_transfer(us,
                us->recv_ctrl_pipe,
                0x82,
                0xC0,
@@ -449,7 +459,7 @@
 
        int result;
 
-       result = usb_storage_send_control(us,
+       result = usb_stor_ctrl_transfer(us,
                us->send_ctrl_pipe,
                0x82,
                0x40,
@@ -582,7 +592,6 @@
 
 static int hp_8200e_select_and_test_registers(struct us_data *us) {
 
-       int result;
        int selector;
        unsigned char status;
 
@@ -590,44 +599,44 @@
 
        for (selector = 0xA0; selector <= 0xB0; selector += 0x10) {
 
-               if ( (result = usbat_write(us, USBAT_ATA, 0x16, selector)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_read(us, USBAT_ATA, 0x17, &status)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_read(us, USBAT_ATA, 0x16, &status)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_read(us, USBAT_ATA, 0x14, &status)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_read(us, USBAT_ATA, 0x15, &status)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_write(us, USBAT_ATA, 0x14, 0x55)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_write(us, USBAT_ATA, 0x15, 0xAA)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_read(us, USBAT_ATA, 0x14, &status)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
-
-               if ( (result = usbat_read(us, USBAT_ATA, 0x15, &status)) != 
-                               USB_STOR_TRANSPORT_GOOD)
-                       return result;
+               if (usbat_write(us, USBAT_ATA, 0x16, selector) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_read(us, USBAT_ATA, 0x17, &status) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_read(us, USBAT_ATA, 0x16, &status) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_read(us, USBAT_ATA, 0x14, &status) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_read(us, USBAT_ATA, 0x15, &status) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_write(us, USBAT_ATA, 0x14, 0x55) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_write(us, USBAT_ATA, 0x15, 0xAA) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_read(us, USBAT_ATA, 0x14, &status) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
+
+               if (usbat_read(us, USBAT_ATA, 0x15, &status) != 
+                               USB_STOR_XFER_GOOD)
+                       return USB_STOR_TRANSPORT_ERROR;
        }
 
-       return result;
+       return USB_STOR_TRANSPORT_GOOD;
 }
 
 int init_8200e(struct us_data *us) {
@@ -637,44 +646,44 @@
 
        // Enable peripheral control signals
 
-       if ( (result = usbat_write_user_io(us,
+       if (usbat_write_user_io(us,
          USBAT_UIO_OE1 | USBAT_UIO_OE0,
-         USBAT_UIO_EPAD | USBAT_UIO_1)) != USB_STOR_TRANSPORT_GOOD)
-               return result;
+         USBAT_UIO_EPAD | USBAT_UIO_1) != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 1\n");
 
        wait_ms(2000);
 
-       if ( (result = usbat_read_user_io(us, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read_user_io(us, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 2\n");
 
-       if ( (result = usbat_read_user_io(us, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read_user_io(us, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 3\n");
 
        // Reset peripheral, enable periph control signals
        // (bring reset signal up)
 
-       if ( (result = usbat_write_user_io(us,
+       if (usbat_write_user_io(us,
          USBAT_UIO_DRVRST | USBAT_UIO_OE1 | USBAT_UIO_OE0,
-         USBAT_UIO_EPAD | USBAT_UIO_1)) != USB_STOR_TRANSPORT_GOOD)
-               return result;
+         USBAT_UIO_EPAD | USBAT_UIO_1) != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 4\n");
 
        // Enable periph control signals
        // (bring reset signal down)
 
-       if ( (result = usbat_write_user_io(us,
+       if (usbat_write_user_io(us,
          USBAT_UIO_OE1 | USBAT_UIO_OE0,
-         USBAT_UIO_EPAD | USBAT_UIO_1)) != USB_STOR_TRANSPORT_GOOD)
-               return result;
+         USBAT_UIO_EPAD | USBAT_UIO_1) != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 5\n");
 
@@ -682,23 +691,23 @@
 
        // Write 0x80 to ISA port 0x3F
 
-       if ( (result = usbat_write(us, USBAT_ISA, 0x3F, 0x80)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_write(us, USBAT_ISA, 0x3F, 0x80) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 6\n");
 
        // Read ISA port 0x27
 
-       if ( (result = usbat_read(us, USBAT_ISA, 0x27, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read(us, USBAT_ISA, 0x27, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 7\n");
 
-       if ( (result = usbat_read_user_io(us, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read_user_io(us, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 8\n");
 
@@ -708,32 +717,32 @@
 
        US_DEBUGP("INIT 9\n");
 
-       if ( (result = usbat_read_user_io(us, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read_user_io(us, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 10\n");
 
        // Enable periph control signals and card detect
 
-       if ( (result = usbat_write_user_io(us,
+       if (usbat_write_user_io(us,
          USBAT_UIO_ACKD |USBAT_UIO_OE1 | USBAT_UIO_OE0,
-         USBAT_UIO_EPAD | USBAT_UIO_1)) != USB_STOR_TRANSPORT_GOOD)
-               return result;
+         USBAT_UIO_EPAD | USBAT_UIO_1) != USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 11\n");
 
-       if ( (result = usbat_read_user_io(us, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read_user_io(us, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 12\n");
 
        wait_ms(1400);
 
-       if ( (result = usbat_read_user_io(us, &status)) !=
-                       USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_read_user_io(us, &status) !=
+                       USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 13\n");
 
@@ -743,14 +752,14 @@
 
        US_DEBUGP("INIT 14\n");
 
-       if ( (result = usbat_set_shuttle_features(us, 
-                       0x83, 0x00, 0x88, 0x08, 0x15, 0x14)) !=
-                        USB_STOR_TRANSPORT_GOOD)
-               return result;
+       if (usbat_set_shuttle_features(us, 
+                       0x83, 0x00, 0x88, 0x08, 0x15, 0x14) !=
+                        USB_STOR_XFER_GOOD)
+               return USB_STOR_TRANSPORT_ERROR;
 
        US_DEBUGP("INIT 15\n");
 
-       return result;
+       return USB_STOR_TRANSPORT_ERROR;
 }
 
 /*
@@ -857,17 +866,16 @@
 
                // How many bytes to read in? Check cylL register
 
-               if ( (result = usbat_read(us, USBAT_ATA, 0x14, &status)) != 
-                   USB_STOR_TRANSPORT_GOOD) {
-                       return result;
+               if (usbat_read(us, USBAT_ATA, 0x14, &status) != 
+                       USB_STOR_XFER_GOOD) {
+                       return USB_STOR_TRANSPORT_ERROR;
                }
 
-               if (len>0xFF) { // need to read cylH also
+               if (len > 0xFF) { // need to read cylH also
                        len = status;
-                       if ( (result = usbat_read(us, USBAT_ATA, 0x15,
-                               &status)) !=
-                                   USB_STOR_TRANSPORT_GOOD) {
-                               return result;
+                       if (usbat_read(us, USBAT_ATA, 0x15, &status) !=
+                                   USB_STOR_XFER_GOOD) {
+                               return USB_STOR_TRANSPORT_ERROR;
                        }
                        len += ((unsigned int)status)<<8;
                }
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c   Sun Oct 13 17:08:36 2002
+++ b/drivers/usb/storage/transport.c   Sun Oct 13 17:08:36 2002
@@ -579,7 +579,7 @@
 
        /* was the entire command transferred? */
        if (result < size) {
-               US_DEBUGP("-- transfer was short\n");
+               US_DEBUGP("-- transferred only %d bytes\n", result);
                return USB_STOR_XFER_SHORT;
        }
 
@@ -614,7 +614,8 @@
 
        /* if we stall, we need to clear it before we go on */
        if (result == -EPIPE) {
-               US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
+               US_DEBUGP("clearing endpoint halt for pipe 0x%x,"
+                               " stalled at %d bytes\n", pipe, partial);
                if (usb_stor_clear_halt(us, pipe) < 0)
                        return USB_STOR_XFER_ERROR;
                return USB_STOR_XFER_STALLED;


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to