From: Robert Baldyga <r.baldyga@samsung.com>
To: Michal Nazarewicz <mina86@mina86.com>, balbi@ti.com
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, m.szyprowski@samsung.com,
andrzej.p@samsung.com
Subject: Re: [PATCH v2 2/3] usb: gadget: f_fs: add ioctl returning ep descriptor
Date: Mon, 28 Jul 2014 08:10:32 +0200 [thread overview]
Message-ID: <53D5E958.40100@samsung.com> (raw)
In-Reply-To: <xa1twqb1ttgq.fsf@mina86.com>
On 07/25/2014 04:15 PM, Michal Nazarewicz wrote:
> On Fri, Jul 25 2014, Robert Baldyga wrote:
>> This patch introduces ioctl named FUNCTIONFS_ENDPOINT_DESC, which
>> returns endpoint descriptor to userspace. It works only if function
>> is active.
>
> I would argue that user space should never need to know the real
> descriptor. Is this ioctl needed for anything in particular?
It's needed, at least, to inform user space about maximum possible
wMaxPacketSize value for the endpoint, which is returned by autoconfig
through the endpoint descriptor when value set by user is zero.
Descriptor returned form this ioctl is mostly the same as descriptor
created by user. I guess you meant that real descriptor is this one,
which contains real endpoint address, because it's probably only datum
in real descriptor which should be never known by user space.
This ioctl would be also useful in case, when FunctionFS daemon obtains
endpoint descriptors from another daemon, and do not have access to
original descriptor structures given do FunctionFS.
>
>>
>> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
>> ---
>> drivers/usb/gadget/f_fs.c | 17 +++++++++++++++++
>> include/uapi/linux/usb/functionfs.h | 6 ++++++
>> 2 files changed, 23 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
>> index 490b30f..a2e18cc 100644
>> --- a/drivers/usb/gadget/f_fs.c
>> +++ b/drivers/usb/gadget/f_fs.c
>> @@ -1031,6 +1031,23 @@ 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;
>> +
>> + if (epfile->ffs->gadget->speed == USB_SPEED_SUPER)
>> + desc_idx = 2;
>> + else if (epfile->ffs->gadget->speed == USB_SPEED_HIGH)
>> + desc_idx = 1;
>> + else
>> + desc_idx = 0;
>> + desc = epfile->ep->descs[desc_idx];
>> + ret = copy_to_user((void *)value, desc, sizeof(*desc));
>> + if (ret)
>> + ret = -EFAULT;
>> + break;
>> + }
>> default:
>> ret = -ENOTTY;
>> }
>> diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
>> index 1dc473a..1ab6f06 100644
>> --- a/include/uapi/linux/usb/functionfs.h
>> +++ b/include/uapi/linux/usb/functionfs.h
>> @@ -197,6 +197,12 @@ struct usb_functionfs_event {
>> */
>> #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
>>
>> +/*
>> + * Returns endpoint descriptor. In funciton is not active returns -ENODEV.
>> + */
>> +#define FUNCTIONFS_ENDPOINT_DESC _IOR('g', 130, \
>> + struct usb_endpoint_descriptor)
>> +
>>
>>
>> #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
>> --
>> 1.9.1
>>
>
next prev parent reply other threads:[~2014-07-28 6:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 13:36 [PATCH v2 0/3] usb: gadget: f_fs: userspace API fixes and improvements Robert Baldyga
2014-07-25 13:36 ` [PATCH v2 1/3] usb: gadget: f_fs: virtual address mapping Robert Baldyga
2014-07-25 14:18 ` Michal Nazarewicz
2014-07-28 5:52 ` Robert Baldyga
2014-07-28 10:22 ` Michal Nazarewicz
2014-07-28 11:52 ` Robert Baldyga
2014-07-28 15:21 ` Michal Nazarewicz
2014-07-29 6:12 ` Robert Baldyga
2014-07-25 13:36 ` [PATCH v2 2/3] usb: gadget: f_fs: add ioctl returning ep descriptor Robert Baldyga
2014-07-25 14:15 ` Michal Nazarewicz
2014-07-28 6:10 ` Robert Baldyga [this message]
2014-07-28 10:24 ` Michal Nazarewicz
2014-07-28 6:42 ` Marek Szyprowski
2014-07-28 6:47 ` Greg KH
2014-07-25 13:36 ` [PATCH v2 3/3] usb: gadget: f_fs: make numbers in ep file names the same as ep addresses Robert Baldyga
2014-07-25 14:14 ` Michal Nazarewicz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53D5E958.40100@samsung.com \
--to=r.baldyga@samsung.com \
--cc=andrzej.p@samsung.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mina86@mina86.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox