Re: [PATCH v6 2/3] usb: gadget: f_fs: add ioctl returning ep descriptor

From: Felipe Balbi
Date: Wed Aug 27 2014 - 15:18:24 EST


Hi,

On Mon, Aug 25, 2014 at 11:16:28AM +0200, Robert Baldyga wrote:
> 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@xxxxxxxxxxx>
> Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx>
> ---
> drivers/usb/gadget/function/f_fs.c | 23 +++++++++++++++++++++++
> include/uapi/linux/usb/functionfs.h | 6 ++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 0dc3552d..6edf7e4 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -1032,6 +1032,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;

should return a value here. Have you tested this at all ?

--
balbi

Attachment: signature.asc
Description: Digital signature