[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<AM8PR06MB7521CFF1CD8A93622A537EEDBC78A@AM8PR06MB7521.eurprd06.prod.outlook.com>
Date: Tue, 24 Jun 2025 10:47:52 +0000
From: SCHNEIDER Johannes <johannes.schneider@...ca-geosystems.com>
To: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
CC: 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>, GEO-CHHER-bsp-development
<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.
>
Ups, you're right - re-verified it with a short test program
i'll just drop the third patch...
Gruß
Johannes
>
> Thanks,
> Thinh
>
> > +
> > + if (!req->direction) /* OUT transfers */
> > + return rem != 0;
> >
> > - return false;
> > + return rem == 0;
> > }
> >
> > /**
> >
> > --
> > 2.34.1
> >
>
Powered by blists - more mailing lists