aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2008-11-20 14:20:03 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 12:59:57 -0500
commit64648a9dc4d7ac0189364188207310ec6bc75bbe (patch)
treed66c3054df85828f7910822b8dc8f0d5ebf17da4 /drivers/usb/storage
parent12aae68a203e97a58d3f8237fc389201a4d9282d (diff)
USB: usb-storage: merge CB and CBI transport routines
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>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/transport.c61
-rw-r--r--drivers/usb/storage/transport.h2
-rw-r--r--drivers/usb/storage/usb.c2
3 files changed, 10 insertions, 55 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index f584e72cc689..9cc30afd6d31 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -756,10 +756,10 @@ void usb_stor_stop_transport(struct us_data *us)
756} 756}
757 757
758/* 758/*
759 * Control/Bulk/Interrupt transport 759 * Control/Bulk and Control/Bulk/Interrupt transport
760 */ 760 */
761 761
762int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us) 762int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
763{ 763{
764 unsigned int transfer_length = scsi_bufflen(srb); 764 unsigned int transfer_length = scsi_bufflen(srb);
765 unsigned int pipe = 0; 765 unsigned int pipe = 0;
@@ -801,6 +801,13 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
801 } 801 }
802 802
803 /* STATUS STAGE */ 803 /* STATUS STAGE */
804
805 /* NOTE: CB does not have a status stage. Silly, I know. So
806 * we have to catch this at a higher level.
807 */
808 if (us->protocol != US_PR_CBI)
809 return USB_STOR_TRANSPORT_GOOD;
810
804 result = usb_stor_intr_transfer(us, us->iobuf, 2); 811 result = usb_stor_intr_transfer(us, us->iobuf, 2);
805 US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", 812 US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n",
806 us->iobuf[0], us->iobuf[1]); 813 us->iobuf[0], us->iobuf[1]);
@@ -855,56 +862,6 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
855} 862}
856 863
857/* 864/*
858 * Control/Bulk transport
859 */
860int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
861{
862 unsigned int transfer_length = scsi_bufflen(srb);
863 int result;
864
865 /* COMMAND STAGE */
866 /* let's send the command via the control pipe */
867 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
868 US_CBI_ADSC,
869 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
870 us->ifnum, srb->cmnd, srb->cmd_len);
871
872 /* check the return code for the command */
873 US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);
874
875 /* if we stalled the command, it means command failed */
876 if (result == USB_STOR_XFER_STALLED) {
877 return USB_STOR_TRANSPORT_FAILED;
878 }
879
880 /* Uh oh... serious problem here */
881 if (result != USB_STOR_XFER_GOOD) {
882 return USB_STOR_TRANSPORT_ERROR;
883 }
884
885 /* DATA STAGE */
886 /* transfer the data payload for this command, if one exists*/
887 if (transfer_length) {
888 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
889 us->recv_bulk_pipe : us->send_bulk_pipe;
890 result = usb_stor_bulk_srb(us, pipe, srb);
891 US_DEBUGP("CB data stage result is 0x%x\n", result);
892
893 /* if we stalled the data transfer it means command failed */
894 if (result == USB_STOR_XFER_STALLED)
895 return USB_STOR_TRANSPORT_FAILED;
896 if (result > USB_STOR_XFER_STALLED)
897 return USB_STOR_TRANSPORT_ERROR;
898 }
899
900 /* STATUS STAGE */
901 /* NOTE: CB does not have a status stage. Silly, I know. So
902 * we have to catch this at a higher level.
903 */
904 return USB_STOR_TRANSPORT_GOOD;
905}
906
907/*
908 * Bulk only transport 865 * Bulk only transport
909 */ 866 */
910 867
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index e70b88182f0e..242ff5e791a5 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -113,8 +113,6 @@ struct bulk_cs_wrap {
113 113
114#define US_CBI_ADSC 0 114#define US_CBI_ADSC 0
115 115
116extern int usb_stor_CBI_transport(struct scsi_cmnd *, struct us_data*);
117
118extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*); 116extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
119extern int usb_stor_CB_reset(struct us_data*); 117extern int usb_stor_CB_reset(struct us_data*);
120 118
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 099e07c6af7b..cdd009fae3cd 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -591,7 +591,7 @@ static int get_transport(struct us_data *us)
591 591
592 case US_PR_CBI: 592 case US_PR_CBI:
593 us->transport_name = "Control/Bulk/Interrupt"; 593 us->transport_name = "Control/Bulk/Interrupt";
594 us->transport = usb_stor_CBI_transport; 594 us->transport = usb_stor_CB_transport;
595 us->transport_reset = usb_stor_CB_reset; 595 us->transport_reset = usb_stor_CB_reset;
596 us->max_lun = 7; 596 us->max_lun = 7;
597 break; 597 break;