aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-05-05 09:21:59 -0400
committerFelipe Balbi <balbi@ti.com>2013-03-18 05:18:02 -0400
commit6a1e3ef45fb0c4d79cbb5190c8fc59263c630b0e (patch)
treebdae74e5a79fcedf2521c4faeaa04ca15710913b /drivers
parent789451f6c698282d0745f265bde47173c9372867 (diff)
usb: dwc3: gadget: use num_(in|out)_eps from HW params
that way we will only tell gadget framework about the endpoints we actually have. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/dwc3/gadget.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 8e53acc0e43e..2b6e7e001207 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1623,14 +1623,15 @@ static const struct usb_gadget_ops dwc3_gadget_ops = {
1623 1623
1624/* -------------------------------------------------------------------------- */ 1624/* -------------------------------------------------------------------------- */
1625 1625
1626static int dwc3_gadget_init_endpoints(struct dwc3 *dwc) 1626static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
1627 u8 num, u32 direction)
1627{ 1628{
1628 struct dwc3_ep *dep; 1629 struct dwc3_ep *dep;
1629 u8 epnum; 1630 u8 i;
1630 1631
1631 INIT_LIST_HEAD(&dwc->gadget.ep_list); 1632 for (i = 0; i < num; i++) {
1633 u8 epnum = (i << 1) | (!!direction);
1632 1634
1633 for (epnum = 0; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
1634 dep = kzalloc(sizeof(*dep), GFP_KERNEL); 1635 dep = kzalloc(sizeof(*dep), GFP_KERNEL);
1635 if (!dep) { 1636 if (!dep) {
1636 dev_err(dwc->dev, "can't allocate endpoint %d\n", 1637 dev_err(dwc->dev, "can't allocate endpoint %d\n",
@@ -1644,6 +1645,7 @@ static int dwc3_gadget_init_endpoints(struct dwc3 *dwc)
1644 1645
1645 snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1, 1646 snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1,
1646 (epnum & 1) ? "in" : "out"); 1647 (epnum & 1) ? "in" : "out");
1648
1647 dep->endpoint.name = dep->name; 1649 dep->endpoint.name = dep->name;
1648 dep->direction = (epnum & 1); 1650 dep->direction = (epnum & 1);
1649 1651
@@ -1674,6 +1676,27 @@ static int dwc3_gadget_init_endpoints(struct dwc3 *dwc)
1674 return 0; 1676 return 0;
1675} 1677}
1676 1678
1679static int dwc3_gadget_init_endpoints(struct dwc3 *dwc)
1680{
1681 int ret;
1682
1683 INIT_LIST_HEAD(&dwc->gadget.ep_list);
1684
1685 ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_out_eps, 0);
1686 if (ret < 0) {
1687 dev_vdbg(dwc->dev, "failed to allocate OUT endpoints\n");
1688 return ret;
1689 }
1690
1691 ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_in_eps, 1);
1692 if (ret < 0) {
1693 dev_vdbg(dwc->dev, "failed to allocate IN endpoints\n");
1694 return ret;
1695 }
1696
1697 return 0;
1698}
1699
1677static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) 1700static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
1678{ 1701{
1679 struct dwc3_ep *dep; 1702 struct dwc3_ep *dep;
@@ -1681,6 +1704,9 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
1681 1704
1682 for (epnum = 0; epnum < DWC3_ENDPOINTS_NUM; epnum++) { 1705 for (epnum = 0; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
1683 dep = dwc->eps[epnum]; 1706 dep = dwc->eps[epnum];
1707 if (!dep)
1708 continue;
1709
1684 dwc3_free_trb_pool(dep); 1710 dwc3_free_trb_pool(dep);
1685 1711
1686 if (epnum != 0 && epnum != 1) 1712 if (epnum != 0 && epnum != 1)
@@ -2015,6 +2041,9 @@ static void dwc3_stop_active_transfers(struct dwc3 *dwc)
2015 struct dwc3_ep *dep; 2041 struct dwc3_ep *dep;
2016 2042
2017 dep = dwc->eps[epnum]; 2043 dep = dwc->eps[epnum];
2044 if (!dep)
2045 continue;
2046
2018 if (!(dep->flags & DWC3_EP_ENABLED)) 2047 if (!(dep->flags & DWC3_EP_ENABLED))
2019 continue; 2048 continue;
2020 2049
@@ -2032,6 +2061,8 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
2032 int ret; 2061 int ret;
2033 2062
2034 dep = dwc->eps[epnum]; 2063 dep = dwc->eps[epnum];
2064 if (!dep)
2065 continue;
2035 2066
2036 if (!(dep->flags & DWC3_EP_STALL)) 2067 if (!(dep->flags & DWC3_EP_STALL))
2037 continue; 2068 continue;