Commit c559a353 authored by Robert Baldyga's avatar Robert Baldyga Committed by Felipe Balbi

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: default avatarRobert Baldyga <r.baldyga@samsung.com>
Acked-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent e45cfa20
...@@ -1026,6 +1026,29 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, ...@@ -1026,6 +1026,29 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
case FUNCTIONFS_ENDPOINT_REVMAP: case FUNCTIONFS_ENDPOINT_REVMAP:
ret = epfile->ep->num; ret = epfile->ep->num;
break; 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: default:
ret = -ENOTTY; ret = -ENOTTY;
} }
......
...@@ -275,6 +275,12 @@ struct usb_functionfs_event { ...@@ -275,6 +275,12 @@ struct usb_functionfs_event {
*/ */
#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
/*
* Returns endpoint descriptor. If function is not active returns -ENODEV.
*/
#define FUNCTIONFS_ENDPOINT_DESC _IOR('g', 130, \
struct usb_endpoint_descriptor)
#endif /* _UAPI__LINUX_FUNCTIONFS_H__ */ #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment