linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: usbip: convert platform driver to use dev_groups
@ 2019-08-05 19:36 Greg Kroah-Hartman
  2019-08-05 20:22 ` shuah
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-05 19:36 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Valentina Manea, Shuah Khan

Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files.  So take advantage of that
and do not register "by hand" any sysfs files.

Cc: Valentina Manea <valentina.manea.m@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/usbip/vudc.h       | 2 +-
 drivers/usb/usbip/vudc_dev.c   | 9 ---------
 drivers/usb/usbip/vudc_main.c  | 1 +
 drivers/usb/usbip/vudc_sysfs.c | 7 ++++++-
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
index cf968192e59f..1bd4bc005829 100644
--- a/drivers/usb/usbip/vudc.h
+++ b/drivers/usb/usbip/vudc.h
@@ -115,7 +115,7 @@ struct vudc_device {
 	struct list_head dev_entry;
 };
 
-extern const struct attribute_group vudc_attr_group;
+extern const struct attribute_group *vudc_groups[];
 
 /* visible everywhere */
 
diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index a72c17ff1c6a..c8eeabdd9b56 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -616,18 +616,10 @@ int vudc_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_add_udc;
 
-	ret = sysfs_create_group(&pdev->dev.kobj, &vudc_attr_group);
-	if (ret) {
-		dev_err(&udc->pdev->dev, "create sysfs files\n");
-		goto err_sysfs;
-	}
-
 	platform_set_drvdata(pdev, udc);
 
 	return ret;
 
-err_sysfs:
-	usb_del_gadget_udc(&udc->gadget);
 err_add_udc:
 	cleanup_vudc_hw(udc);
 err_init_vudc_hw:
@@ -640,7 +632,6 @@ int vudc_remove(struct platform_device *pdev)
 {
 	struct vudc *udc = platform_get_drvdata(pdev);
 
-	sysfs_remove_group(&pdev->dev.kobj, &vudc_attr_group);
 	usb_del_gadget_udc(&udc->gadget);
 	cleanup_vudc_hw(udc);
 	kfree(udc);
diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
index 390733e6937e..678faa82598c 100644
--- a/drivers/usb/usbip/vudc_main.c
+++ b/drivers/usb/usbip/vudc_main.c
@@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
 	.remove		= vudc_remove,
 	.driver		= {
 		.name	= GADGET_NAME,
+		.dev_groups = vudc_groups,
 	},
 };
 
diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index 6dcd3ff655c3..100f680c572a 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -215,7 +215,12 @@ static struct bin_attribute *dev_bin_attrs[] = {
 	NULL,
 };
 
-const struct attribute_group vudc_attr_group = {
+static const struct attribute_group vudc_attr_group = {
 	.attrs = dev_attrs,
 	.bin_attrs = dev_bin_attrs,
 };
+
+const struct attribute_group *vudc_groups[] = {
+	&vudc_attr_group,
+	NULL,
+};
-- 
2.22.0


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

* Re: [PATCH] USB: usbip: convert platform driver to use dev_groups
  2019-08-05 19:36 [PATCH] USB: usbip: convert platform driver to use dev_groups Greg Kroah-Hartman
@ 2019-08-05 20:22 ` shuah
  2019-08-06  7:37   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: shuah @ 2019-08-05 20:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb; +Cc: Valentina Manea, shuah

On 8/5/19 1:36 PM, Greg Kroah-Hartman wrote:
> Platform drivers now have the option to have the platform core create
> and remove any needed sysfs attribute files.  So take advantage of that
> and do not register "by hand" any sysfs files.
> 
> Cc: Valentina Manea <valentina.manea.m@gmail.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>   drivers/usb/usbip/vudc.h       | 2 +-
>   drivers/usb/usbip/vudc_dev.c   | 9 ---------
>   drivers/usb/usbip/vudc_main.c  | 1 +
>   drivers/usb/usbip/vudc_sysfs.c | 7 ++++++-
>   4 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
> index cf968192e59f..1bd4bc005829 100644
> --- a/drivers/usb/usbip/vudc.h
> +++ b/drivers/usb/usbip/vudc.h
> @@ -115,7 +115,7 @@ struct vudc_device {
>   	struct list_head dev_entry;
>   };
>   
> -extern const struct attribute_group vudc_attr_group;
> +extern const struct attribute_group *vudc_groups[];
>   
>   /* visible everywhere */
>   
> diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
> index a72c17ff1c6a..c8eeabdd9b56 100644
> --- a/drivers/usb/usbip/vudc_dev.c
> +++ b/drivers/usb/usbip/vudc_dev.c
> @@ -616,18 +616,10 @@ int vudc_probe(struct platform_device *pdev)
>   	if (ret < 0)
>   		goto err_add_udc;
>   
> -	ret = sysfs_create_group(&pdev->dev.kobj, &vudc_attr_group);
> -	if (ret) {
> -		dev_err(&udc->pdev->dev, "create sysfs files\n");
> -		goto err_sysfs;
> -	}
> -
>   	platform_set_drvdata(pdev, udc);
>   
>   	return ret;
>   
> -err_sysfs:
> -	usb_del_gadget_udc(&udc->gadget);
>   err_add_udc:
>   	cleanup_vudc_hw(udc);
>   err_init_vudc_hw:
> @@ -640,7 +632,6 @@ int vudc_remove(struct platform_device *pdev)
>   {
>   	struct vudc *udc = platform_get_drvdata(pdev);
>   
> -	sysfs_remove_group(&pdev->dev.kobj, &vudc_attr_group);
>   	usb_del_gadget_udc(&udc->gadget);
>   	cleanup_vudc_hw(udc);
>   	kfree(udc);
> diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
> index 390733e6937e..678faa82598c 100644
> --- a/drivers/usb/usbip/vudc_main.c
> +++ b/drivers/usb/usbip/vudc_main.c
> @@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
>   	.remove		= vudc_remove,
>   	.driver		= {
>   		.name	= GADGET_NAME,
> +		.dev_groups = vudc_groups,
>   	},
>   };
>   
> diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
> index 6dcd3ff655c3..100f680c572a 100644
> --- a/drivers/usb/usbip/vudc_sysfs.c
> +++ b/drivers/usb/usbip/vudc_sysfs.c
> @@ -215,7 +215,12 @@ static struct bin_attribute *dev_bin_attrs[] = {
>   	NULL,
>   };
>   
> -const struct attribute_group vudc_attr_group = {
> +static const struct attribute_group vudc_attr_group = {
>   	.attrs = dev_attrs,
>   	.bin_attrs = dev_bin_attrs,
>   };
> +
> +const struct attribute_group *vudc_groups[] = {
> +	&vudc_attr_group,
> +	NULL,
> +};
> 

Looks good to me.

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

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

* Re: [PATCH] USB: usbip: convert platform driver to use dev_groups
  2019-08-05 20:22 ` shuah
@ 2019-08-06  7:37   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-06  7:37 UTC (permalink / raw)
  To: shuah; +Cc: linux-usb, Valentina Manea

On Mon, Aug 05, 2019 at 02:22:18PM -0600, shuah wrote:
> On 8/5/19 1:36 PM, Greg Kroah-Hartman wrote:
> > Platform drivers now have the option to have the platform core create
> > and remove any needed sysfs attribute files.  So take advantage of that
> > and do not register "by hand" any sysfs files.
> > 
> > Cc: Valentina Manea <valentina.manea.m@gmail.com>
> > Cc: Shuah Khan <shuah@kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >   drivers/usb/usbip/vudc.h       | 2 +-
> >   drivers/usb/usbip/vudc_dev.c   | 9 ---------
> >   drivers/usb/usbip/vudc_main.c  | 1 +
> >   drivers/usb/usbip/vudc_sysfs.c | 7 ++++++-
> >   4 files changed, 8 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
> > index cf968192e59f..1bd4bc005829 100644
> > --- a/drivers/usb/usbip/vudc.h
> > +++ b/drivers/usb/usbip/vudc.h
> > @@ -115,7 +115,7 @@ struct vudc_device {
> >   	struct list_head dev_entry;
> >   };
> > -extern const struct attribute_group vudc_attr_group;
> > +extern const struct attribute_group *vudc_groups[];
> >   /* visible everywhere */
> > diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
> > index a72c17ff1c6a..c8eeabdd9b56 100644
> > --- a/drivers/usb/usbip/vudc_dev.c
> > +++ b/drivers/usb/usbip/vudc_dev.c
> > @@ -616,18 +616,10 @@ int vudc_probe(struct platform_device *pdev)
> >   	if (ret < 0)
> >   		goto err_add_udc;
> > -	ret = sysfs_create_group(&pdev->dev.kobj, &vudc_attr_group);
> > -	if (ret) {
> > -		dev_err(&udc->pdev->dev, "create sysfs files\n");
> > -		goto err_sysfs;
> > -	}
> > -
> >   	platform_set_drvdata(pdev, udc);
> >   	return ret;
> > -err_sysfs:
> > -	usb_del_gadget_udc(&udc->gadget);
> >   err_add_udc:
> >   	cleanup_vudc_hw(udc);
> >   err_init_vudc_hw:
> > @@ -640,7 +632,6 @@ int vudc_remove(struct platform_device *pdev)
> >   {
> >   	struct vudc *udc = platform_get_drvdata(pdev);
> > -	sysfs_remove_group(&pdev->dev.kobj, &vudc_attr_group);
> >   	usb_del_gadget_udc(&udc->gadget);
> >   	cleanup_vudc_hw(udc);
> >   	kfree(udc);
> > diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
> > index 390733e6937e..678faa82598c 100644
> > --- a/drivers/usb/usbip/vudc_main.c
> > +++ b/drivers/usb/usbip/vudc_main.c
> > @@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
> >   	.remove		= vudc_remove,
> >   	.driver		= {
> >   		.name	= GADGET_NAME,
> > +		.dev_groups = vudc_groups,
> >   	},
> >   };
> > diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
> > index 6dcd3ff655c3..100f680c572a 100644
> > --- a/drivers/usb/usbip/vudc_sysfs.c
> > +++ b/drivers/usb/usbip/vudc_sysfs.c
> > @@ -215,7 +215,12 @@ static struct bin_attribute *dev_bin_attrs[] = {
> >   	NULL,
> >   };
> > -const struct attribute_group vudc_attr_group = {
> > +static const struct attribute_group vudc_attr_group = {
> >   	.attrs = dev_attrs,
> >   	.bin_attrs = dev_bin_attrs,
> >   };
> > +
> > +const struct attribute_group *vudc_groups[] = {
> > +	&vudc_attr_group,
> > +	NULL,
> > +};
> > 
> 
> Looks good to me.
> 
> Acked-by: Shuah Khan <skhan@linuxfoundation.org>

Thanks for the review!

greg k-h

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

end of thread, other threads:[~2019-08-06  7:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 19:36 [PATCH] USB: usbip: convert platform driver to use dev_groups Greg Kroah-Hartman
2019-08-05 20:22 ` shuah
2019-08-06  7:37   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).