All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
@ 2023-01-11  6:51 Chanh Nguyen
  2023-01-11  9:46 ` Andrzej Pietrasiewicz
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Chanh Nguyen @ 2023-01-11  6:51 UTC (permalink / raw)
  To: OpenBMC Maillist, Greg Kroah-Hartman, Frank Li,
	Christophe JAILLET, Dan Vacura, Jakob Koschel, Alan Stern,
	Vijayavardhan Vennapusa, Rondreis, Andrzej Pietrasiewicz,
	Heikki Krogerus, linux-usb, linux-kernel, Open Source Submission
  Cc: Chanh Nguyen

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>

---
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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  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-11 15:16 ` [EXT] " Frank Li
  2023-01-12  7:26   ` Heikki Krogerus
  2 siblings, 1 reply; 10+ messages in thread
From: Andrzej Pietrasiewicz @ 2023-01-11  9:46 UTC (permalink / raw)
  To: Chanh Nguyen, OpenBMC Maillist, Greg Kroah-Hartman, Frank Li,
	Christophe JAILLET, Dan Vacura, Jakob Koschel, Alan Stern,
	Vijayavardhan Vennapusa, Rondreis, Heikki Krogerus, linux-usb,
	linux-kernel, Open Source Submission

Hello,

W dniu 11.01.2023 o 07:51, Chanh Nguyen pisze:
> 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>
> 
> ---
> 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);

This line is 88 chars long, which means you're taking advantage of checkpatch
allowing 100 columns nowadays. That's absolutely fine. If you collapse the above
two lines into one, the combined length is exactly 100 chars, so you might
just as well use a single line. In any case (collapsed or not) you can add my

Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>

> +	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);


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [EXT] [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  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-11 15:16 ` Frank Li
  2023-01-12  8:38   ` Chanh Nguyen
  2023-01-12  7:26   ` Heikki Krogerus
  2 siblings, 1 reply; 10+ messages in thread
From: Frank Li @ 2023-01-11 15:16 UTC (permalink / raw)
  To: Chanh Nguyen, OpenBMC Maillist, Greg Kroah-Hartman,
	Christophe JAILLET, Dan Vacura, Jakob Koschel, Alan Stern,
	Vijayavardhan Vennapusa, Rondreis, Andrzej Pietrasiewicz,
	Heikki Krogerus, linux-usb, linux-kernel, Open Source Submission



> -----Original Message-----
> From: Chanh Nguyen <chanh@os.amperecomputing.com>
> Sent: Wednesday, January 11, 2023 12:51 AM
> To: 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>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; linux-usb@vger.kernel.org; linux-
> kernel@vger.kernel.org; Open Source Submission
> <patches@amperecomputing.com>
> Cc: Chanh Nguyen <chanh@os.amperecomputing.com>
> Subject: [EXT] [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget
> driver names
> 
> Caution: EXT Email
> 
> 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>

Reviewed-by: Frank Li <frank.li@nxp.com>

> 
> ---
> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  2023-01-11  6:51 [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names Chanh Nguyen
@ 2023-01-12  7:26   ` Heikki Krogerus
  2023-01-11 15:16 ` [EXT] " Frank Li
  2023-01-12  7:26   ` Heikki Krogerus
  2 siblings, 0 replies; 10+ messages in thread
From: Heikki Krogerus @ 2023-01-12  7:26 UTC (permalink / raw)
  To: Chanh Nguyen
  Cc: OpenBMC Maillist, Greg Kroah-Hartman, Frank Li,
	Christophe JAILLET, Dan Vacura, Jakob Koschel, Alan Stern,
	Vijayavardhan Vennapusa, Rondreis, Andrzej Pietrasiewicz,
	linux-usb, linux-kernel, Open Source Submission

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
@ 2023-01-12  7:26   ` Heikki Krogerus
  0 siblings, 0 replies; 10+ messages in thread
From: Heikki Krogerus @ 2023-01-12  7:26 UTC (permalink / raw)
  To: Chanh Nguyen
  Cc: Greg Kroah-Hartman, OpenBMC Maillist, linux-usb, Frank Li,
	linux-kernel, Andrzej Pietrasiewicz, Dan Vacura,
	Vijayavardhan Vennapusa, Rondreis, Christophe JAILLET,
	Jakob Koschel, Alan Stern, Open Source Submission

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  2023-01-11  9:46 ` Andrzej Pietrasiewicz
@ 2023-01-12  8:33   ` Chanh Nguyen
  2023-01-12 10:23     ` Andrzej Pietrasiewicz
  0 siblings, 1 reply; 10+ messages in thread
From: Chanh Nguyen @ 2023-01-12  8:33 UTC (permalink / raw)
  To: Andrzej Pietrasiewicz, Chanh Nguyen, OpenBMC Maillist,
	Greg Kroah-Hartman, Frank Li, Christophe JAILLET, Dan Vacura,
	Jakob Koschel, Alan Stern, Vijayavardhan Vennapusa, Rondreis,
	Heikki Krogerus, linux-usb, linux-kernel, Open Source Submission



On 11/01/2023 16:46, Andrzej Pietrasiewicz wrote:
> Hello,
> 
> W dniu 11.01.2023 o 07:51, Chanh Nguyen pisze:
>> 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>
>>
>> ---
>> 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);
> 
> This line is 88 chars long, which means you're taking advantage of 
> checkpatch
> allowing 100 columns nowadays. That's absolutely fine. If you collapse 
> the above
> two lines into one, the combined length is exactly 100 chars, so you might
> just as well use a single line. In any case (collapsed or not) you can 
> add my
> 
> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> 

Thanks Andrzej for the review.

Just found out the commit title is not totally correct.
It should be "usb: gadget: Append name as suffix to configfs-gadget 
driver names".

I wonder if these issues could be fixed when get merged or should I 
resend a v4 with that two lines collapsed and with the title adjust?

Thanks a lot,
- Chanh

>> +    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);
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [EXT] [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  2023-01-11 15:16 ` [EXT] " Frank Li
@ 2023-01-12  8:38   ` Chanh Nguyen
  0 siblings, 0 replies; 10+ messages in thread
From: Chanh Nguyen @ 2023-01-12  8:38 UTC (permalink / raw)
  To: Frank Li, Chanh Nguyen, OpenBMC Maillist, Greg Kroah-Hartman,
	Christophe JAILLET, Dan Vacura, Jakob Koschel, Alan Stern,
	Vijayavardhan Vennapusa, Rondreis, Andrzej Pietrasiewicz,
	Heikki Krogerus, linux-usb, linux-kernel, Open Source Submission



On 11/01/2023 22:16, Frank Li wrote:
> 
> 
>> -----Original Message-----
>> From: Chanh Nguyen <chanh@os.amperecomputing.com>
>> Sent: Wednesday, January 11, 2023 12:51 AM
>> To: 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>; Heikki Krogerus
>> <heikki.krogerus@linux.intel.com>; linux-usb@vger.kernel.org; linux-
>> kernel@vger.kernel.org; Open Source Submission
>> <patches@amperecomputing.com>
>> Cc: Chanh Nguyen <chanh@os.amperecomputing.com>
>> Subject: [EXT] [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget
>> driver names
>>
>> Caution: EXT Email
>>
>> 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>
> 
> Reviewed-by: Frank Li <frank.li@nxp.com>
> 

Thanks Frank!

>>
>> ---
>> 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
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  2023-01-12  7:26   ` Heikki Krogerus
@ 2023-01-12  8:40     ` Chanh Nguyen
  -1 siblings, 0 replies; 10+ messages in thread
From: Chanh Nguyen @ 2023-01-12  8:40 UTC (permalink / raw)
  To: Heikki Krogerus, Chanh Nguyen
  Cc: OpenBMC Maillist, Greg Kroah-Hartman, Frank Li,
	Christophe JAILLET, Dan Vacura, Jakob Koschel, Alan Stern,
	Vijayavardhan Vennapusa, Rondreis, Andrzej Pietrasiewicz,
	linux-usb, linux-kernel, Open Source Submission



On 12/01/2023 14:26, Heikki Krogerus wrote:
> 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!
> 

Thanks Heikki!

>> ---
>> 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
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
@ 2023-01-12  8:40     ` Chanh Nguyen
  0 siblings, 0 replies; 10+ messages in thread
From: Chanh Nguyen @ 2023-01-12  8:40 UTC (permalink / raw)
  To: Heikki Krogerus, Chanh Nguyen
  Cc: Greg Kroah-Hartman, OpenBMC Maillist, linux-usb, Frank Li,
	linux-kernel, Andrzej Pietrasiewicz, Dan Vacura,
	Vijayavardhan Vennapusa, Rondreis, Christophe JAILLET,
	Jakob Koschel, Alan Stern, Open Source Submission



On 12/01/2023 14:26, Heikki Krogerus wrote:
> 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!
> 

Thanks Heikki!

>> ---
>> 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
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3] USB: gadget: Add ID numbers to configfs-gadget driver names
  2023-01-12  8:33   ` Chanh Nguyen
@ 2023-01-12 10:23     ` Andrzej Pietrasiewicz
  0 siblings, 0 replies; 10+ messages in thread
From: Andrzej Pietrasiewicz @ 2023-01-12 10:23 UTC (permalink / raw)
  To: Chanh Nguyen, Chanh Nguyen, OpenBMC Maillist, Greg Kroah-Hartman,
	Frank Li, Christophe JAILLET, Dan Vacura, Jakob Koschel,
	Alan Stern, Vijayavardhan Vennapusa, Rondreis, Heikki Krogerus,
	linux-usb, linux-kernel, Open Source Submission

Hi,

W dniu 12.01.2023 o 09:33, Chanh Nguyen pisze:
> 
> 
> On 11/01/2023 16:46, Andrzej Pietrasiewicz wrote:
>> Hello,
>>
>> W dniu 11.01.2023 o 07:51, Chanh Nguyen pisze:
>>> 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>
>>>
>>> ---
>>> 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);
>>
>> This line is 88 chars long, which means you're taking advantage of checkpatch
>> allowing 100 columns nowadays. That's absolutely fine. If you collapse the above
>> two lines into one, the combined length is exactly 100 chars, so you might
>> just as well use a single line. In any case (collapsed or not) you can add my
>>
>> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
>>
> 
> Thanks Andrzej for the review.
> 
> Just found out the commit title is not totally correct.
> It should be "usb: gadget: Append name as suffix to configfs-gadget driver names".
> 

Heh, good catch :D

"Append gadget name to configfs-gadget driver names?"

I'm not a native speaker, but to me "to append" is the opposite of "to prepend",
isn't it? So IMO "to append" already contains the notion of "adding at the end",
which is the same thing as a suffix. I also suggest it is better to qualify the
"name", it is not just any name, it is specifically a gadget name. If you only
insert the word "gadget" and don't remove "as suffix" then the title becomes
lengthy, hence my suggestion as above.

> I wonder if these issues could be fixed when get merged or should I resend a v4 
> with that two lines collapsed and with the title adjust?

If it is only about making the title better reflect patch contents and
whitespace changes I'd say it is ok to send a v4 with Reviewed-by and Tested-by
already added. Not making the maintainer think why there's no ID numbers is
a good thing. But then Greg's automaton might get confused if it sees a v4
without v1, 2 and 3 preceding it. I'm not sure how it reacts if you reply-to v3
with corrected title, either. On the flip side, if you send a new patch (without
any v number) in a new thread, you also make the maintainer think why the patch
already contains R-b and T-b, so...

Regards,

Andrzej

> 
> Thanks a lot,
> - Chanh
> 
>>> +    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);
>>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-01-17  6:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2023-01-12  7:26   ` Heikki Krogerus
2023-01-12  8:40   ` Chanh Nguyen
2023-01-12  8:40     ` Chanh Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.