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

usb/storage: redefine US_BULK_FLAG_IN and use it

US_BULK_FLAG_IN is defined as 1 and not used. The USB storage spec says
that bit 7 of flags within CBW defines the data direction. 1 is DATA-IN
(read from device) and 0 is the DATA-OUT. Bit 6 is obselete and bits 0-5
are reserved.
This patch redefines the unsued define US_BULK_FLAG_IN from 1 to 1 << 7
aka 0x80 and replaces the obvious users. In a following patch the
storage gadget will use it as well.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sebastian Andrzej Siewior and committed by
Greg Kroah-Hartman
b8db6d64 7ac4704c

+18 -17
+13 -13
drivers/usb/storage/ene_ub6250.c
··· 674 674 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 675 675 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 676 676 bcb->DataTransferLength = blenByte; 677 - bcb->Flags = 0x80; 677 + bcb->Flags = US_BULK_FLAG_IN; 678 678 bcb->CDB[0] = 0xF1; 679 679 bcb->CDB[5] = (unsigned char)(bnByte); 680 680 bcb->CDB[4] = (unsigned char)(bnByte>>8); ··· 858 858 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 859 859 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 860 860 bcb->DataTransferLength = 0x200; 861 - bcb->Flags = 0x80; 861 + bcb->Flags = US_BULK_FLAG_IN; 862 862 bcb->CDB[0] = 0xF1; 863 863 864 864 bcb->CDB[1] = 0x02; /* in init.c ENE_MSInit() is 0x01 */ ··· 877 877 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 878 878 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 879 879 bcb->DataTransferLength = 0x4; 880 - bcb->Flags = 0x80; 880 + bcb->Flags = US_BULK_FLAG_IN; 881 881 bcb->CDB[0] = 0xF1; 882 882 bcb->CDB[1] = 0x03; 883 883 ··· 1170 1170 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1171 1171 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1172 1172 bcb->DataTransferLength = 0x200; 1173 - bcb->Flags = 0x80; 1173 + bcb->Flags = US_BULK_FLAG_IN; 1174 1174 bcb->CDB[0] = 0xF2; 1175 1175 bcb->CDB[1] = 0x06; 1176 1176 bcb->CDB[4] = (unsigned char)(bn); ··· 1249 1249 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1250 1250 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1251 1251 bcb->DataTransferLength = 0x4; 1252 - bcb->Flags = 0x80; 1252 + bcb->Flags = US_BULK_FLAG_IN; 1253 1253 bcb->CDB[0] = 0xF2; 1254 1254 bcb->CDB[1] = 0x05; 1255 1255 bcb->CDB[5] = (unsigned char)(PageNum); ··· 1331 1331 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1332 1332 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1333 1333 bcb->DataTransferLength = 0x4; 1334 - bcb->Flags = 0x80; 1334 + bcb->Flags = US_BULK_FLAG_IN; 1335 1335 bcb->CDB[0] = 0xF1; 1336 1336 bcb->CDB[1] = 0x03; 1337 1337 bcb->CDB[5] = (unsigned char)(PageNum); ··· 1533 1533 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1534 1534 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1535 1535 bcb->DataTransferLength = 0x4 * blen; 1536 - bcb->Flags = 0x80; 1536 + bcb->Flags = US_BULK_FLAG_IN; 1537 1537 bcb->CDB[0] = 0xF1; 1538 1538 bcb->CDB[1] = 0x03; 1539 1539 bcb->CDB[5] = (unsigned char)(PageNum); ··· 1650 1650 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1651 1651 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1652 1652 bcb->DataTransferLength = blenByte; 1653 - bcb->Flags = 0x80; 1653 + bcb->Flags = US_BULK_FLAG_IN; 1654 1654 bcb->CDB[0] = 0xF1; 1655 1655 bcb->CDB[1] = 0x02; 1656 1656 bcb->CDB[5] = (unsigned char)(bn); ··· 1694 1694 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1695 1695 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1696 1696 bcb->DataTransferLength = 0x200 * len; 1697 - bcb->Flags = 0x80; 1697 + bcb->Flags = US_BULK_FLAG_IN; 1698 1698 bcb->CDB[0] = 0xF1; 1699 1699 bcb->CDB[1] = 0x02; 1700 1700 bcb->CDB[5] = (unsigned char)(blkno); ··· 1827 1827 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1828 1828 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1829 1829 bcb->DataTransferLength = 0x01; 1830 - bcb->Flags = 0x80; 1830 + bcb->Flags = US_BULK_FLAG_IN; 1831 1831 bcb->CDB[0] = 0xED; 1832 1832 bcb->CDB[2] = (unsigned char)(index>>8); 1833 1833 bcb->CDB[3] = (unsigned char)index; ··· 2083 2083 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 2084 2084 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 2085 2085 bcb->DataTransferLength = 0x200; 2086 - bcb->Flags = 0x80; 2086 + bcb->Flags = US_BULK_FLAG_IN; 2087 2087 bcb->CDB[0] = 0xF1; 2088 2088 bcb->CDB[1] = 0x01; 2089 2089 ··· 2134 2134 2135 2135 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 2136 2136 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 2137 - bcb->Flags = 0x80; 2137 + bcb->Flags = US_BULK_FLAG_IN; 2138 2138 bcb->CDB[0] = 0xF2; 2139 2139 2140 2140 result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); ··· 2153 2153 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 2154 2154 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 2155 2155 bcb->DataTransferLength = 0x200; 2156 - bcb->Flags = 0x80; 2156 + bcb->Flags = US_BULK_FLAG_IN; 2157 2157 bcb->CDB[0] = 0xF1; 2158 2158 2159 2159 result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0);
+2 -2
drivers/usb/storage/realtek_cr.c
··· 219 219 /* set up the command wrapper */ 220 220 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 221 221 bcb->DataTransferLength = cpu_to_le32(buf_len); 222 - bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0; 222 + bcb->Flags = (dir == DMA_FROM_DEVICE) ? US_BULK_FLAG_IN : 0; 223 223 bcb->Tag = ++us->tag; 224 224 bcb->Lun = lun; 225 225 bcb->Length = cmd_len; ··· 305 305 /* set up the command wrapper */ 306 306 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 307 307 bcb->DataTransferLength = cpu_to_le32(buf_len); 308 - bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0; 308 + bcb->Flags = (dir == DMA_FROM_DEVICE) ? US_BULK_FLAG_IN : 0; 309 309 bcb->Tag = ++us->tag; 310 310 bcb->Lun = lun; 311 311 bcb->Length = cmd_len;
+2 -1
drivers/usb/storage/transport.c
··· 1071 1071 /* set up the command wrapper */ 1072 1072 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1073 1073 bcb->DataTransferLength = cpu_to_le32(transfer_length); 1074 - bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; 1074 + bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1075 + US_BULK_FLAG_IN : 0; 1075 1076 bcb->Tag = ++us->tag; 1076 1077 bcb->Lun = srb->device->lun; 1077 1078 if (us->fflags & US_FL_SCM_MULT_TARG)
+1 -1
include/linux/usb/storage.h
··· 62 62 63 63 #define US_BULK_CB_WRAP_LEN 31 64 64 #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */ 65 - #define US_BULK_FLAG_IN 1 65 + #define US_BULK_FLAG_IN (1 << 7) 66 66 #define US_BULK_FLAG_OUT 0 67 67 68 68 /* command status wrapper */