From patchwork Wed Jul 10 01:16:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 257946 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 28B2B2C0209 for ; Wed, 10 Jul 2013 11:20:22 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 55FC64A141; Wed, 10 Jul 2013 03:19:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id py2C6RZ4b-tp; Wed, 10 Jul 2013 03:19:05 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C3BF4A143; Wed, 10 Jul 2013 03:17:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E44AF4A0A9 for ; Wed, 10 Jul 2013 03:17:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PjSyrR65OSRS for ; Wed, 10 Jul 2013 03:17:17 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTPS id B4FA64A0AE for ; Wed, 10 Jul 2013 03:17:01 +0200 (CEST) Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3bqjD36lbrz4KK6x; Wed, 10 Jul 2013 03:16:51 +0200 (CEST) X-Auth-Info: DdgwmNIa4pGoUF7pK801EyXiROSoE5qoV4QYvep10Ro= Received: from mashiro.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3bqjD354hDzbbhB; Wed, 10 Jul 2013 03:16:51 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Wed, 10 Jul 2013 03:16:41 +0200 Message-Id: <1373419003-10919-16-git-send-email-marex@denx.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373419003-10919-1-git-send-email-marex@denx.de> References: <1373419003-10919-1-git-send-email-marex@denx.de> Cc: Marek Vasut , Fabio Estevam , Otavio Salvador , Lei Wen Subject: [U-Boot] [PATCH 15/17] usb: mv_udc: Implement better qTD item accessor X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Cc: Fabio Estevam Cc: Lei Wen Cc: Otavio Salvador Cc: Stefano Babic --- drivers/usb/gadget/mv_udc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c index 55dd5df..364c8ed 100644 --- a/drivers/usb/gadget/mv_udc.c +++ b/drivers/usb/gadget/mv_udc.c @@ -139,6 +139,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) { @@ -197,7 +210,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; @@ -233,7 +246,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",