diff options
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 24 | ||||
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 24 | ||||
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 21 |
3 files changed, 24 insertions, 45 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 9e71fe7fc50..84e6573ea74 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -620,7 +620,7 @@ static int fsg_setup(struct usb_function *f, | |||
620 | 620 | ||
621 | switch (ctrl->bRequest) { | 621 | switch (ctrl->bRequest) { |
622 | 622 | ||
623 | case USB_BULK_RESET_REQUEST: | 623 | case US_BULK_RESET_REQUEST: |
624 | if (ctrl->bRequestType != | 624 | if (ctrl->bRequestType != |
625 | (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 625 | (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
626 | break; | 626 | break; |
@@ -636,7 +636,7 @@ static int fsg_setup(struct usb_function *f, | |||
636 | raise_exception(fsg->common, FSG_STATE_RESET); | 636 | raise_exception(fsg->common, FSG_STATE_RESET); |
637 | return DELAYED_STATUS; | 637 | return DELAYED_STATUS; |
638 | 638 | ||
639 | case USB_BULK_GET_MAX_LUN_REQUEST: | 639 | case US_BULK_GET_MAX_LUN: |
640 | if (ctrl->bRequestType != | 640 | if (ctrl->bRequestType != |
641 | (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 641 | (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
642 | break; | 642 | break; |
@@ -1742,7 +1742,7 @@ static int send_status(struct fsg_common *common) | |||
1742 | struct fsg_buffhd *bh; | 1742 | struct fsg_buffhd *bh; |
1743 | struct bulk_cs_wrap *csw; | 1743 | struct bulk_cs_wrap *csw; |
1744 | int rc; | 1744 | int rc; |
1745 | u8 status = USB_STATUS_PASS; | 1745 | u8 status = US_BULK_STAT_OK; |
1746 | u32 sd, sdinfo = 0; | 1746 | u32 sd, sdinfo = 0; |
1747 | 1747 | ||
1748 | /* Wait for the next buffer to become available */ | 1748 | /* Wait for the next buffer to become available */ |
@@ -1763,11 +1763,11 @@ static int send_status(struct fsg_common *common) | |||
1763 | 1763 | ||
1764 | if (common->phase_error) { | 1764 | if (common->phase_error) { |
1765 | DBG(common, "sending phase-error status\n"); | 1765 | DBG(common, "sending phase-error status\n"); |
1766 | status = USB_STATUS_PHASE_ERROR; | 1766 | status = US_BULK_STAT_PHASE; |
1767 | sd = SS_INVALID_COMMAND; | 1767 | sd = SS_INVALID_COMMAND; |
1768 | } else if (sd != SS_NO_SENSE) { | 1768 | } else if (sd != SS_NO_SENSE) { |
1769 | DBG(common, "sending command-failure status\n"); | 1769 | DBG(common, "sending command-failure status\n"); |
1770 | status = USB_STATUS_FAIL; | 1770 | status = US_BULK_STAT_FAIL; |
1771 | VDBG(common, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" | 1771 | VDBG(common, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" |
1772 | " info x%x\n", | 1772 | " info x%x\n", |
1773 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); | 1773 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); |
@@ -1776,12 +1776,12 @@ static int send_status(struct fsg_common *common) | |||
1776 | /* Store and send the Bulk-only CSW */ | 1776 | /* Store and send the Bulk-only CSW */ |
1777 | csw = (void *)bh->buf; | 1777 | csw = (void *)bh->buf; |
1778 | 1778 | ||
1779 | csw->Signature = cpu_to_le32(USB_BULK_CS_SIG); | 1779 | csw->Signature = cpu_to_le32(US_BULK_CS_SIGN); |
1780 | csw->Tag = common->tag; | 1780 | csw->Tag = common->tag; |
1781 | csw->Residue = cpu_to_le32(common->residue); | 1781 | csw->Residue = cpu_to_le32(common->residue); |
1782 | csw->Status = status; | 1782 | csw->Status = status; |
1783 | 1783 | ||
1784 | bh->inreq->length = USB_BULK_CS_WRAP_LEN; | 1784 | bh->inreq->length = US_BULK_CS_WRAP_LEN; |
1785 | bh->inreq->zero = 0; | 1785 | bh->inreq->zero = 0; |
1786 | if (!start_in_transfer(common, bh)) | 1786 | if (!start_in_transfer(common, bh)) |
1787 | /* Don't know what to do if common->fsg is NULL */ | 1787 | /* Don't know what to do if common->fsg is NULL */ |
@@ -2229,9 +2229,9 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2229 | return -EINVAL; | 2229 | return -EINVAL; |
2230 | 2230 | ||
2231 | /* Is the CBW valid? */ | 2231 | /* Is the CBW valid? */ |
2232 | if (req->actual != USB_BULK_CB_WRAP_LEN || | 2232 | if (req->actual != US_BULK_CB_WRAP_LEN || |
2233 | cbw->Signature != cpu_to_le32( | 2233 | cbw->Signature != cpu_to_le32( |
2234 | USB_BULK_CB_SIG)) { | 2234 | US_BULK_CB_SIGN)) { |
2235 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", | 2235 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", |
2236 | req->actual, | 2236 | req->actual, |
2237 | le32_to_cpu(cbw->Signature)); | 2237 | le32_to_cpu(cbw->Signature)); |
@@ -2253,7 +2253,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | /* Is the CBW meaningful? */ | 2255 | /* Is the CBW meaningful? */ |
2256 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~USB_BULK_IN_FLAG || | 2256 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN || |
2257 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { | 2257 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { |
2258 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " | 2258 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " |
2259 | "cmdlen %u\n", | 2259 | "cmdlen %u\n", |
@@ -2273,7 +2273,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2273 | /* Save the command for later */ | 2273 | /* Save the command for later */ |
2274 | common->cmnd_size = cbw->Length; | 2274 | common->cmnd_size = cbw->Length; |
2275 | memcpy(common->cmnd, cbw->CDB, common->cmnd_size); | 2275 | memcpy(common->cmnd, cbw->CDB, common->cmnd_size); |
2276 | if (cbw->Flags & USB_BULK_IN_FLAG) | 2276 | if (cbw->Flags & US_BULK_FLAG_IN) |
2277 | common->data_dir = DATA_DIR_TO_HOST; | 2277 | common->data_dir = DATA_DIR_TO_HOST; |
2278 | else | 2278 | else |
2279 | common->data_dir = DATA_DIR_FROM_HOST; | 2279 | common->data_dir = DATA_DIR_FROM_HOST; |
@@ -2303,7 +2303,7 @@ static int get_next_command(struct fsg_common *common) | |||
2303 | } | 2303 | } |
2304 | 2304 | ||
2305 | /* Queue a request to read a Bulk-only CBW */ | 2305 | /* Queue a request to read a Bulk-only CBW */ |
2306 | set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN); | 2306 | set_bulk_out_req_length(common, bh, US_BULK_CB_WRAP_LEN); |
2307 | if (!start_out_transfer(common, bh)) | 2307 | if (!start_out_transfer(common, bh)) |
2308 | /* Don't know what to do if common->fsg is NULL */ | 2308 | /* Don't know what to do if common->fsg is NULL */ |
2309 | return -EIO; | 2309 | return -EIO; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 15e6e8e55ef..4fac5692774 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -855,7 +855,7 @@ static int class_setup_req(struct fsg_dev *fsg, | |||
855 | if (transport_is_bbb()) { | 855 | if (transport_is_bbb()) { |
856 | switch (ctrl->bRequest) { | 856 | switch (ctrl->bRequest) { |
857 | 857 | ||
858 | case USB_BULK_RESET_REQUEST: | 858 | case US_BULK_RESET_REQUEST: |
859 | if (ctrl->bRequestType != (USB_DIR_OUT | | 859 | if (ctrl->bRequestType != (USB_DIR_OUT | |
860 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 860 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
861 | break; | 861 | break; |
@@ -871,7 +871,7 @@ static int class_setup_req(struct fsg_dev *fsg, | |||
871 | value = DELAYED_STATUS; | 871 | value = DELAYED_STATUS; |
872 | break; | 872 | break; |
873 | 873 | ||
874 | case USB_BULK_GET_MAX_LUN_REQUEST: | 874 | case US_BULK_GET_MAX_LUN: |
875 | if (ctrl->bRequestType != (USB_DIR_IN | | 875 | if (ctrl->bRequestType != (USB_DIR_IN | |
876 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 876 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
877 | break; | 877 | break; |
@@ -2125,7 +2125,7 @@ static int send_status(struct fsg_dev *fsg) | |||
2125 | struct fsg_lun *curlun = fsg->curlun; | 2125 | struct fsg_lun *curlun = fsg->curlun; |
2126 | struct fsg_buffhd *bh; | 2126 | struct fsg_buffhd *bh; |
2127 | int rc; | 2127 | int rc; |
2128 | u8 status = USB_STATUS_PASS; | 2128 | u8 status = US_BULK_STAT_OK; |
2129 | u32 sd, sdinfo = 0; | 2129 | u32 sd, sdinfo = 0; |
2130 | 2130 | ||
2131 | /* Wait for the next buffer to become available */ | 2131 | /* Wait for the next buffer to become available */ |
@@ -2146,11 +2146,11 @@ static int send_status(struct fsg_dev *fsg) | |||
2146 | 2146 | ||
2147 | if (fsg->phase_error) { | 2147 | if (fsg->phase_error) { |
2148 | DBG(fsg, "sending phase-error status\n"); | 2148 | DBG(fsg, "sending phase-error status\n"); |
2149 | status = USB_STATUS_PHASE_ERROR; | 2149 | status = US_BULK_STAT_PHASE; |
2150 | sd = SS_INVALID_COMMAND; | 2150 | sd = SS_INVALID_COMMAND; |
2151 | } else if (sd != SS_NO_SENSE) { | 2151 | } else if (sd != SS_NO_SENSE) { |
2152 | DBG(fsg, "sending command-failure status\n"); | 2152 | DBG(fsg, "sending command-failure status\n"); |
2153 | status = USB_STATUS_FAIL; | 2153 | status = US_BULK_STAT_FAIL; |
2154 | VDBG(fsg, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" | 2154 | VDBG(fsg, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" |
2155 | " info x%x\n", | 2155 | " info x%x\n", |
2156 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); | 2156 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); |
@@ -2160,12 +2160,12 @@ static int send_status(struct fsg_dev *fsg) | |||
2160 | struct bulk_cs_wrap *csw = bh->buf; | 2160 | struct bulk_cs_wrap *csw = bh->buf; |
2161 | 2161 | ||
2162 | /* Store and send the Bulk-only CSW */ | 2162 | /* Store and send the Bulk-only CSW */ |
2163 | csw->Signature = cpu_to_le32(USB_BULK_CS_SIG); | 2163 | csw->Signature = cpu_to_le32(US_BULK_CS_SIGN); |
2164 | csw->Tag = fsg->tag; | 2164 | csw->Tag = fsg->tag; |
2165 | csw->Residue = cpu_to_le32(fsg->residue); | 2165 | csw->Residue = cpu_to_le32(fsg->residue); |
2166 | csw->Status = status; | 2166 | csw->Status = status; |
2167 | 2167 | ||
2168 | bh->inreq->length = USB_BULK_CS_WRAP_LEN; | 2168 | bh->inreq->length = US_BULK_CS_WRAP_LEN; |
2169 | bh->inreq->zero = 0; | 2169 | bh->inreq->zero = 0; |
2170 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | 2170 | start_transfer(fsg, fsg->bulk_in, bh->inreq, |
2171 | &bh->inreq_busy, &bh->state); | 2171 | &bh->inreq_busy, &bh->state); |
@@ -2616,9 +2616,9 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2616 | return -EINVAL; | 2616 | return -EINVAL; |
2617 | 2617 | ||
2618 | /* Is the CBW valid? */ | 2618 | /* Is the CBW valid? */ |
2619 | if (req->actual != USB_BULK_CB_WRAP_LEN || | 2619 | if (req->actual != US_BULK_CB_WRAP_LEN || |
2620 | cbw->Signature != cpu_to_le32( | 2620 | cbw->Signature != cpu_to_le32( |
2621 | USB_BULK_CB_SIG)) { | 2621 | US_BULK_CB_SIGN)) { |
2622 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", | 2622 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", |
2623 | req->actual, | 2623 | req->actual, |
2624 | le32_to_cpu(cbw->Signature)); | 2624 | le32_to_cpu(cbw->Signature)); |
@@ -2638,7 +2638,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2638 | } | 2638 | } |
2639 | 2639 | ||
2640 | /* Is the CBW meaningful? */ | 2640 | /* Is the CBW meaningful? */ |
2641 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~USB_BULK_IN_FLAG || | 2641 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN || |
2642 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { | 2642 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { |
2643 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " | 2643 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " |
2644 | "cmdlen %u\n", | 2644 | "cmdlen %u\n", |
@@ -2656,7 +2656,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2656 | /* Save the command for later */ | 2656 | /* Save the command for later */ |
2657 | fsg->cmnd_size = cbw->Length; | 2657 | fsg->cmnd_size = cbw->Length; |
2658 | memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size); | 2658 | memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size); |
2659 | if (cbw->Flags & USB_BULK_IN_FLAG) | 2659 | if (cbw->Flags & US_BULK_FLAG_IN) |
2660 | fsg->data_dir = DATA_DIR_TO_HOST; | 2660 | fsg->data_dir = DATA_DIR_TO_HOST; |
2661 | else | 2661 | else |
2662 | fsg->data_dir = DATA_DIR_FROM_HOST; | 2662 | fsg->data_dir = DATA_DIR_FROM_HOST; |
@@ -2685,7 +2685,7 @@ static int get_next_command(struct fsg_dev *fsg) | |||
2685 | } | 2685 | } |
2686 | 2686 | ||
2687 | /* Queue a request to read a Bulk-only CBW */ | 2687 | /* Queue a request to read a Bulk-only CBW */ |
2688 | set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN); | 2688 | set_bulk_out_req_length(fsg, bh, US_BULK_CB_WRAP_LEN); |
2689 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 2689 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
2690 | &bh->outreq_busy, &bh->state); | 2690 | &bh->outreq_busy, &bh->state); |
2691 | 2691 | ||
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 4095696b158..52ab4098b3c 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -145,29 +145,8 @@ | |||
145 | 145 | ||
146 | #endif /* DUMP_MSGS */ | 146 | #endif /* DUMP_MSGS */ |
147 | 147 | ||
148 | |||
149 | |||
150 | |||
151 | |||
152 | /*-------------------------------------------------------------------------*/ | 148 | /*-------------------------------------------------------------------------*/ |
153 | 149 | ||
154 | /* Bulk-only data structures */ | ||
155 | |||
156 | #define USB_BULK_CB_WRAP_LEN 31 | ||
157 | #define USB_BULK_CB_SIG 0x43425355 /* Spells out USBC */ | ||
158 | #define USB_BULK_IN_FLAG 0x80 | ||
159 | |||
160 | #define USB_BULK_CS_WRAP_LEN 13 | ||
161 | #define USB_BULK_CS_SIG 0x53425355 /* Spells out 'USBS' */ | ||
162 | #define USB_STATUS_PASS 0 | ||
163 | #define USB_STATUS_FAIL 1 | ||
164 | #define USB_STATUS_PHASE_ERROR 2 | ||
165 | |||
166 | /* Bulk-only class specific requests */ | ||
167 | #define USB_BULK_RESET_REQUEST 0xff | ||
168 | #define USB_BULK_GET_MAX_LUN_REQUEST 0xfe | ||
169 | |||
170 | |||
171 | /* CBI Interrupt data structure */ | 150 | /* CBI Interrupt data structure */ |
172 | struct interrupt_data { | 151 | struct interrupt_data { |
173 | u8 bType; | 152 | u8 bType; |