Commit c5501d23 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: usbip: convert to use dev_groups

USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner.  Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Cc: Valentina Manea <valentina.manea.m@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Link: https://lore.kernel.org/r/20190806144502.17792-13-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e605c309
...@@ -106,38 +106,13 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a ...@@ -106,38 +106,13 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a
} }
static DEVICE_ATTR_WO(usbip_sockfd); static DEVICE_ATTR_WO(usbip_sockfd);
static int stub_add_files(struct device *dev) static struct attribute *usbip_attrs[] = {
{ &dev_attr_usbip_status.attr,
int err = 0; &dev_attr_usbip_sockfd.attr,
&dev_attr_usbip_debug.attr,
err = device_create_file(dev, &dev_attr_usbip_status); NULL,
if (err) };
goto err_status; ATTRIBUTE_GROUPS(usbip);
err = device_create_file(dev, &dev_attr_usbip_sockfd);
if (err)
goto err_sockfd;
err = device_create_file(dev, &dev_attr_usbip_debug);
if (err)
goto err_debug;
return 0;
err_debug:
device_remove_file(dev, &dev_attr_usbip_sockfd);
err_sockfd:
device_remove_file(dev, &dev_attr_usbip_status);
err_status:
return err;
}
static void stub_remove_files(struct device *dev)
{
device_remove_file(dev, &dev_attr_usbip_status);
device_remove_file(dev, &dev_attr_usbip_sockfd);
device_remove_file(dev, &dev_attr_usbip_debug);
}
static void stub_shutdown_connection(struct usbip_device *ud) static void stub_shutdown_connection(struct usbip_device *ud)
{ {
...@@ -379,17 +354,8 @@ static int stub_probe(struct usb_device *udev) ...@@ -379,17 +354,8 @@ static int stub_probe(struct usb_device *udev)
goto err_port; goto err_port;
} }
rc = stub_add_files(&udev->dev);
if (rc) {
dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid);
goto err_files;
}
return 0; return 0;
err_files:
usb_hub_release_port(udev->parent, udev->portnum,
(struct usb_dev_state *) udev);
err_port: err_port:
dev_set_drvdata(&udev->dev, NULL); dev_set_drvdata(&udev->dev, NULL);
usb_put_dev(udev); usb_put_dev(udev);
...@@ -457,7 +423,6 @@ static void stub_disconnect(struct usb_device *udev) ...@@ -457,7 +423,6 @@ static void stub_disconnect(struct usb_device *udev)
/* /*
* NOTE: rx/tx threads are invoked for each usb_device. * NOTE: rx/tx threads are invoked for each usb_device.
*/ */
stub_remove_files(&udev->dev);
/* release port */ /* release port */
rc = usb_hub_release_port(udev->parent, udev->portnum, rc = usb_hub_release_port(udev->parent, udev->portnum,
...@@ -526,4 +491,5 @@ struct usb_device_driver stub_driver = { ...@@ -526,4 +491,5 @@ struct usb_device_driver stub_driver = {
.resume = stub_resume, .resume = stub_resume,
#endif #endif
.supports_autosuspend = 0, .supports_autosuspend = 0,
.dev_groups = usbip_groups,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment