Added USB_GADGETFS_ALLOW_DELEGATE_DESCRIPTORS to Kconfig, this option is available under USB_GADGETFS and requires EXPERT. Enabling this option will not change the default behavior of GadgetFS, but will allow a user to enable descriptor delegation using ioctls. --- drivers/usb/gadget/legacy/Kconfig | 12 ++++++++++++ drivers/usb/gadget/legacy/inode.c | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig index 0b36878..c062384 100644 --- a/drivers/usb/gadget/legacy/Kconfig +++ b/drivers/usb/gadget/legacy/Kconfig @@ -184,6 +184,18 @@ config USB_GADGETFS Say "y" to link the driver statically, or "m" to build a dynamically linked module called "gadgetfs". +config USB_GADGETFS_ALLOW_DELEGATE_DESCRIPTORS + bool "Delegate get descriptor requests to user" if EXPERT + depends on USB_GADGETFS + default n + help + This feature allows to enable delegation of GET_DESCRIPTOR + requests in GadgetFS. + Enabling the request delegation is done through ioctl calls on + the control endpoint file descriptor. Once enabled, all + GET_DESCRIPTOR requests will be delegated to user mode, and will + not be handled by GadgetFS. + config USB_FUNCTIONFS tristate "Function Filesystem" select USB_LIBCOMPOSITE diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c index f8a3e75..9a62584 100644 --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -178,9 +178,13 @@ static struct dev_data *dev_new (void) spin_lock_init (&dev->lock); INIT_LIST_HEAD (&dev->epfiles); init_waitqueue_head (&dev->wait); + +#ifdef CONFIG_USB_GADGETFS_ALLOW_DELEGATE_DESCRIPTORS feature_set(&dev->supported_features, GADGETFS_FEATURE_DELEGATE_DESCRIPTORS); - return dev; +#endif + + return dev; } /*----------------------------------------------------------------------*/ @@ -1414,10 +1418,14 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) case USB_REQ_GET_DESCRIPTOR: if (ctrl->bRequestType != USB_DIR_IN) goto unrecognized; + +#ifdef CONFIG_USB_GADGETFS_ALLOW_DELEGATE_DESCRIPTORS if (is_feature_set(&dev->enabled_features, GADGETFS_FEATURE_DELEGATE_DESCRIPTORS)) goto delegate; - switch (w_value >> 8) { +#endif + + switch (w_value >> 8) { case USB_DT_DEVICE: value = min (w_length, (u16) sizeof *dev->dev); -- 2.5.0 -- Binyamin Sharet, Cisco, STARE-C -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html