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 <felixhaedi...@web.de>
---
 drivers/usb/gadget/function/f_fs.c  | 5 +++--
 include/uapi/linux/usb/functionfs.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index 4cf6efc..43aeed6 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2126,7 +2126,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;
                }
@@ -3022,7 +3023,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) {
diff --git a/include/uapi/linux/usb/functionfs.h 
b/include/uapi/linux/usb/functionfs.h
index 93da4ca..acc6369 100644
--- a/include/uapi/linux/usb/functionfs.h
+++ b/include/uapi/linux/usb/functionfs.h
@@ -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 */
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to