USB: usbip: convert platform driver to use dev_groups
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Aug 2019 19:36:35 +0000 (21:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 Aug 2019 07:40:47 +0000 (09:40 +0200)
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>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20190805193636.25560-5-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/vudc.h
drivers/usb/usbip/vudc_dev.c
drivers/usb/usbip/vudc_main.c
drivers/usb/usbip/vudc_sysfs.c

index cf96819..1bd4bc0 100644 (file)
@@ -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 */
 
index a72c17f..c8eeabd 100644 (file)
@@ -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);
index 390733e..678faa8 100644 (file)
@@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
        .remove         = vudc_remove,
        .driver         = {
                .name   = GADGET_NAME,
+               .dev_groups = vudc_groups,
        },
 };
 
index 6dcd3ff..100f680 100644 (file)
@@ -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,
+};