diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2012-05-04 09:47:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-08 12:27:56 -0400 |
commit | d36ade60e3cc212992f001d2046815b068073c0c (patch) | |
tree | acd53eecfa37eab33a96d42532190ee874a7bdab /drivers/usb/gadget | |
parent | efa015bbc410198a192cd3e504ce24104e8c8852 (diff) |
usb: gadget: ci13xxx: initialize ep0{out,in} dynamically
Change ep0{out,in} macros into dynamically assigned pointers in
gadget initialization time.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/ci13xxx_udc.c | 48 | ||||
-rw-r--r-- | drivers/usb/gadget/ci13xxx_udc.h | 3 |
2 files changed, 30 insertions, 21 deletions
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index b6f359ce157d..b44c83d90c0e 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c | |||
@@ -1650,8 +1650,8 @@ static int _gadget_stop_activity(struct usb_gadget *gadget) | |||
1650 | gadget_for_each_ep(ep, gadget) { | 1650 | gadget_for_each_ep(ep, gadget) { |
1651 | usb_ep_fifo_flush(ep); | 1651 | usb_ep_fifo_flush(ep); |
1652 | } | 1652 | } |
1653 | usb_ep_fifo_flush(&udc->ep0out.ep); | 1653 | usb_ep_fifo_flush(&udc->ep0out->ep); |
1654 | usb_ep_fifo_flush(&udc->ep0in.ep); | 1654 | usb_ep_fifo_flush(&udc->ep0in->ep); |
1655 | 1655 | ||
1656 | udc->driver->disconnect(gadget); | 1656 | udc->driver->disconnect(gadget); |
1657 | 1657 | ||
@@ -1661,7 +1661,7 @@ static int _gadget_stop_activity(struct usb_gadget *gadget) | |||
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | if (udc->status != NULL) { | 1663 | if (udc->status != NULL) { |
1664 | usb_ep_free_request(&udc->ep0in.ep, udc->status); | 1664 | usb_ep_free_request(&udc->ep0in->ep, udc->status); |
1665 | udc->status = NULL; | 1665 | udc->status = NULL; |
1666 | } | 1666 | } |
1667 | 1667 | ||
@@ -1701,7 +1701,7 @@ __acquires(udc->lock) | |||
1701 | if (retval) | 1701 | if (retval) |
1702 | goto done; | 1702 | goto done; |
1703 | 1703 | ||
1704 | udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC); | 1704 | udc->status = usb_ep_alloc_request(&udc->ep0in->ep, GFP_ATOMIC); |
1705 | if (udc->status == NULL) | 1705 | if (udc->status == NULL) |
1706 | retval = -ENOMEM; | 1706 | retval = -ENOMEM; |
1707 | 1707 | ||
@@ -1744,7 +1744,7 @@ static int isr_get_status_response(struct ci13xxx *udc, | |||
1744 | __releases(mEp->lock) | 1744 | __releases(mEp->lock) |
1745 | __acquires(mEp->lock) | 1745 | __acquires(mEp->lock) |
1746 | { | 1746 | { |
1747 | struct ci13xxx_ep *mEp = &udc->ep0in; | 1747 | struct ci13xxx_ep *mEp = udc->ep0in; |
1748 | struct usb_request *req = NULL; | 1748 | struct usb_request *req = NULL; |
1749 | gfp_t gfp_flags = GFP_ATOMIC; | 1749 | gfp_t gfp_flags = GFP_ATOMIC; |
1750 | int dir, num, retval; | 1750 | int dir, num, retval; |
@@ -1835,7 +1835,7 @@ __acquires(mEp->lock) | |||
1835 | 1835 | ||
1836 | trace("%p", udc); | 1836 | trace("%p", udc); |
1837 | 1837 | ||
1838 | mEp = (udc->ep0_dir == TX) ? &udc->ep0out : &udc->ep0in; | 1838 | mEp = (udc->ep0_dir == TX) ? udc->ep0out : udc->ep0in; |
1839 | udc->status->context = udc; | 1839 | udc->status->context = udc; |
1840 | udc->status->complete = isr_setup_status_complete; | 1840 | udc->status->complete = isr_setup_status_complete; |
1841 | 1841 | ||
@@ -1877,7 +1877,7 @@ __acquires(mEp->lock) | |||
1877 | spin_unlock(mEp->lock); | 1877 | spin_unlock(mEp->lock); |
1878 | if ((mEp->type == USB_ENDPOINT_XFER_CONTROL) && | 1878 | if ((mEp->type == USB_ENDPOINT_XFER_CONTROL) && |
1879 | mReq->req.length) | 1879 | mReq->req.length) |
1880 | mEpTemp = &_udc->ep0in; | 1880 | mEpTemp = _udc->ep0in; |
1881 | mReq->req.complete(&mEpTemp->ep, &mReq->req); | 1881 | mReq->req.complete(&mEpTemp->ep, &mReq->req); |
1882 | spin_lock(mEp->lock); | 1882 | spin_lock(mEp->lock); |
1883 | } | 1883 | } |
@@ -1950,8 +1950,8 @@ __acquires(udc->lock) | |||
1950 | * Flush data and handshake transactions of previous | 1950 | * Flush data and handshake transactions of previous |
1951 | * setup packet. | 1951 | * setup packet. |
1952 | */ | 1952 | */ |
1953 | _ep_nuke(&udc->ep0out); | 1953 | _ep_nuke(udc->ep0out); |
1954 | _ep_nuke(&udc->ep0in); | 1954 | _ep_nuke(udc->ep0in); |
1955 | 1955 | ||
1956 | /* read_setup_packet */ | 1956 | /* read_setup_packet */ |
1957 | do { | 1957 | do { |
@@ -2279,7 +2279,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req, | |||
2279 | if (mEp->type == USB_ENDPOINT_XFER_CONTROL) { | 2279 | if (mEp->type == USB_ENDPOINT_XFER_CONTROL) { |
2280 | if (req->length) | 2280 | if (req->length) |
2281 | mEp = (_udc->ep0_dir == RX) ? | 2281 | mEp = (_udc->ep0_dir == RX) ? |
2282 | &_udc->ep0out : &_udc->ep0in; | 2282 | _udc->ep0out : _udc->ep0in; |
2283 | if (!list_empty(&mEp->qh.queue)) { | 2283 | if (!list_empty(&mEp->qh.queue)) { |
2284 | _ep_nuke(mEp); | 2284 | _ep_nuke(mEp); |
2285 | retval = -EOVERFLOW; | 2285 | retval = -EOVERFLOW; |
@@ -2496,7 +2496,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active) | |||
2496 | if (is_active) { | 2496 | if (is_active) { |
2497 | pm_runtime_get_sync(&_gadget->dev); | 2497 | pm_runtime_get_sync(&_gadget->dev); |
2498 | hw_device_reset(udc); | 2498 | hw_device_reset(udc); |
2499 | hw_device_state(udc->ep0out.qh.dma); | 2499 | hw_device_state(udc->ep0out->qh.dma); |
2500 | } else { | 2500 | } else { |
2501 | hw_device_state(0); | 2501 | hw_device_state(0); |
2502 | if (udc->udc_driver->notify_event) | 2502 | if (udc->udc_driver->notify_event) |
@@ -2637,28 +2637,38 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, | |||
2637 | else | 2637 | else |
2638 | memset(mEp->qh.ptr, 0, sizeof(*mEp->qh.ptr)); | 2638 | memset(mEp->qh.ptr, 0, sizeof(*mEp->qh.ptr)); |
2639 | 2639 | ||
2640 | /* skip ep0 out and in endpoints */ | 2640 | /* |
2641 | if (i == 0) | 2641 | * set up shorthands for ep0 out and in endpoints, |
2642 | * don't add to gadget's ep_list | ||
2643 | */ | ||
2644 | if (i == 0) { | ||
2645 | if (j == RX) | ||
2646 | udc->ep0out = mEp; | ||
2647 | else | ||
2648 | udc->ep0in = mEp; | ||
2649 | |||
2642 | continue; | 2650 | continue; |
2651 | } | ||
2643 | 2652 | ||
2644 | list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list); | 2653 | list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list); |
2645 | } | 2654 | } |
2646 | } | 2655 | } |
2647 | if (retval) | 2656 | if (retval) |
2648 | goto done; | 2657 | goto done; |
2658 | |||
2649 | spin_unlock_irqrestore(udc->lock, flags); | 2659 | spin_unlock_irqrestore(udc->lock, flags); |
2650 | udc->ep0out.ep.desc = &ctrl_endpt_out_desc; | 2660 | udc->ep0out->ep.desc = &ctrl_endpt_out_desc; |
2651 | retval = usb_ep_enable(&udc->ep0out.ep); | 2661 | retval = usb_ep_enable(&udc->ep0out->ep); |
2652 | if (retval) | 2662 | if (retval) |
2653 | return retval; | 2663 | return retval; |
2654 | 2664 | ||
2655 | udc->ep0in.ep.desc = &ctrl_endpt_in_desc; | 2665 | udc->ep0in->ep.desc = &ctrl_endpt_in_desc; |
2656 | retval = usb_ep_enable(&udc->ep0in.ep); | 2666 | retval = usb_ep_enable(&udc->ep0in->ep); |
2657 | if (retval) | 2667 | if (retval) |
2658 | return retval; | 2668 | return retval; |
2659 | spin_lock_irqsave(udc->lock, flags); | 2669 | spin_lock_irqsave(udc->lock, flags); |
2660 | 2670 | ||
2661 | udc->gadget.ep0 = &udc->ep0in.ep; | 2671 | udc->gadget.ep0 = &udc->ep0in->ep; |
2662 | /* bind gadget */ | 2672 | /* bind gadget */ |
2663 | driver->driver.bus = NULL; | 2673 | driver->driver.bus = NULL; |
2664 | udc->gadget.dev.driver = &driver->driver; | 2674 | udc->gadget.dev.driver = &driver->driver; |
@@ -2684,7 +2694,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, | |||
2684 | } | 2694 | } |
2685 | } | 2695 | } |
2686 | 2696 | ||
2687 | retval = hw_device_state(udc->ep0out.qh.dma); | 2697 | retval = hw_device_state(udc->ep0out->qh.dma); |
2688 | if (retval) | 2698 | if (retval) |
2689 | pm_runtime_put_sync(&udc->gadget.dev); | 2699 | pm_runtime_put_sync(&udc->gadget.dev); |
2690 | 2700 | ||
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h index 6490cf872adb..d6dbaad9c906 100644 --- a/drivers/usb/gadget/ci13xxx_udc.h +++ b/drivers/usb/gadget/ci13xxx_udc.h | |||
@@ -125,8 +125,7 @@ struct ci13xxx { | |||
125 | struct usb_gadget gadget; /* USB slave device */ | 125 | struct usb_gadget gadget; /* USB slave device */ |
126 | struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ | 126 | struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ |
127 | u32 ep0_dir; /* ep0 direction */ | 127 | u32 ep0_dir; /* ep0 direction */ |
128 | #define ep0out ci13xxx_ep[0] | 128 | struct ci13xxx_ep *ep0out, *ep0in; |
129 | #define ep0in ci13xxx_ep[hw_ep_max / 2] | ||
130 | u8 remote_wakeup; /* Is remote wakeup feature | 129 | u8 remote_wakeup; /* Is remote wakeup feature |
131 | enabled by the host? */ | 130 | enabled by the host? */ |
132 | u8 suspended; /* suspended by the host */ | 131 | u8 suspended; /* suspended by the host */ |