usb: gadget: f_fs: handle control requests in config 0
authorFelix Hädicke <felixhaedicke@web.de>
Tue, 21 Jun 2016 23:12:09 +0000 (01:12 +0200)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 25 Aug 2016 09:13:17 +0000 (12:13 +0300)
Introduces a new FunctionFS descriptor flag named
FUNCTIONFS_CONFIG0_SETUP.

When this flag is enabled, FunctionFS userspace drivers can process
non-standard control requests in configuration 0.

Signed-off-by: Felix Hädicke <felixhaedicke@web.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_fs.c
include/uapi/linux/usb/functionfs.h

index d8f46f6233aced7b274ecdf1ef09c20ff135984d..998697bd80acd88c8519082dfe3ae1bdff3e9fe6 100644 (file)
@@ -2247,7 +2247,8 @@ static int __ffs_data_got_descs(struct ffs_data *ffs,
                              FUNCTIONFS_HAS_MS_OS_DESC |
                              FUNCTIONFS_VIRTUAL_ADDR |
                              FUNCTIONFS_EVENTFD |
-                             FUNCTIONFS_ALL_CTRL_RECIP)) {
+                             FUNCTIONFS_ALL_CTRL_RECIP |
+                             FUNCTIONFS_CONFIG0_SETUP)) {
                        ret = -ENOSYS;
                        goto error;
                }
@@ -3142,7 +3143,7 @@ static bool ffs_func_req_match(struct usb_function *f,
 {
        struct ffs_function *func = ffs_func_from_usb(f);
 
-       if (config0)
+       if (config0 && !(func->ffs->user_flags & FUNCTIONFS_CONFIG0_SETUP))
                return false;
 
        switch (creq->bRequestType & USB_RECIP_MASK) {
index 93da4ca82dc7af55e4f0233036e4420ddf5f54c3..acc63697a0cc415357792e922396a9ef296bb01f 100644 (file)
@@ -22,6 +22,7 @@ enum functionfs_flags {
        FUNCTIONFS_VIRTUAL_ADDR = 16,
        FUNCTIONFS_EVENTFD = 32,
        FUNCTIONFS_ALL_CTRL_RECIP = 64,
+       FUNCTIONFS_CONFIG0_SETUP = 128,
 };
 
 /* Descriptor of an non-audio endpoint */