diff options
author | Marek Vasut <marex@denx.de> | 2013-07-10 03:16:41 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2013-07-29 23:01:33 +0200 |
commit | ede709c0d293d980ceb6596132aa39941e3e1c7f (patch) | |
tree | ae5dc96a10392d58e2252804f1b614c3f4df51ed /drivers | |
parent | 8a095a68ce8e7989dec6af4011f0f41bbc554f22 (diff) | |
download | u-boot-imx-ede709c0d293d980ceb6596132aa39941e3e1c7f.zip u-boot-imx-ede709c0d293d980ceb6596132aa39941e3e1c7f.tar.gz u-boot-imx-ede709c0d293d980ceb6596132aa39941e3e1c7f.tar.bz2 |
usb: mv_udc: Implement better qTD item accessor
The code for retrieving qTD item for particular endpoint is hard
to understand, moreover it's duplicated all over the driver. Move
the code into single nice and documented function.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Lei Wen <leiwen@marvell.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/mv_udc.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c index dbdf878..9ec575a 100644 --- a/drivers/usb/gadget/mv_udc.c +++ b/drivers/usb/gadget/mv_udc.c @@ -123,6 +123,19 @@ static struct ept_queue_head *mv_get_qh(int ep_num, int dir_in) return &controller.epts[(ep_num * 2) + dir_in]; } +/** + * mv_get_qtd() - return queue item for endpoint + * @ep_num: Endpoint number + * @dir_in: Direction of the endpoint (IN = 1, OUT = 0) + * + * This function returns the QH associated with particular endpoint + * and it's direction. + */ +static struct ept_queue_item *mv_get_qtd(int ep_num, int dir_in) +{ + return controller.items[(ep_num * 2) + dir_in]; +} + static struct usb_request * mv_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags) { @@ -181,7 +194,7 @@ static int mv_ep_queue(struct usb_ep *ep, int bit, num, len, in; num = mv_ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; in = (mv_ep->desc->bEndpointAddress & USB_DIR_IN) != 0; - item = controller.items[2 * num + in]; + item = mv_get_qtd(num, in); head = mv_get_qh(num, in); phys = (unsigned)req->buf; len = req->length; @@ -217,7 +230,7 @@ static void handle_ep_complete(struct mv_ep *ep) in = (ep->desc->bEndpointAddress & USB_DIR_IN) != 0; if (num == 0) ep->desc = &ep0_out_desc; - item = controller.items[2 * num + in]; + item = mv_get_qtd(num, in); if (item->info & 0xff) printf("EP%d/%s FAIL nfo=%x pg0=%x\n", |