From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"bsp-development.geo@leica-geosystems.com"
<bsp-development.geo@leica-geosystems.com>
Subject: Re: [PATCH 3/3] usb: dwc3: gadget: Simplify logic in dwc3_needs_extra_trb()
Date: Mon, 23 Jun 2025 22:31:45 +0000 [thread overview]
Message-ID: <20250623223134.mr4lsbrl73ita5gm@synopsys.com> (raw)
In-Reply-To: <20250621-dwc3-fix-gadget-mtp-v1-3-a45e6def71bb@leica-geosystems.com>
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@leica-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
>
next prev parent reply other threads:[~2025-06-23 22:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-21 19:07 [PATCH 0/3] usb: dwc3: Fix TRB reclaim regression and clean up reclaim logic Johannes Schneider
2025-06-21 19:07 ` [PATCH 1/3] usb: dwc3: gadget: Fix TRB reclaim logic for short transfers and ZLPs Johannes Schneider
2025-06-23 22:41 ` Thinh Nguyen
2025-06-25 7:49 ` [PATCH v3] " SCHNEIDER Johannes
2025-06-28 15:18 ` Greg Kroah-Hartman
2025-06-28 15:19 ` Greg Kroah-Hartman
2025-06-21 19:07 ` [PATCH 2/3] usb: dwc3: gadget: Simplify TRB reclaim logic by removing redundant 'chain' argument Johannes Schneider
2025-06-23 22:43 ` Thinh Nguyen
2025-06-25 7:53 ` [PATCH v3] " SCHNEIDER Johannes
2025-06-28 15:23 ` Greg Kroah-Hartman
2025-06-29 8:45 ` SCHNEIDER Johannes
2025-06-29 9:06 ` Greg Kroah-Hartman
2025-06-21 19:07 ` [PATCH 3/3] usb: dwc3: gadget: Simplify logic in dwc3_needs_extra_trb() Johannes Schneider
2025-06-23 22:31 ` Thinh Nguyen [this message]
2025-06-24 10:47 ` SCHNEIDER Johannes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250623223134.mr4lsbrl73ita5gm@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=bsp-development.geo@leica-geosystems.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.schneider@leica-geosystems.com \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox