Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
64648a9d 12aae68a

+10 -55
+9 -52
drivers/usb/storage/transport.c
··· 756 756 } 757 757 758 758 /* 759 - * Control/Bulk/Interrupt transport 759 + * Control/Bulk and Control/Bulk/Interrupt transport 760 760 */ 761 761 762 - int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us) 762 + int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) 763 763 { 764 764 unsigned int transfer_length = scsi_bufflen(srb); 765 765 unsigned int pipe = 0; ··· 801 801 } 802 802 803 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 811 result = usb_stor_intr_transfer(us, us->iobuf, 2); 805 812 US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", 806 813 us->iobuf[0], us->iobuf[1]); ··· 859 852 if (pipe) 860 853 usb_stor_clear_halt(us, pipe); 861 854 return USB_STOR_TRANSPORT_FAILED; 862 - } 863 - 864 - /* 865 - * Control/Bulk transport 866 - */ 867 - int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us) 868 - { 869 - unsigned int transfer_length = scsi_bufflen(srb); 870 - int result; 871 - 872 - /* COMMAND STAGE */ 873 - /* let's send the command via the control pipe */ 874 - result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, 875 - US_CBI_ADSC, 876 - USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, 877 - us->ifnum, srb->cmnd, srb->cmd_len); 878 - 879 - /* check the return code for the command */ 880 - US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result); 881 - 882 - /* if we stalled the command, it means command failed */ 883 - if (result == USB_STOR_XFER_STALLED) { 884 - return USB_STOR_TRANSPORT_FAILED; 885 - } 886 - 887 - /* Uh oh... serious problem here */ 888 - if (result != USB_STOR_XFER_GOOD) { 889 - return USB_STOR_TRANSPORT_ERROR; 890 - } 891 - 892 - /* DATA STAGE */ 893 - /* transfer the data payload for this command, if one exists*/ 894 - if (transfer_length) { 895 - unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 896 - us->recv_bulk_pipe : us->send_bulk_pipe; 897 - result = usb_stor_bulk_srb(us, pipe, srb); 898 - US_DEBUGP("CB data stage result is 0x%x\n", result); 899 - 900 - /* if we stalled the data transfer it means command failed */ 901 - if (result == USB_STOR_XFER_STALLED) 902 - return USB_STOR_TRANSPORT_FAILED; 903 - if (result > USB_STOR_XFER_STALLED) 904 - return USB_STOR_TRANSPORT_ERROR; 905 - } 906 - 907 - /* STATUS STAGE */ 908 - /* NOTE: CB does not have a status stage. Silly, I know. So 909 - * we have to catch this at a higher level. 910 - */ 911 - return USB_STOR_TRANSPORT_GOOD; 912 855 } 913 856 914 857 /*
-2
drivers/usb/storage/transport.h
··· 113 113 114 114 #define US_CBI_ADSC 0 115 115 116 - extern int usb_stor_CBI_transport(struct scsi_cmnd *, struct us_data*); 117 - 118 116 extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*); 119 117 extern int usb_stor_CB_reset(struct us_data*); 120 118
+1 -1
drivers/usb/storage/usb.c
··· 591 591 592 592 case US_PR_CBI: 593 593 us->transport_name = "Control/Bulk/Interrupt"; 594 - us->transport = usb_stor_CBI_transport; 594 + us->transport = usb_stor_CB_transport; 595 595 us->transport_reset = usb_stor_CB_reset; 596 596 us->max_lun = 7; 597 597 break;