From: Johannes Weiner <hannes@cmpxchg.org>
To: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
David Brownell <dbrownell@users.sourceforge.net>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Peter Korsgaard <jacmet@sunsite.dk>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH] USB: gadget: f_mass_storage: per function descriptors copy
Date: Mon, 29 Mar 2010 12:52:04 +0200 [thread overview]
Message-ID: <20100329105204.GG29222@cmpxchg.org> (raw)
In-Reply-To: <01616584180153ae03d983b6971f5a1b8097419e.1269631274.git.mina86@mina86.com>
On Mon, Mar 29, 2010 at 12:18:43PM +0200, Michal Nazarewicz wrote:
> Mass Storage Function (MSF) used the same descriptors for each
> usb_function instance (meaning usb_function::descriptors of different
> functions pointed to the same static area (the same was true for
> usb_function::hs_descriptors)).
>
> This would leads to problems if MSF were used in several USB
> configurations with different interface and/or endpoint numbers.
> Descriptors for all configurations would have interface/endpoint
> numbers overwritten by the values valid for the last configuration.
>
> This patch adds code that copies the descriptors each time MSF is
> added to USB configuration (that is for each usb_function).
>
> Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/usb/gadget/f_mass_storage.c | 32 ++++++++++++++++++++++++++------
> 1 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index f4911c0..9fccdc3 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2906,6 +2906,8 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
>
> DBG(fsg, "unbind\n");
> fsg_common_put(fsg->common);
> + usb_free_descriptors(fsg->function.descriptors);
> + usb_free_descriptors(fsg->function.hs_descriptors);
> kfree(fsg);
> }
>
> @@ -2946,7 +2948,13 @@ static int __init fsg_bind(struct usb_configuration *c, struct usb_function *f)
> fsg_fs_bulk_in_desc.bEndpointAddress;
> fsg_hs_bulk_out_desc.bEndpointAddress =
> fsg_fs_bulk_out_desc.bEndpointAddress;
> - f->hs_descriptors = fsg_hs_function;
> + f->hs_descriptors = usb_copy_descriptors(fsg_hs_function);
> + /* We don't care if we could not copy the high speed
> + * descriptor. If we are out of memory we'll stick to
> + * full speed only. Ie. it is an error that we cannot
> + * copy hs descriptors but not a fatal one. */
> + /* if (unlikely(!f->hs_descriptors))
> + return -ENOMEM; */
I would much prefer to fail here and handle reloading a module in userspace
over having a gadget operate on varying speeds, depending on a transient
situation at module loading time that is not transparent to the user of an
embedded device in the field for example.
next prev parent reply other threads:[~2010-03-29 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-29 10:18 [PATCH] USB: gadget: f_mass_storage: per function descriptors copy Michal Nazarewicz
2010-03-29 10:52 ` Johannes Weiner [this message]
2010-03-29 12:01 ` [PATCHv2] USB: gadget: f_mass_storage: per function 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=20100329105204.GG29222@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=dbrownell@users.sourceforge.net \
--cc=jacmet@sunsite.dk \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.nazarewicz@samsung.com \
--cc=m.szyprowski@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