From patchwork Fri Aug 7 02:46:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 258923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B900FC433E0 for ; Fri, 7 Aug 2020 02:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93AFE2075A for ; Fri, 7 Aug 2020 02:46:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="MUPiXwI6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbgHGCqc (ORCPT ); Thu, 6 Aug 2020 22:46:32 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:58166 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgHGCqb (ORCPT ); Thu, 6 Aug 2020 22:46:31 -0400 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 0853FC0C28; Fri, 7 Aug 2020 02:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1596768391; bh=HKTcfx7fgfr/QBBN5dB5SuLBdfs3r0af/HkOfZtBRsI=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=MUPiXwI6BSKhyEMrwhy4qTh/IbAPxx4ski+mXjKVb5zP12USt4UxqlQJm4hCtWovD DQgfoJn4/XqrELvjTZesrBw7LmS4u09S5MR7D5qVqDxy6CldUdC67DKV/auVjoQSpN J9RbEl5x+Csl3geIpNINwazWy2817gnXUYZm6t6L3htlG5U9Mg4G5O41d1e8GlCsj9 NVe4n15JkeFhmrzpV5UIbtMKOc5dz29ye6H6CNfDEQkPXmaghbyOYIU2W0gi8rAIDX lRMb/4tqJPzdo2JzKMziBO1Ajemb0b46YcN3wO1vSiUt9pDioqz/JLEvUvG9MyXlf0 txUkPD30fc3Gw== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 8EF53A006F; Fri, 7 Aug 2020 02:46:29 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Thu, 06 Aug 2020 19:46:29 -0700 Date: Thu, 06 Aug 2020 19:46:29 -0700 Message-Id: <14acf1f4680fbd9b8d6b60a748a17ee6a04380a8.1596767991.git.thinhn@synopsys.com> In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [PATCH v2 2/7] usb: dwc3: gadget: Fix handling ZLP To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn , stable@vger.kernel.org Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The usb_request->zero doesn't apply for isoc. Also, if we prepare a 0-length (ZLP) TRB for the OUT direction, we need to prepare an extra TRB to pad up to the MPS alignment. Use the same bounce buffer for the ZLP TRB and the extra pad TRB. Cc: stable@vger.kernel.org Fixes: d6e5a549cc4d ("usb: dwc3: simplify ZLP handling") Fixes: 04c03d10e507 ("usb: dwc3: gadget: handle request->zero") Signed-off-by: Thinh Nguyen --- Changes in v2: - None drivers/usb/dwc3/gadget.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f9231253cbed..df603a817a98 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1199,6 +1199,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, req->request.no_interrupt, req->request.is_last); } else if (req->request.zero && req->request.length && + !usb_endpoint_xfer_isoc(dep->endpoint.desc) && (IS_ALIGNED(req->request.length, maxp))) { struct dwc3 *dwc = dep->dwc; struct dwc3_trb *trb; @@ -1208,14 +1209,25 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, /* prepare normal TRB */ dwc3_prepare_one_trb(dep, req, length, true, 0); - /* Now prepare one extra TRB to handle ZLP */ + /* Prepare one extra TRB to handle ZLP */ trb = &dep->trb_pool[dep->trb_enqueue]; req->num_trbs++; __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, - false, 1, req->request.stream_id, + !req->direction, 1, req->request.stream_id, req->request.short_not_ok, req->request.no_interrupt, req->request.is_last); + + /* Prepare one more TRB to handle MPS alignment for OUT */ + if (!req->direction) { + trb = &dep->trb_pool[dep->trb_enqueue]; + req->num_trbs++; + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp, + false, 1, req->request.stream_id, + req->request.short_not_ok, + req->request.no_interrupt, + req->request.is_last); + } } else { dwc3_prepare_one_trb(dep, req, length, false, 0); } @@ -2690,8 +2702,17 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, status); if (req->needs_extra_trb) { + unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); + ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status); + + /* Reclaim MPS padding TRB for ZLP */ + if (!req->direction && req->request.zero && req->request.length && + !usb_endpoint_xfer_isoc(dep->endpoint.desc) && + (IS_ALIGNED(req->request.length, maxp))) + ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status); + req->needs_extra_trb = false; } From patchwork Fri Aug 7 02:46:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 258922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 916A3C433E0 for ; Fri, 7 Aug 2020 02:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 607CF2075A for ; Fri, 7 Aug 2020 02:46:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="RgDMWYz9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726360AbgHGCqn (ORCPT ); Thu, 6 Aug 2020 22:46:43 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.73.133]:57058 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgHGCqn (ORCPT ); Thu, 6 Aug 2020 22:46:43 -0400 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 38CF5408EF; Fri, 7 Aug 2020 02:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1596768403; bh=ufyB2NcX3NcnljOLeAZ+OhtuKlygkh9bGFnRdpUB4yk=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=RgDMWYz9wPtIsZ0y8SFu/+w1+JXMUSk1Yor+o/bkFV/K+00tt5pM4WesQ6uqLIiju Ek0v3mSHXdkgHfGoPCZVU/oXvn2wYpTi9UYrISDyaoO5O4J1BSm3suiDSEJQhYz6gZ 03vlzxQxHU2j+HKkVqiKygJByawgaDGolwNpU4FC0TDETxk7agZBaBH03AdqhAehRy kqkHEZ6W6OL7XlR0E1EY5T6GPoM3mJRZrxk63iQYOEBZT8OT00bOJD+zF5fN1Q93W1 uzbsFcTXemqCayc55TVC2KQaxxZnExTtNDzOuqjvW57zFtMNoqKqdFc2b89RxngRlo Cbi1HZLItx1/g== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id EF0A1A006F; Fri, 7 Aug 2020 02:46:41 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Thu, 06 Aug 2020 19:46:41 -0700 Date: Thu, 06 Aug 2020 19:46:41 -0700 Message-Id: <6f67c1a81052389225a95fbccec93b0af0151cf1.1596767991.git.thinhn@synopsys.com> In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [PATCH v2 4/7] usb: dwc3: gadget: Refactor preparing TRBs To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There are a lot of common codes for preparing SG and linear TRBs. Let's refactor them for easier read. No functional change here. Signed-off-by: Thinh Nguyen --- Changes in v2: - Remove unused variables rem and maxp drivers/usb/dwc3/gadget.c | 178 ++++++++++++++------------------------ 1 file changed, 67 insertions(+), 111 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c2a0f64f8d1e..f929810580bf 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1088,6 +1088,65 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, stream_id, short_not_ok, no_interrupt, is_last); } +/** + * dwc3_prepare_last_sg - prepare TRBs for the last SG entry + * @dep: The endpoint that the request belongs to + * @req: The request to prepare + * @entry_length: The last SG entry size + * @node: Indicates whether this is not the first entry (for isoc only) + */ +static void dwc3_prepare_last_sg(struct dwc3_ep *dep, + struct dwc3_request *req, + unsigned int entry_length, + unsigned int node) +{ + unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); + unsigned int rem = req->request.length % maxp; + unsigned int num_extra_trbs = 0; + unsigned int i; + bool do_zlp = false; + + if (!usb_endpoint_xfer_isoc(dep->endpoint.desc) && + req->request.zero && req->request.length && !rem) { + num_extra_trbs++; + do_zlp = true; + } + + if (!req->direction && (!req->request.length || rem || do_zlp)) + num_extra_trbs++; + + if (num_extra_trbs > 0) + req->needs_extra_trb = true; + + /* Prepare a normal TRB */ + dwc3_prepare_one_trb(dep, req, entry_length, req->needs_extra_trb, node); + + /* Prepare extra TRBs for ZLP and MPS OUT transfer alignment */ + for (i = 0; i < num_extra_trbs; i++) { + struct dwc3 *dwc = dep->dwc; + struct dwc3_trb *trb; + unsigned int extra_trb_length; + bool chain = true; + + if (do_zlp && !i) + extra_trb_length = 0; + else + extra_trb_length = maxp - rem; + + if (i == num_extra_trbs - 1) + chain = false; + + trb = &dep->trb_pool[dep->trb_enqueue]; + req->num_trbs++; + __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, + extra_trb_length, chain, 1, + req->request.stream_id, + req->request.short_not_ok, + req->request.no_interrupt, + req->request.is_last); + } +} + static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, struct dwc3_request *req) { @@ -1106,10 +1165,8 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, length -= sg_dma_len(s); for_each_sg(sg, s, remaining, i) { - unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); - unsigned int rem = length % maxp; unsigned int trb_length; - unsigned chain = true; + bool last_sg = false; trb_length = min_t(unsigned int, length, sg_dma_len(s)); @@ -1123,60 +1180,12 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, * mapped sg. */ if ((i == remaining - 1) || !length) - chain = false; + last_sg = true; - if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) { - struct dwc3 *dwc = dep->dwc; - struct dwc3_trb *trb; - - req->needs_extra_trb = true; - - /* prepare normal TRB */ - dwc3_prepare_one_trb(dep, req, trb_length, true, i); - - /* Now prepare one extra TRB to align transfer size */ - trb = &dep->trb_pool[dep->trb_enqueue]; - req->num_trbs++; - __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, - maxp - rem, false, 1, - req->request.stream_id, - req->request.short_not_ok, - req->request.no_interrupt, - req->request.is_last); - } else if (req->request.zero && req->request.length && - !usb_endpoint_xfer_isoc(dep->endpoint.desc) && - !rem && !chain) { - struct dwc3 *dwc = dep->dwc; - struct dwc3_trb *trb; - - req->needs_extra_trb = true; - - /* Prepare normal TRB */ - dwc3_prepare_one_trb(dep, req, trb_length, true, i); - - /* Prepare one extra TRB to handle ZLP */ - trb = &dep->trb_pool[dep->trb_enqueue]; - req->num_trbs++; - __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, - !req->direction, 1, - req->request.stream_id, - req->request.short_not_ok, - req->request.no_interrupt, - req->request.is_last); - - /* Prepare one more TRB to handle MPS alignment */ - if (!req->direction) { - trb = &dep->trb_pool[dep->trb_enqueue]; - req->num_trbs++; - __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp, - false, 1, req->request.stream_id, - req->request.short_not_ok, - req->request.no_interrupt, - req->request.is_last); - } - } else { - dwc3_prepare_one_trb(dep, req, trb_length, chain, i); - } + if (last_sg) + dwc3_prepare_last_sg(dep, req, trb_length, i); + else + dwc3_prepare_one_trb(dep, req, trb_length, 1, i); /* * There can be a situation where all sgs in sglist are not @@ -1185,7 +1194,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, * we have free trbs we can continue queuing from where we * previously stopped */ - if (chain) + if (!last_sg) req->start_sg = sg_next(s); req->num_queued_sgs++; @@ -1208,60 +1217,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, struct dwc3_request *req) { - unsigned int length = req->request.length; - unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); - unsigned int rem = length % maxp; - - if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) { - struct dwc3 *dwc = dep->dwc; - struct dwc3_trb *trb; - - req->needs_extra_trb = true; - - /* prepare normal TRB */ - dwc3_prepare_one_trb(dep, req, length, true, 0); - - /* Now prepare one extra TRB to align transfer size */ - trb = &dep->trb_pool[dep->trb_enqueue]; - req->num_trbs++; - __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem, - false, 1, req->request.stream_id, - req->request.short_not_ok, - req->request.no_interrupt, - req->request.is_last); - } else if (req->request.zero && req->request.length && - !usb_endpoint_xfer_isoc(dep->endpoint.desc) && - (IS_ALIGNED(req->request.length, maxp))) { - struct dwc3 *dwc = dep->dwc; - struct dwc3_trb *trb; - - req->needs_extra_trb = true; - - /* prepare normal TRB */ - dwc3_prepare_one_trb(dep, req, length, true, 0); - - /* Prepare one extra TRB to handle ZLP */ - trb = &dep->trb_pool[dep->trb_enqueue]; - req->num_trbs++; - __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0, - !req->direction, 1, req->request.stream_id, - req->request.short_not_ok, - req->request.no_interrupt, - req->request.is_last); - - /* Prepare one more TRB to handle MPS alignment for OUT */ - if (!req->direction) { - trb = &dep->trb_pool[dep->trb_enqueue]; - req->num_trbs++; - __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp, - false, 1, req->request.stream_id, - req->request.short_not_ok, - req->request.no_interrupt, - req->request.is_last); - } - } else { - dwc3_prepare_one_trb(dep, req, length, false, 0); - } + dwc3_prepare_last_sg(dep, req, req->request.length, 0); } /* From patchwork Fri Aug 7 02:46:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 258921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AEF6C433DF for ; Fri, 7 Aug 2020 02:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D77821744 for ; Fri, 7 Aug 2020 02:46:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="h6gxOn9I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726453AbgHGCqz (ORCPT ); Thu, 6 Aug 2020 22:46:55 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.73.133]:57070 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgHGCqz (ORCPT ); Thu, 6 Aug 2020 22:46:55 -0400 Received: from mailhost.synopsys.com (sv2-mailhost1.synopsys.com [10.205.2.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 3D574408EF; Fri, 7 Aug 2020 02:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1596768415; bh=NETiTmPFwyd0pBZY5f9RdybB0n5bkhMbDLqFbPP5nWE=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=h6gxOn9IUoEUd9gK4TNleXGwyUK1SKjspGfCkQvGUxZ3zqYu1c19HKg0UqLNC6mt1 +nj93OfyT8MlewDamEAE45OIKKblEl2mWPp75v/ozkqYp8OlKet45SzzWg8rN8tTNJ mr5ulATWgwbjYYznffRVhWd67KqN9saX03Cu6OfKGONgJF78WXnj4hHOCXI7OcoFNg DKr1aPvmXCGzVvBiCoQ+rb459fz9cmR2d2lifwDXp98ACVq1XlSkok0+lhEicIrZGC VKIMpMxzsmNpN5tWTQKoTcpz7E4DxB+HOpx7EnI+3NGISvV74QX5X9KK8Mb5pXcfcd 2x9R4ULJstd4g== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 24B9EA0096; Fri, 7 Aug 2020 02:46:54 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Thu, 06 Aug 2020 19:46:54 -0700 Date: Thu, 06 Aug 2020 19:46:54 -0700 Message-Id: <554c6d34c5936630bbe292114fad9c3322a7161e.1596767991.git.thinhn@synopsys.com> In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [PATCH v2 6/7] usb: dwc3: gadget: Rename misleading function names To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The functions dwc3_prepare_one_trb_sg and dwc3_prepare_one_trb_linear are not necessarily preparing "one" TRB, it can prepare multiple TRBs. Rename these functions as follow: dwc3_prepare_one_trb_sg -> dwc3_prepare_trbs_sg dwc3_prepare_one_trb_linear -> dwc3_prepare_trbs_linear Signed-off-by: Thinh Nguyen --- Changes in v2: - None drivers/usb/dwc3/gadget.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 138f1b96bdf7..24cc4f2c2e1b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1161,7 +1161,7 @@ static int dwc3_prepare_last_sg(struct dwc3_ep *dep, return 0; } -static int dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, +static int dwc3_prepare_trbs_sg(struct dwc3_ep *dep, struct dwc3_request *req) { struct scatterlist *sg = req->start_sg; @@ -1231,7 +1231,7 @@ static int dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, return 0; } -static int dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, +static int dwc3_prepare_trbs_linear(struct dwc3_ep *dep, struct dwc3_request *req) { return dwc3_prepare_last_sg(dep, req, req->request.length, 0); @@ -1266,7 +1266,7 @@ static int dwc3_prepare_trbs(struct dwc3_ep *dep) */ list_for_each_entry(req, &dep->started_list, list) { if (req->num_pending_sgs > 0) { - ret = dwc3_prepare_one_trb_sg(dep, req); + ret = dwc3_prepare_trbs_sg(dep, req); if (ret) return ret; } @@ -1294,9 +1294,9 @@ static int dwc3_prepare_trbs(struct dwc3_ep *dep) req->num_pending_sgs = req->request.num_mapped_sgs; if (req->num_pending_sgs > 0) - ret = dwc3_prepare_one_trb_sg(dep, req); + ret = dwc3_prepare_trbs_sg(dep, req); else - ret = dwc3_prepare_one_trb_linear(dep, req); + ret = dwc3_prepare_trbs_linear(dep, req); if (ret) return ret;