diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-19 08:50:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-19 08:50:38 -0400 |
commit | 50ee9339c7347c2b16fa79d43777f72e9f41ef5a (patch) | |
tree | ce09aa147e5c8bb74c72c46cebfdbffeece6678f /drivers/usb/gadget | |
parent | f0e615c3cb72b42191b558c130409335812621d8 (diff) | |
parent | 98346f7db014614a4814eb60639f651f8bbc591d (diff) |
Merge 2.6.39-rc4 into usb-next
This is needed to help resolve some xhci issues and other minor
differences.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/Kconfig | 18 | ||||
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 60 | ||||
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 53 | ||||
-rw-r--r-- | drivers/usb/gadget/fsl_qe_udc.h | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/gadget_chips.h | 9 | ||||
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 15 |
6 files changed, 66 insertions, 91 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bc5123cf41c2..4c02b9f1597e 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -260,6 +260,24 @@ config USB_R8A66597 | |||
260 | default USB_GADGET | 260 | default USB_GADGET |
261 | select USB_GADGET_SELECTED | 261 | select USB_GADGET_SELECTED |
262 | 262 | ||
263 | config USB_GADGET_RENESAS_USBHS | ||
264 | boolean "Renesas USBHS" | ||
265 | depends on USB_RENESAS_USBHS | ||
266 | select USB_GADGET_DUALSPEED | ||
267 | help | ||
268 | Renesas USBHS is a discrete USB host and peripheral controller | ||
269 | chip that supports both full and high speed USB 2.0 data transfers. | ||
270 | platform is able to configure endpoint (pipe) style | ||
271 | |||
272 | Say "y" to enable the gadget specific portion of the USBHS driver. | ||
273 | |||
274 | |||
275 | config USB_RENESAS_USBHS_UDC | ||
276 | tristate | ||
277 | depends on USB_GADGET_RENESAS_USBHS | ||
278 | default USB_GADGET | ||
279 | select USB_GADGET_SELECTED | ||
280 | |||
263 | config USB_GADGET_PXA27X | 281 | config USB_GADGET_PXA27X |
264 | boolean "PXA 27x" | 282 | boolean "PXA 27x" |
265 | depends on ARCH_PXA && (PXA27x || PXA3xx) | 283 | depends on ARCH_PXA && (PXA27x || PXA3xx) |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 6d8e533949eb..01ae27b60d4c 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -613,6 +613,11 @@ static int fsg_setup(struct usb_function *f, | |||
613 | if (!fsg_is_set(fsg->common)) | 613 | if (!fsg_is_set(fsg->common)) |
614 | return -EOPNOTSUPP; | 614 | return -EOPNOTSUPP; |
615 | 615 | ||
616 | ++fsg->common->ep0_req_tag; /* Record arrival of a new request */ | ||
617 | req->context = NULL; | ||
618 | req->length = 0; | ||
619 | dump_msg(fsg, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl)); | ||
620 | |||
616 | switch (ctrl->bRequest) { | 621 | switch (ctrl->bRequest) { |
617 | 622 | ||
618 | case USB_BULK_RESET_REQUEST: | 623 | case USB_BULK_RESET_REQUEST: |
@@ -1584,37 +1589,6 @@ static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) | |||
1584 | return rc; | 1589 | return rc; |
1585 | } | 1590 | } |
1586 | 1591 | ||
1587 | static int pad_with_zeros(struct fsg_dev *fsg) | ||
1588 | { | ||
1589 | struct fsg_buffhd *bh = fsg->common->next_buffhd_to_fill; | ||
1590 | u32 nkeep = bh->inreq->length; | ||
1591 | u32 nsend; | ||
1592 | int rc; | ||
1593 | |||
1594 | bh->state = BUF_STATE_EMPTY; /* For the first iteration */ | ||
1595 | fsg->common->usb_amount_left = nkeep + fsg->common->residue; | ||
1596 | while (fsg->common->usb_amount_left > 0) { | ||
1597 | |||
1598 | /* Wait for the next buffer to be free */ | ||
1599 | while (bh->state != BUF_STATE_EMPTY) { | ||
1600 | rc = sleep_thread(fsg->common); | ||
1601 | if (rc) | ||
1602 | return rc; | ||
1603 | } | ||
1604 | |||
1605 | nsend = min(fsg->common->usb_amount_left, FSG_BUFLEN); | ||
1606 | memset(bh->buf + nkeep, 0, nsend - nkeep); | ||
1607 | bh->inreq->length = nsend; | ||
1608 | bh->inreq->zero = 0; | ||
1609 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
1610 | &bh->inreq_busy, &bh->state); | ||
1611 | bh = fsg->common->next_buffhd_to_fill = bh->next; | ||
1612 | fsg->common->usb_amount_left -= nsend; | ||
1613 | nkeep = 0; | ||
1614 | } | ||
1615 | return 0; | ||
1616 | } | ||
1617 | |||
1618 | static int throw_away_data(struct fsg_common *common) | 1592 | static int throw_away_data(struct fsg_common *common) |
1619 | { | 1593 | { |
1620 | struct fsg_buffhd *bh; | 1594 | struct fsg_buffhd *bh; |
@@ -1702,6 +1676,10 @@ static int finish_reply(struct fsg_common *common) | |||
1702 | if (common->data_size == 0) { | 1676 | if (common->data_size == 0) { |
1703 | /* Nothing to send */ | 1677 | /* Nothing to send */ |
1704 | 1678 | ||
1679 | /* Don't know what to do if common->fsg is NULL */ | ||
1680 | } else if (!fsg_is_set(common)) { | ||
1681 | rc = -EIO; | ||
1682 | |||
1705 | /* If there's no residue, simply send the last buffer */ | 1683 | /* If there's no residue, simply send the last buffer */ |
1706 | } else if (common->residue == 0) { | 1684 | } else if (common->residue == 0) { |
1707 | bh->inreq->zero = 0; | 1685 | bh->inreq->zero = 0; |
@@ -1710,24 +1688,19 @@ static int finish_reply(struct fsg_common *common) | |||
1710 | common->next_buffhd_to_fill = bh->next; | 1688 | common->next_buffhd_to_fill = bh->next; |
1711 | 1689 | ||
1712 | /* | 1690 | /* |
1713 | * For Bulk-only, if we're allowed to stall then send the | 1691 | * For Bulk-only, mark the end of the data with a short |
1714 | * short packet and halt the bulk-in endpoint. If we can't | 1692 | * packet. If we are allowed to stall, halt the bulk-in |
1715 | * stall, pad out the remaining data with 0's. | 1693 | * endpoint. (Note: This violates the Bulk-Only Transport |
1694 | * specification, which requires us to pad the data if we | ||
1695 | * don't halt the endpoint. Presumably nobody will mind.) | ||
1716 | */ | 1696 | */ |
1717 | } else if (common->can_stall) { | 1697 | } else { |
1718 | bh->inreq->zero = 1; | 1698 | bh->inreq->zero = 1; |
1719 | if (!start_in_transfer(common, bh)) | 1699 | if (!start_in_transfer(common, bh)) |
1720 | /* Don't know what to do if | ||
1721 | * common->fsg is NULL */ | ||
1722 | rc = -EIO; | 1700 | rc = -EIO; |
1723 | common->next_buffhd_to_fill = bh->next; | 1701 | common->next_buffhd_to_fill = bh->next; |
1724 | if (common->fsg) | 1702 | if (common->can_stall) |
1725 | rc = halt_bulk_in_endpoint(common->fsg); | 1703 | rc = halt_bulk_in_endpoint(common->fsg); |
1726 | } else if (fsg_is_set(common)) { | ||
1727 | rc = pad_with_zeros(common->fsg); | ||
1728 | } else { | ||
1729 | /* Don't know what to do if common->fsg is NULL */ | ||
1730 | rc = -EIO; | ||
1731 | } | 1704 | } |
1732 | break; | 1705 | break; |
1733 | 1706 | ||
@@ -2800,6 +2773,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, | |||
2800 | for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun, ++lcfg) { | 2773 | for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun, ++lcfg) { |
2801 | curlun->cdrom = !!lcfg->cdrom; | 2774 | curlun->cdrom = !!lcfg->cdrom; |
2802 | curlun->ro = lcfg->cdrom || lcfg->ro; | 2775 | curlun->ro = lcfg->cdrom || lcfg->ro; |
2776 | curlun->initially_ro = curlun->ro; | ||
2803 | curlun->removable = lcfg->removable; | 2777 | curlun->removable = lcfg->removable; |
2804 | curlun->dev.release = fsg_lun_release; | 2778 | curlun->dev.release = fsg_lun_release; |
2805 | curlun->dev.parent = &gadget->dev; | 2779 | curlun->dev.parent = &gadget->dev; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index a6eacb59571b..fcfc77c7ad70 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -1947,37 +1947,6 @@ static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) | |||
1947 | return rc; | 1947 | return rc; |
1948 | } | 1948 | } |
1949 | 1949 | ||
1950 | static int pad_with_zeros(struct fsg_dev *fsg) | ||
1951 | { | ||
1952 | struct fsg_buffhd *bh = fsg->next_buffhd_to_fill; | ||
1953 | u32 nkeep = bh->inreq->length; | ||
1954 | u32 nsend; | ||
1955 | int rc; | ||
1956 | |||
1957 | bh->state = BUF_STATE_EMPTY; // For the first iteration | ||
1958 | fsg->usb_amount_left = nkeep + fsg->residue; | ||
1959 | while (fsg->usb_amount_left > 0) { | ||
1960 | |||
1961 | /* Wait for the next buffer to be free */ | ||
1962 | while (bh->state != BUF_STATE_EMPTY) { | ||
1963 | rc = sleep_thread(fsg); | ||
1964 | if (rc) | ||
1965 | return rc; | ||
1966 | } | ||
1967 | |||
1968 | nsend = min(fsg->usb_amount_left, (u32) mod_data.buflen); | ||
1969 | memset(bh->buf + nkeep, 0, nsend - nkeep); | ||
1970 | bh->inreq->length = nsend; | ||
1971 | bh->inreq->zero = 0; | ||
1972 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
1973 | &bh->inreq_busy, &bh->state); | ||
1974 | bh = fsg->next_buffhd_to_fill = bh->next; | ||
1975 | fsg->usb_amount_left -= nsend; | ||
1976 | nkeep = 0; | ||
1977 | } | ||
1978 | return 0; | ||
1979 | } | ||
1980 | |||
1981 | static int throw_away_data(struct fsg_dev *fsg) | 1950 | static int throw_away_data(struct fsg_dev *fsg) |
1982 | { | 1951 | { |
1983 | struct fsg_buffhd *bh; | 1952 | struct fsg_buffhd *bh; |
@@ -2082,18 +2051,20 @@ static int finish_reply(struct fsg_dev *fsg) | |||
2082 | } | 2051 | } |
2083 | } | 2052 | } |
2084 | 2053 | ||
2085 | /* For Bulk-only, if we're allowed to stall then send the | 2054 | /* |
2086 | * short packet and halt the bulk-in endpoint. If we can't | 2055 | * For Bulk-only, mark the end of the data with a short |
2087 | * stall, pad out the remaining data with 0's. */ | 2056 | * packet. If we are allowed to stall, halt the bulk-in |
2057 | * endpoint. (Note: This violates the Bulk-Only Transport | ||
2058 | * specification, which requires us to pad the data if we | ||
2059 | * don't halt the endpoint. Presumably nobody will mind.) | ||
2060 | */ | ||
2088 | else { | 2061 | else { |
2089 | if (mod_data.can_stall) { | 2062 | bh->inreq->zero = 1; |
2090 | bh->inreq->zero = 1; | 2063 | start_transfer(fsg, fsg->bulk_in, bh->inreq, |
2091 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | 2064 | &bh->inreq_busy, &bh->state); |
2092 | &bh->inreq_busy, &bh->state); | 2065 | fsg->next_buffhd_to_fill = bh->next; |
2093 | fsg->next_buffhd_to_fill = bh->next; | 2066 | if (mod_data.can_stall) |
2094 | rc = halt_bulk_in_endpoint(fsg); | 2067 | rc = halt_bulk_in_endpoint(fsg); |
2095 | } else | ||
2096 | rc = pad_with_zeros(fsg); | ||
2097 | } | 2068 | } |
2098 | break; | 2069 | break; |
2099 | 2070 | ||
diff --git a/drivers/usb/gadget/fsl_qe_udc.h b/drivers/usb/gadget/fsl_qe_udc.h index e35e24fd64bb..1da5fb03d218 100644 --- a/drivers/usb/gadget/fsl_qe_udc.h +++ b/drivers/usb/gadget/fsl_qe_udc.h | |||
@@ -207,7 +207,7 @@ struct qe_frame{ | |||
207 | 207 | ||
208 | /* Frame status field */ | 208 | /* Frame status field */ |
209 | /* Receive side */ | 209 | /* Receive side */ |
210 | #define FRAME_OK 0x00000000 /* Frame tranmitted or received OK */ | 210 | #define FRAME_OK 0x00000000 /* Frame transmitted or received OK */ |
211 | #define FRAME_ERROR 0x80000000 /* Error occurred on frame */ | 211 | #define FRAME_ERROR 0x80000000 /* Error occurred on frame */ |
212 | #define START_FRAME_LOST 0x40000000 /* START_FRAME_LOST */ | 212 | #define START_FRAME_LOST 0x40000000 /* START_FRAME_LOST */ |
213 | #define END_FRAME_LOST 0x20000000 /* END_FRAME_LOST */ | 213 | #define END_FRAME_LOST 0x20000000 /* END_FRAME_LOST */ |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index e896f6359dfe..ec3fd979c71d 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h | |||
@@ -148,6 +148,12 @@ | |||
148 | #define gadget_is_ci13xxx_msm(g) 0 | 148 | #define gadget_is_ci13xxx_msm(g) 0 |
149 | #endif | 149 | #endif |
150 | 150 | ||
151 | #ifdef CONFIG_USB_GADGET_RENESAS_USBHS | ||
152 | #define gadget_is_renesas_usbhs(g) (!strcmp("renesas_usbhs_udc", (g)->name)) | ||
153 | #else | ||
154 | #define gadget_is_renesas_usbhs(g) 0 | ||
155 | #endif | ||
156 | |||
151 | /** | 157 | /** |
152 | * usb_gadget_controller_number - support bcdDevice id convention | 158 | * usb_gadget_controller_number - support bcdDevice id convention |
153 | * @gadget: the controller being driven | 159 | * @gadget: the controller being driven |
@@ -207,6 +213,9 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |||
207 | return 0x27; | 213 | return 0x27; |
208 | else if (gadget_is_ci13xxx_msm(gadget)) | 214 | else if (gadget_is_ci13xxx_msm(gadget)) |
209 | return 0x28; | 215 | return 0x28; |
216 | else if (gadget_is_renesas_usbhs(gadget)) | ||
217 | return 0x29; | ||
218 | |||
210 | return -ENOENT; | 219 | return -ENOENT; |
211 | } | 220 | } |
212 | 221 | ||
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index b015561fd602..109635a84888 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -711,10 +711,11 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, | |||
711 | ssize_t rc = count; | 711 | ssize_t rc = count; |
712 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | 712 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); |
713 | struct rw_semaphore *filesem = dev_get_drvdata(dev); | 713 | struct rw_semaphore *filesem = dev_get_drvdata(dev); |
714 | unsigned long ro; | 714 | unsigned ro; |
715 | 715 | ||
716 | if (strict_strtoul(buf, 2, &ro)) | 716 | rc = kstrtouint(buf, 2, &ro); |
717 | return -EINVAL; | 717 | if (rc) |
718 | return rc; | ||
718 | 719 | ||
719 | /* | 720 | /* |
720 | * Allow the write-enable status to change only while the | 721 | * Allow the write-enable status to change only while the |
@@ -738,10 +739,12 @@ static ssize_t fsg_store_nofua(struct device *dev, | |||
738 | const char *buf, size_t count) | 739 | const char *buf, size_t count) |
739 | { | 740 | { |
740 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); | 741 | struct fsg_lun *curlun = fsg_lun_from_dev(dev); |
741 | unsigned long nofua; | 742 | unsigned nofua; |
743 | int ret; | ||
742 | 744 | ||
743 | if (strict_strtoul(buf, 2, &nofua)) | 745 | ret = kstrtouint(buf, 2, &nofua); |
744 | return -EINVAL; | 746 | if (ret) |
747 | return ret; | ||
745 | 748 | ||
746 | /* Sync data when switching from async mode to sync */ | 749 | /* Sync data when switching from async mode to sync */ |
747 | if (!nofua && curlun->nofua) | 750 | if (!nofua && curlun->nofua) |