From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Chanh Nguyen <chanh@os.amperecomputing.com>
Cc: OpenBMC Maillist <openbmc@lists.ozlabs.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Frank Li <frank.li@nxp.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Dan Vacura <w36195@motorola.com>,
Jakob Koschel <jakobkoschel@gmail.com>,
Alan Stern <stern@rowland.harvard.edu>,
Vijayavardhan Vennapusa <vvreddy@codeaurora.org>,
Rondreis <linhaoguo86@gmail.com>,
Andrzej Pietrasiewicz <andrzej.p@collabora.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Open Source Submission <patches@amperecomputing.com>
Subject: Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
Date: Thu, 12 Jan 2023 09:26:24 +0200 [thread overview]
Message-ID: <Y7+2ICAKlghDAem2@kuha.fi.intel.com> (raw)
In-Reply-To: <20230111065105.29205-1-chanh@os.amperecomputing.com>
On Wed, Jan 11, 2023 at 01:51:05PM +0700, Chanh Nguyen wrote:
> It is unable to use configfs to attach more than one gadget. When
> attaching the second gadget, it always fails and the kernel message
> prints out:
>
> Error: Driver 'configfs-gadget' is already registered, aborting...
> UDC core: g1: driver registration failed: -16
>
> This commit fixes the problem by using the gadget name as a suffix
> to each configfs_gadget's driver name, thus making the names
> distinct.
>
> Fixes: fc274c1e9973 ("USB: gadget: Add a new bus for gadgets")
> Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Thanks!
> ---
> Changes in v3:
> - Use the gadget name as a unique suffix instead [Andrzej]
> - Remove the driver.name allocation by template [Chanh]
> - Update commit message [Chanh]
>
> Changes in v2:
> - Replace scnprintf() by kasprintf() to simplify the code [CJ]
> - Move the clean up code from gadgets_drop() to
> gadget_info_attr_release() [Frank Li]
> - Correct the resource free up in gadges_make() [Alan Stern]
> - Remove the unnecessary variable in gadgets_make() [Chanh]
> - Fixes minor grammar issue in commit message [Chanh]
> ---
> drivers/usb/gadget/configfs.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
> index 96121d1c8df4..0853536cbf2e 100644
> --- a/drivers/usb/gadget/configfs.c
> +++ b/drivers/usb/gadget/configfs.c
> @@ -393,6 +393,7 @@ static void gadget_info_attr_release(struct config_item *item)
> WARN_ON(!list_empty(&gi->string_list));
> WARN_ON(!list_empty(&gi->available_func));
> kfree(gi->composite.gadget_driver.function);
> + kfree(gi->composite.gadget_driver.driver.name);
> kfree(gi);
> }
>
> @@ -1572,7 +1573,6 @@ static const struct usb_gadget_driver configfs_driver_template = {
> .max_speed = USB_SPEED_SUPER_PLUS,
> .driver = {
> .owner = THIS_MODULE,
> - .name = "configfs-gadget",
> },
> .match_existing_only = 1,
> };
> @@ -1623,13 +1623,21 @@ static struct config_group *gadgets_make(
>
> gi->composite.gadget_driver = configfs_driver_template;
>
> + gi->composite.gadget_driver.driver.name = kasprintf(GFP_KERNEL,
> + "configfs-gadget.%s", name);
> + if (!gi->composite.gadget_driver.driver.name)
> + goto err;
> +
> gi->composite.gadget_driver.function = kstrdup(name, GFP_KERNEL);
> gi->composite.name = gi->composite.gadget_driver.function;
>
> if (!gi->composite.gadget_driver.function)
> - goto err;
> + goto out_free_driver_name;
>
> return &gi->group;
> +
> +out_free_driver_name:
> + kfree(gi->composite.gadget_driver.driver.name);
> err:
> kfree(gi);
> return ERR_PTR(-ENOMEM);
> --
> 2.17.1
--
heikki
next prev parent reply other threads:[~2023-01-12 7:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 6:51 [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names Chanh Nguyen
2023-01-11 9:46 ` Andrzej Pietrasiewicz
2023-01-12 8:33 ` Chanh Nguyen
2023-01-12 10:23 ` Andrzej Pietrasiewicz
2023-01-11 15:16 ` [EXT] " Frank Li
2023-01-12 8:38 ` Chanh Nguyen
2023-01-12 7:26 ` Heikki Krogerus [this message]
2023-01-12 8:40 ` Chanh Nguyen
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=Y7+2ICAKlghDAem2@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=andrzej.p@collabora.com \
--cc=chanh@os.amperecomputing.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=frank.li@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=jakobkoschel@gmail.com \
--cc=linhaoguo86@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=patches@amperecomputing.com \
--cc=stern@rowland.harvard.edu \
--cc=vvreddy@codeaurora.org \
--cc=w36195@motorola.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