]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
USB: usb-storage: merge CB and CBI transport routines
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 20 Nov 2008 19:20:03 +0000 (14:20 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 7 Jan 2009 17:59:57 +0000 (09:59 -0800)
This patch (as1173) merges usb-storage's CB and CBI transports into a
single routine.  So much of their code is common, it's silly to keep
them separate.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/storage/transport.c
drivers/usb/storage/transport.h
drivers/usb/storage/usb.c

index f584e72cc6890aec275fe32bd4323009e1b7a8a0..9cc30afd6d3123119c4ac77107e3b1b57344a7b6 100644 (file)
@@ -756,10 +756,10 @@ void usb_stor_stop_transport(struct us_data *us)
 }
 
 /*
- * Control/Bulk/Interrupt transport
+ * Control/Bulk and Control/Bulk/Interrupt transport
  */
 
-int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
+int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        unsigned int transfer_length = scsi_bufflen(srb);
        unsigned int pipe = 0;
@@ -801,6 +801,13 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
        }
 
        /* STATUS STAGE */
+
+       /* NOTE: CB does not have a status stage.  Silly, I know.  So
+        * we have to catch this at a higher level.
+        */
+       if (us->protocol != US_PR_CBI)
+               return USB_STOR_TRANSPORT_GOOD;
+
        result = usb_stor_intr_transfer(us, us->iobuf, 2);
        US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", 
                        us->iobuf[0], us->iobuf[1]);
@@ -854,56 +861,6 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
        return USB_STOR_TRANSPORT_FAILED;
 }
 
-/*
- * Control/Bulk transport
- */
-int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
-{
-       unsigned int transfer_length = scsi_bufflen(srb);
-       int result;
-
-       /* COMMAND STAGE */
-       /* let's send the command via the control pipe */
-       result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
-                                     US_CBI_ADSC, 
-                                     USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, 
-                                     us->ifnum, srb->cmnd, srb->cmd_len);
-
-       /* check the return code for the command */
-       US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);
-
-       /* if we stalled the command, it means command failed */
-       if (result == USB_STOR_XFER_STALLED) {
-               return USB_STOR_TRANSPORT_FAILED;
-       }
-
-       /* Uh oh... serious problem here */
-       if (result != USB_STOR_XFER_GOOD) {
-               return USB_STOR_TRANSPORT_ERROR;
-       }
-
-       /* DATA STAGE */
-       /* transfer the data payload for this command, if one exists*/
-       if (transfer_length) {
-               unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
-                               us->recv_bulk_pipe : us->send_bulk_pipe;
-               result = usb_stor_bulk_srb(us, pipe, srb);
-               US_DEBUGP("CB data stage result is 0x%x\n", result);
-
-               /* if we stalled the data transfer it means command failed */
-               if (result == USB_STOR_XFER_STALLED)
-                       return USB_STOR_TRANSPORT_FAILED;
-               if (result > USB_STOR_XFER_STALLED)
-                       return USB_STOR_TRANSPORT_ERROR;
-       }
-
-       /* STATUS STAGE */
-       /* NOTE: CB does not have a status stage.  Silly, I know.  So
-        * we have to catch this at a higher level.
-        */
-       return USB_STOR_TRANSPORT_GOOD;
-}
-
 /*
  * Bulk only transport
  */
index e70b88182f0ee8713f0f0676c879252b6b8d379e..242ff5e791a532ecc96d4ceaf180e3d60130f8c1 100644 (file)
@@ -113,8 +113,6 @@ struct bulk_cs_wrap {
 
 #define US_CBI_ADSC            0
 
-extern int usb_stor_CBI_transport(struct scsi_cmnd *, struct us_data*);
-
 extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
 extern int usb_stor_CB_reset(struct us_data*);
 
index 099e07c6af7b9bbcdb606ead9eee911c3c3ef84a..cdd009fae3cdf2c60838d73e90ab2850c6427e2a 100644 (file)
@@ -591,7 +591,7 @@ static int get_transport(struct us_data *us)
 
        case US_PR_CBI:
                us->transport_name = "Control/Bulk/Interrupt";
-               us->transport = usb_stor_CBI_transport;
+               us->transport = usb_stor_CB_transport;
                us->transport_reset = usb_stor_CB_reset;
                us->max_lun = 7;
                break;