[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250116154117.148915-3-andriy.shevchenko@linux.intel.com>
Date: Thu, 16 Jan 2025 17:40:47 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
Felipe Balbi <balbi@...nel.org>,
linux-usb@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Ferry Toth <fntoth@...il.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 2/3] usb: dwc3: gadget: Add support for snps,reserved-endpoints property
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;
+ 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];
+ u8 count, num;
+ 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;
ret = dwc3_gadget_init_endpoint(dwc, epnum);
if (ret)
--
2.43.0.rc1.1336.g36b5255a03ac
Powered by blists - more mailing lists