From nobody Mon Sep 29 21:15:50 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10FD1C3276C for ; Mon, 15 Aug 2022 22:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351065AbiHOW1c (ORCPT ); Mon, 15 Aug 2022 18:27:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349016AbiHOWV1 (ORCPT ); Mon, 15 Aug 2022 18:21:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30FE19C1E5; Mon, 15 Aug 2022 12:43:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 263CA61089; Mon, 15 Aug 2022 19:43:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24AB8C433D7; Mon, 15 Aug 2022 19:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592617; bh=iRBxce8yUOxLWUqTwqXzGzLqt4POlYqXSO1YXOmuWfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mc3DoKZ3dEwoTSIt5v69db87nt1RjLghXkKPSO5jdGLXLjNAwYmAxJumql7k+8Nto ADPy3POmOVZHan6IQjRSE97ZE7PaktwijozaprXWq4yGmuyvkuOwa4pbW8abSvwzwk cD/gLdqyisCTkaTvVFkU37U8SZFnUN4lRYjT0tlI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Michael Grzeschik Subject: [PATCH 5.19 0138/1157] usb: dwc3: gadget: refactor dwc3_repare_one_trb Date: Mon, 15 Aug 2022 19:51:34 +0200 Message-Id: <20220815180445.158682479@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Michael Grzeschik commit 23385cec5f354794dadced7f28c31da7ae3eb54c upstream. The function __dwc3_prepare_one_trb has many parameters. Since it is only used in dwc3_prepare_one_trb there is no point in keeping the function. We merge both functions and get rid of the big list of parameters. Fixes: 40d829fb2ec6 ("usb: dwc3: gadget: Correct ISOC DATA PIDs for short p= ackets") Cc: stable Signed-off-by: Michael Grzeschik Link: https://lore.kernel.org/r/20220704141812.1532306-2-m.grzeschik@pengut= ronix.de Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 92 ++++++++++++++++++++---------------------= ----- 1 file changed, 40 insertions(+), 52 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1182,17 +1182,49 @@ static u32 dwc3_calc_trbs_left(struct dw return trbs_left; } =20 -static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *t= rb, - dma_addr_t dma, unsigned int length, unsigned int chain, - unsigned int node, unsigned int stream_id, - unsigned int short_not_ok, unsigned int no_interrupt, - unsigned int is_last, bool must_interrupt) +/** + * dwc3_prepare_one_trb - setup one TRB from one request + * @dep: endpoint for which this request is prepared + * @req: dwc3_request pointer + * @trb_length: buffer size of the TRB + * @chain: should this TRB be chained to the next? + * @node: only for isochronous endpoints. First TRB needs different type. + * @use_bounce_buffer: set to use bounce buffer + * @must_interrupt: set to interrupt on TRB completion + */ +static void dwc3_prepare_one_trb(struct dwc3_ep *dep, + struct dwc3_request *req, unsigned int trb_length, + unsigned int chain, unsigned int node, bool use_bounce_buffer, + bool must_interrupt) { + struct dwc3_trb *trb; + dma_addr_t dma; + unsigned int stream_id =3D req->request.stream_id; + unsigned int short_not_ok =3D req->request.short_not_ok; + unsigned int no_interrupt =3D req->request.no_interrupt; + unsigned int is_last =3D req->request.is_last; struct dwc3 *dwc =3D dep->dwc; struct usb_gadget *gadget =3D dwc->gadget; enum usb_device_speed speed =3D gadget->speed; =20 - trb->size =3D DWC3_TRB_SIZE_LENGTH(length); + if (use_bounce_buffer) + dma =3D dep->dwc->bounce_addr; + else if (req->request.num_sgs > 0) + dma =3D sg_dma_address(req->start_sg); + else + dma =3D req->request.dma; + + trb =3D &dep->trb_pool[dep->trb_enqueue]; + + if (!req->trb) { + dwc3_gadget_move_started_request(req); + req->trb =3D trb; + req->trb_dma =3D dwc3_trb_dma_offset(dep, trb); + } + + req->num_trbs++; + + trb->size =3D DWC3_TRB_SIZE_LENGTH(trb_length); trb->bpl =3D lower_32_bits(dma); trb->bph =3D upper_32_bits(dma); =20 @@ -1232,10 +1264,10 @@ static void __dwc3_prepare_one_trb(struc unsigned int mult =3D 2; unsigned int maxp =3D usb_endpoint_maxp(ep->desc); =20 - if (length <=3D (2 * maxp)) + if (trb_length <=3D (2 * maxp)) mult--; =20 - if (length <=3D maxp) + if (trb_length <=3D maxp) mult--; =20 trb->size |=3D DWC3_TRB_SIZE_PCM1(mult); @@ -1309,50 +1341,6 @@ static void __dwc3_prepare_one_trb(struc trace_dwc3_prepare_trb(dep, trb); } =20 -/** - * dwc3_prepare_one_trb - setup one TRB from one request - * @dep: endpoint for which this request is prepared - * @req: dwc3_request pointer - * @trb_length: buffer size of the TRB - * @chain: should this TRB be chained to the next? - * @node: only for isochronous endpoints. First TRB needs different type. - * @use_bounce_buffer: set to use bounce buffer - * @must_interrupt: set to interrupt on TRB completion - */ -static void dwc3_prepare_one_trb(struct dwc3_ep *dep, - struct dwc3_request *req, unsigned int trb_length, - unsigned int chain, unsigned int node, bool use_bounce_buffer, - bool must_interrupt) -{ - struct dwc3_trb *trb; - dma_addr_t dma; - unsigned int stream_id =3D req->request.stream_id; - unsigned int short_not_ok =3D req->request.short_not_ok; - unsigned int no_interrupt =3D req->request.no_interrupt; - unsigned int is_last =3D req->request.is_last; - - if (use_bounce_buffer) - dma =3D dep->dwc->bounce_addr; - else if (req->request.num_sgs > 0) - dma =3D sg_dma_address(req->start_sg); - else - dma =3D req->request.dma; - - trb =3D &dep->trb_pool[dep->trb_enqueue]; - - if (!req->trb) { - dwc3_gadget_move_started_request(req); - req->trb =3D trb; - req->trb_dma =3D dwc3_trb_dma_offset(dep, trb); - } - - req->num_trbs++; - - __dwc3_prepare_one_trb(dep, trb, dma, trb_length, chain, node, - stream_id, short_not_ok, no_interrupt, is_last, - must_interrupt); -} - static bool dwc3_needs_extra_trb(struct dwc3_ep *dep, struct dwc3_request = *req) { unsigned int maxp =3D usb_endpoint_maxp(dep->endpoint.desc);