public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Robert Baldyga <r.baldyga@samsung.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, Robert Baldyga <r.baldyga@samsung.com>
Subject: Re: [PATCH v2 3/3] usb: gadget: f_fs: make numbers in ep file names the same as ep addresses
Date: Fri, 25 Jul 2014 16:14:58 +0200	[thread overview]
Message-ID: <xa1tzjfxtti5.fsf@mina86.com> (raw)
In-Reply-To: <1406295363-26998-4-git-send-email-r.baldyga@samsung.com>

On Fri, Jul 25 2014, Robert Baldyga wrote:
> This patch adds FUNCTIONFS_ADDR_NAMES flag to user flags set in
> descriptors, which makes numbers in endpoint file names the same as
> value of bEndpointAddress in endpoint descriptor. It simplifies endpoint
> handling, because now it can be refered using one unique number.
>
> Numbers are in hexadecimal format to have each name of the same lenght,
> and to simplify debugging. The first digit can be 0 or 8 which means
> OUT or IN endpoint direction, and the second digit is simply hexadecimal
> value of endpoint number (which is between 1 and 15).
>
> It needed to store user flags to the moment of endpoint files creation,
> and for this reason there is new field in struct ffs_data named user_flags.
>
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>

I don't like this to be honest.  IMO it adds code for little benefit.

> ---
>  drivers/usb/gadget/f_fs.c           | 11 ++++++++---
>  drivers/usb/gadget/u_fs.h           |  2 ++
>  include/uapi/linux/usb/functionfs.h |  1 +
>  3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
> index a2e18cc..0b8040b 100644
> --- a/drivers/usb/gadget/f_fs.c
> +++ b/drivers/usb/gadget/f_fs.c
> @@ -1550,8 +1550,11 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
>  		epfile->ffs = ffs;
>  		mutex_init(&epfile->mutex);
>  		init_waitqueue_head(&epfile->wait);
> -		sprintf(epfiles->name, "ep%u",
> -			ffs->eps_addrmap[i] & USB_ENDPOINT_NUMBER_MASK);
> +		if (ffs->user_flags & FUNCTIONFS_ADDR_NAMES)
> +			sprintf(epfiles->name, "ep%02x", ffs->eps_addrmap[i]);
> +		else
> +			sprintf(epfiles->name, "ep%u",
> +				ffs->eps_addrmap[i] & USB_ENDPOINT_NUMBER_MASK);
>  		if (!unlikely(ffs_sb_create_file(ffs->sb, epfiles->name, epfile,
>  						 &ffs_epfile_operations,
>  						 &epfile->dentry))) {
> @@ -1912,9 +1915,11 @@ static int __ffs_data_got_descs(struct ffs_data *ffs,
>  		break;
>  	case FUNCTIONFS_DESCRIPTORS_MAGIC_V2:
>  		flags = get_unaligned_le32(data + 8);
> +		ffs->user_flags = flags;
>  		if (flags & ~(FUNCTIONFS_HAS_FS_DESC |
>  			      FUNCTIONFS_HAS_HS_DESC |
> -			      FUNCTIONFS_HAS_SS_DESC)) {
> +			      FUNCTIONFS_HAS_SS_DESC |
> +			      FUNCTIONFS_ADDR_NAMES)) {
>  			ret = -ENOSYS;
>  			goto error;
>  		}
> diff --git a/drivers/usb/gadget/u_fs.h b/drivers/usb/gadget/u_fs.h
> index fe31eba..adc6568 100644
> --- a/drivers/usb/gadget/u_fs.h
> +++ b/drivers/usb/gadget/u_fs.h
> @@ -217,6 +217,8 @@ struct ffs_data {
>  	unsigned			hs_descs_count;
>  	unsigned			ss_descs_count;
>  
> +	unsigned			user_flags;
> +
>  	u8				eps_addrmap[15];
>  
>  	unsigned short			strings_count;
> diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
> index 1ab6f06..a29d910 100644
> --- a/include/uapi/linux/usb/functionfs.h
> +++ b/include/uapi/linux/usb/functionfs.h
> @@ -18,6 +18,7 @@ enum functionfs_flags {
>  	FUNCTIONFS_HAS_FS_DESC = 1,
>  	FUNCTIONFS_HAS_HS_DESC = 2,
>  	FUNCTIONFS_HAS_SS_DESC = 4,
> +	FUNCTIONFS_ADDR_NAMES = 8,
>  };
>  
>  #ifndef __KERNEL__
> -- 
> 1.9.1
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--

      reply	other threads:[~2014-07-25 14:15 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
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 [this message]

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=xa1tzjfxtti5.fsf@mina86.com \
    --to=mina86@mina86.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=r.baldyga@samsung.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