[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250116233507.sifqs5u3rixoz4lw@synopsys.com>
Date: Thu, 16 Jan 2025 23:35:19 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
Felipe Balbi <balbi@...nel.org>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Ferry Toth <fntoth@...il.com>
Subject: Re: [PATCH v1 2/3] usb: dwc3: gadget: Add support for
snps,reserved-endpoints property
On Thu, Jan 16, 2025, Andy Shevchenko wrote:
> The snps,reserved-endpoints property lists the reserved endpoints
> that shouldn't be used for normal transfers. Add support for that
> to the driver.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> drivers/usb/dwc3/gadget.c | 38 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 31a654c6f15b..3f806fb8b61c 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -3349,14 +3349,50 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum)
> return 0;
> }
>
> +static int dwc3_gadget_parse_reserved_endpoints(struct dwc3 *dwc, u8 *eps, size_t count)
> +{
> + const char *propname = "snps,reserved-endpoints";
> + int ret;
> +
> + ret = device_property_count_u8(dwc->dev, propname);
> + if (ret < 0)
> + return 0;
> + if (ret == 0)
> + return 0;
Just use if (ret <= 0) return 0.
> + if (ret > count) {
> + dev_err(dwc->dev, "too many entries in %s\n", propname);
> + return -EINVAL;
> + }
> +
> + count = ret;
> + ret = device_property_read_u8_array(dwc->dev, propname, eps, count);
> + if (ret)
> + dev_err(dwc->dev, "failed to read %s\n", propname);
> +
> + return ret;
> +}
> +
> static int dwc3_gadget_init_endpoints(struct dwc3 *dwc, u8 total)
> {
> u8 epnum;
> + u8 eps[DWC3_ENDPOINTS_NUM];
Please keep consistent alignment.
> + u8 count, num;
Please keep declaration in separate lines here.
> + int ret;
>
> INIT_LIST_HEAD(&dwc->gadget->ep_list);
>
> + ret = dwc3_gadget_parse_reserved_endpoints(dwc, eps, ARRAY_SIZE(eps));
> + if (ret < 0)
> + return ret;
> + count = ret;
> +
> 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.
>
> ret = dwc3_gadget_init_endpoint(dwc, epnum);
> if (ret)
> --
> 2.43.0.rc1.1336.g36b5255a03ac
>
BR,
Thinh
Powered by blists - more mailing lists