Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2924478rwb; Mon, 15 Aug 2022 14:09:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Xd/6WCqq4ZyxWahNX2kQqEiO1hg3ODPKFDWspuV7e2WD7utPrutb9freqT69IMme1Lc6S X-Received: by 2002:a50:ee85:0:b0:43d:3e0:6157 with SMTP id f5-20020a50ee85000000b0043d03e06157mr16448808edr.19.1660597767316; Mon, 15 Aug 2022 14:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597767; cv=none; d=google.com; s=arc-20160816; b=09cMg4Jg0562b2yn2SaQnjiLmz3gBDOW8C3M/pvVD7nft6xRZeV49ihbe2///F3m1F jnr+51/Fy4N8x4QrodLf2WGq5tWy83SC+u9cfr4Z74oqdJQoD6qeUZMaCwRK6YruP39E 68bbxI+N2Sv57ZneUkXkhYdE5igolWXvz2AUS+AEmbmW26dbj89E2/R82ClOuG2o6rGO 8lljr5zXab3HcLQ699Ng//0uvycLCUvmSeBUUyH4I709wtiiJnK7LlzqbLGVSWgRV7h3 J15+YypZVoDhdji3Wnc0qcbJYMu76Lam+8LndRtM3e+GI4f2GJf2d230U2EVJM5vUlhI cY/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SB7XinHZBKOfxy+TRP0Pp4xmvPM82uROjpfczhsbkkY=; b=cOy//Wn9nDryf/HzrfsevVGMU3EX+UcutIr02RpWnYebGa0qP46l0rTN/BHIxteB76 RNEX1jxIQXqoLHCsOritPTu6jQ8VBlikdfXWT5sOAy6iwxVcZ6+WrK/kj+/uiETGY8u0 yk4AQSr0weQyBsD8xacQYjk4cZ/GvZPkRTM14O/fN/yBcoS2EiurG/q9GKxe18qcC1MB a2AxtX2KW4Hv8LM4bEE+HEBupUQN0BMBJau+LUFbRsEzELIlDduyTazOwzb8BWlPm5sP ueFbO7rBptT52qRF4cKPp2ujqEE3/9j6GPe7RcWXAbL5+y2q60IikXJpCC3KYzY/pCYK bQ5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ze2Y664K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne18-20020a1709077b9200b0073086ecd585si8815778ejc.625.2022.08.15.14.09.01; Mon, 15 Aug 2022 14:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ze2Y664K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347737AbiHOU0d (ORCPT + 99 others); Mon, 15 Aug 2022 16:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346519AbiHOUUU (ORCPT ); Mon, 15 Aug 2022 16:20:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85E2997D50; Mon, 15 Aug 2022 12:00:54 -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 963136122B; Mon, 15 Aug 2022 19:00:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E544C433D7; Mon, 15 Aug 2022 19:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590053; bh=q6objEWJqQalE6qrNAA/Zzot4pb3FshImXwWMJLY6gM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ze2Y664KhBYGW1JCZoaNYQDpX/SUNK4+1LXNat03vUJvBVtraE/KVJVLbG84YoWc8 csSAS/UwZvbXt7vxixYIcLVP7OZq5v7Ps2lh7Iw1CaNqXyoDGl80V276Li9eqBU5zg +NNzCB8JHfhUBK0C0AVyHZ/JR87wSAaJ3W17vE2M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Michael Grzeschik Subject: [PATCH 5.18 0128/1095] usb: dwc3: gadget: refactor dwc3_repare_one_trb Date: Mon, 15 Aug 2022 19:52:07 +0200 Message-Id: <20220815180434.882377454@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 packets") Cc: stable Signed-off-by: Michael Grzeschik Link: https://lore.kernel.org/r/20220704141812.1532306-2-m.grzeschik@pengutronix.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 @@ -1181,17 +1181,49 @@ static u32 dwc3_calc_trbs_left(struct dw return trbs_left; } -static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb, - 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 = req->request.stream_id; + unsigned int short_not_ok = req->request.short_not_ok; + unsigned int no_interrupt = req->request.no_interrupt; + unsigned int is_last = req->request.is_last; struct dwc3 *dwc = dep->dwc; struct usb_gadget *gadget = dwc->gadget; enum usb_device_speed speed = gadget->speed; - trb->size = DWC3_TRB_SIZE_LENGTH(length); + if (use_bounce_buffer) + dma = dep->dwc->bounce_addr; + else if (req->request.num_sgs > 0) + dma = sg_dma_address(req->start_sg); + else + dma = req->request.dma; + + trb = &dep->trb_pool[dep->trb_enqueue]; + + if (!req->trb) { + dwc3_gadget_move_started_request(req); + req->trb = trb; + req->trb_dma = dwc3_trb_dma_offset(dep, trb); + } + + req->num_trbs++; + + trb->size = DWC3_TRB_SIZE_LENGTH(trb_length); trb->bpl = lower_32_bits(dma); trb->bph = upper_32_bits(dma); @@ -1231,10 +1263,10 @@ static void __dwc3_prepare_one_trb(struc unsigned int mult = 2; unsigned int maxp = usb_endpoint_maxp(ep->desc); - if (length <= (2 * maxp)) + if (trb_length <= (2 * maxp)) mult--; - if (length <= maxp) + if (trb_length <= maxp) mult--; trb->size |= DWC3_TRB_SIZE_PCM1(mult); @@ -1308,50 +1340,6 @@ static void __dwc3_prepare_one_trb(struc trace_dwc3_prepare_trb(dep, trb); } -/** - * 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 = req->request.stream_id; - unsigned int short_not_ok = req->request.short_not_ok; - unsigned int no_interrupt = req->request.no_interrupt; - unsigned int is_last = req->request.is_last; - - if (use_bounce_buffer) - dma = dep->dwc->bounce_addr; - else if (req->request.num_sgs > 0) - dma = sg_dma_address(req->start_sg); - else - dma = req->request.dma; - - trb = &dep->trb_pool[dep->trb_enqueue]; - - if (!req->trb) { - dwc3_gadget_move_started_request(req); - req->trb = trb; - req->trb_dma = 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 = usb_endpoint_maxp(dep->endpoint.desc);