You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Orange Pi PC have endpoints from ep1-ep4 for both in and out direction, and if we try to use raw_ioctl_ep_enable() for ep5in, it will return -EBUSY here
I guess it will be more intuitive if we return some other errno(such as -EINVAL)? Cuz -EBUSY sounds like EP5in is not available now, but might be available in the future
Here is the patch
diff --git a/raw_gadget/raw_gadget.c b/raw_gadget/raw_gadget.c
index 1378d6c..d5acc67 100644
--- a/raw_gadget/raw_gadget.c+++ b/raw_gadget/raw_gadget.c@@ -758,6 +758,7 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
unsigned long flags;
struct usb_endpoint_descriptor *desc;
struct raw_ep *ep;
+ bool ep_num_matched = false;
desc = memdup_user((void __user *)value, sizeof(*desc));
if (IS_ERR(desc))
@@ -792,6 +793,7 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
if (ep->addr != usb_endpoint_num(desc) &&
ep->addr != USB_RAW_EP_ADDR_ANY)
continue;
+ ep_num_matched = true;
if (!usb_gadget_ep_match_desc(dev->gadget, ep->ep, desc, NULL))
continue;
ep->ep->desc = desc;
@@ -815,6 +817,12 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
goto out_unlock;
}
+ if (!ep_num_matched) {+ dev_dbg(&dev->gadget->dev, "fail, no proper ep address available\n");+ ret = -EINVAL;+ goto out_free;+ }+
dev_dbg(&dev->gadget->dev, "fail, no gadget endpoints available\n");
ret = -EBUSY;
The text was updated successfully, but these errors were encountered:
Returning EINVAL makes more sense indeed. However, this is technically a change to the interface, and USB maintainers might reject it. But feel free to send the patch and I'll ack it. Thanks!
Hi,
Orange Pi PC have endpoints from ep1-ep4 for both in and out direction, and if we try to use raw_ioctl_ep_enable() for ep5in, it will return -EBUSY here
raw-gadget/raw_gadget/raw_gadget.c
Line 819 in f74b1c2
I guess it will be more intuitive if we return some other errno(such as -EINVAL)? Cuz -EBUSY sounds like EP5in is not available now, but might be available in the future
Here is the patch
The text was updated successfully, but these errors were encountered: