diff options
author | Robert Baldyga <r.baldyga@samsung.com> | 2014-09-09 08:23:16 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-09-09 10:04:45 -0500 |
commit | c559a353410939c0884e83bdb0e2420a986ac53b (patch) | |
tree | a08371689dd43528a869f443839df674a344a58c /drivers/usb/gadget/function/f_fs.c | |
parent | e45cfa2051d1b7d3378887d9576e11484e25c7d6 (diff) | |
download | linux-stable-c559a353410939c0884e83bdb0e2420a986ac53b.tar.gz linux-stable-c559a353410939c0884e83bdb0e2420a986ac53b.tar.bz2 linux-stable-c559a353410939c0884e83bdb0e2420a986ac53b.zip |
usb: gadget: f_fs: add ioctl returning ep descriptor
This patch introduces ioctl named FUNCTIONFS_ENDPOINT_DESC, which
returns endpoint descriptor to userspace. It works only if function
is active.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/function/f_fs.c')
-rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 1aad353c1f11..a345385a5abe 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1026,6 +1026,29 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, case FUNCTIONFS_ENDPOINT_REVMAP: ret = epfile->ep->num; break; + case FUNCTIONFS_ENDPOINT_DESC: + { + int desc_idx; + struct usb_endpoint_descriptor *desc; + + switch (epfile->ffs->gadget->speed) { + case USB_SPEED_SUPER: + desc_idx = 2; + break; + case USB_SPEED_HIGH: + desc_idx = 1; + break; + default: + desc_idx = 0; + } + desc = epfile->ep->descs[desc_idx]; + + spin_unlock_irq(&epfile->ffs->eps_lock); + ret = copy_to_user((void *)value, desc, sizeof(*desc)); + if (ret) + ret = -EFAULT; + return ret; + } default: ret = -ENOTTY; } |