Re: [PATCH v1 2/3] usb: dwc3: gadget: Add support for snps,reserved-endpoints property

Thinh Nguyen
2025-01-22T01:44:12Z

On Fri, Jan 17, 2025, Andy Shevchenko wrote:
> On Thu, Jan 16, 2025 at 11:35:19PM +0000, Thinh Nguyen wrote:
> > On Thu, Jan 16, 2025, Andy Shevchenko wrote:
>
> ...
>
> > > for (epnum = 0; epnum < total; epnum++) {
> > > - int ret;
> > > + for (num = 0; num < count; num++) {
> > > + if (epnum == eps[num])
> > > + break;
> > > + }
> > > + if (num < count)
> > > + continue;
> >
> > You can probably rewrite this logic better.
>
> Any suggestions?
>
> Thanks for the review!
>

From the first look, is the list sorted? If so, you don't need another
for-loop.

Also, we loop over the number of endpoints throughout the driver, but
you only skip it here during init. Please double check for invalid
accessing of endpoints in other places.

Perhaps set the dwc->eps[reserved_ep] to ERR_PTR(-EINVAL) or something
when you parse the reserved endpoints so you can skip them in your loop.

BR,
Thinh