USB: usbip: convert platform driver to use dev_groups

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>
This commit is contained in:
Greg Kroah-Hartman 2019-08-05 21:36:35 +02:00
parent c5d1653783
commit 91148dbad8
4 changed files with 8 additions and 11 deletions

View 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 */

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

View File

@ -22,6 +22,7 @@ static struct platform_driver vudc_driver = {
.remove = vudc_remove,
.driver = {
.name = GADGET_NAME,
.dev_groups = vudc_groups,
},
};

View 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,
};