[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250623223134.mr4lsbrl73ita5gm@synopsys.com>
Date: Mon, 23 Jun 2025 22:31:45 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Johannes Schneider <johannes.schneider@...ca-geosystems.com>
CC: Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"bsp-development.geo@...ca-geosystems.com" <bsp-development.geo@...ca-geosystems.com>
Subject: Re: [PATCH 3/3] usb: dwc3: gadget: Simplify logic in
dwc3_needs_extra_trb()
On Sat, Jun 21, 2025, Johannes Schneider wrote:
> The existing logic in dwc3_needs_extra_trb() checks multiple conditions
> in a compound expression to determine whether an extra TRB is needed,
> either for a ZLP or to handle short OUT transfers.
>
> This commit simplifies the logic without changing behavior:
> - Returns false early for isochronous endpoints
> - Separates the conditions for IN vs OUT transfers
> - Makes intent and flow easier to read and reason about
>
> No functional changes intended.
>
> Signed-off-by: Johannes Schneider <johannes.schneider@...ca-geosystems.com>
> ---
> drivers/usb/dwc3/gadget.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index a4a2bf273f943fa112f49979297023a732e0af2e..32d0fb090f4c2ffab61ae6eee29a02efd32ed032 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1420,12 +1420,13 @@ static bool dwc3_needs_extra_trb(struct dwc3_ep *dep, struct dwc3_request *req)
> unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
> unsigned int rem = req->request.length % maxp;
>
> - if ((req->request.length && req->request.zero && !rem &&
> - !usb_endpoint_xfer_isoc(dep->endpoint.desc)) ||
> - (!req->direction && rem))
> - return true;
> + if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
> + return false;
I know the current flow is unsightly, but this is not the same logic.
Please help fix it.
Thanks,
Thinh
> +
> + if (!req->direction) /* OUT transfers */
> + return rem != 0;
>
> - return false;
> + return rem == 0;
> }
>
> /**
>
> --
> 2.34.1
>
Powered by blists - more mailing lists