Skip to content

Commit

Permalink
USB: usbip: convert platform driver to use dev_groups
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Greg Kroah-Hartman committed Aug 6, 2019
1 parent c5d1653 commit 91148db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion drivers/usb/usbip/vudc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
9 changes: 0 additions & 9 deletions drivers/usb/usbip/vudc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/usbip/vudc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
.remove = vudc_remove,
.driver = {
.name = GADGET_NAME,
.dev_groups = vudc_groups,
},
};

Expand Down
7 changes: 6 additions & 1 deletion drivers/usb/usbip/vudc_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit 91148db

Please sign in to comment.