diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-06 10:45:02 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-09 01:55:45 -0400 |
| commit | c5501d23e38df1f1e7afd373a5d924a18936930c (patch) | |
| tree | 5e9249cf2b51bf019cd72c72bbb81b55098d393c | |
| parent | e605c30977bb5f48af6d14149a252b1619851f33 (diff) | |
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.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/usb/usbip/stub_dev.c | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c index 7931e6cecc70..2305d425e6c9 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c | |||
| @@ -106,38 +106,13 @@ err: | |||
| 106 | } | 106 | } |
| 107 | static DEVICE_ATTR_WO(usbip_sockfd); | 107 | static DEVICE_ATTR_WO(usbip_sockfd); |
| 108 | 108 | ||
| 109 | static int stub_add_files(struct device *dev) | 109 | static struct attribute *usbip_attrs[] = { |
| 110 | { | 110 | &dev_attr_usbip_status.attr, |
| 111 | int err = 0; | 111 | &dev_attr_usbip_sockfd.attr, |
| 112 | 112 | &dev_attr_usbip_debug.attr, | |
| 113 | err = device_create_file(dev, &dev_attr_usbip_status); | 113 | NULL, |
| 114 | if (err) | 114 | }; |
| 115 | goto err_status; | 115 | ATTRIBUTE_GROUPS(usbip); |
| 116 | |||
| 117 | err = device_create_file(dev, &dev_attr_usbip_sockfd); | ||
| 118 | if (err) | ||
| 119 | goto err_sockfd; | ||
| 120 | |||
| 121 | err = device_create_file(dev, &dev_attr_usbip_debug); | ||
| 122 | if (err) | ||
| 123 | goto err_debug; | ||
| 124 | |||
| 125 | return 0; | ||
| 126 | |||
| 127 | err_debug: | ||
| 128 | device_remove_file(dev, &dev_attr_usbip_sockfd); | ||
| 129 | err_sockfd: | ||
| 130 | device_remove_file(dev, &dev_attr_usbip_status); | ||
| 131 | err_status: | ||
| 132 | return err; | ||
| 133 | } | ||
| 134 | |||
| 135 | static void stub_remove_files(struct device *dev) | ||
| 136 | { | ||
| 137 | device_remove_file(dev, &dev_attr_usbip_status); | ||
| 138 | device_remove_file(dev, &dev_attr_usbip_sockfd); | ||
| 139 | device_remove_file(dev, &dev_attr_usbip_debug); | ||
| 140 | } | ||
| 141 | 116 | ||
| 142 | static void stub_shutdown_connection(struct usbip_device *ud) | 117 | static void stub_shutdown_connection(struct usbip_device *ud) |
| 143 | { | 118 | { |
| @@ -379,17 +354,8 @@ static int stub_probe(struct usb_device *udev) | |||
| 379 | goto err_port; | 354 | goto err_port; |
| 380 | } | 355 | } |
| 381 | 356 | ||
| 382 | rc = stub_add_files(&udev->dev); | ||
| 383 | if (rc) { | ||
| 384 | dev_err(&udev->dev, "stub_add_files for %s\n", udev_busid); | ||
| 385 | goto err_files; | ||
| 386 | } | ||
| 387 | |||
| 388 | return 0; | 357 | return 0; |
| 389 | 358 | ||
| 390 | err_files: | ||
| 391 | usb_hub_release_port(udev->parent, udev->portnum, | ||
| 392 | (struct usb_dev_state *) udev); | ||
| 393 | err_port: | 359 | err_port: |
| 394 | dev_set_drvdata(&udev->dev, NULL); | 360 | dev_set_drvdata(&udev->dev, NULL); |
| 395 | usb_put_dev(udev); | 361 | usb_put_dev(udev); |
| @@ -457,7 +423,6 @@ static void stub_disconnect(struct usb_device *udev) | |||
| 457 | /* | 423 | /* |
| 458 | * NOTE: rx/tx threads are invoked for each usb_device. | 424 | * NOTE: rx/tx threads are invoked for each usb_device. |
| 459 | */ | 425 | */ |
| 460 | stub_remove_files(&udev->dev); | ||
| 461 | 426 | ||
| 462 | /* release port */ | 427 | /* release port */ |
| 463 | rc = usb_hub_release_port(udev->parent, udev->portnum, | 428 | rc = usb_hub_release_port(udev->parent, udev->portnum, |
| @@ -526,4 +491,5 @@ struct usb_device_driver stub_driver = { | |||
| 526 | .resume = stub_resume, | 491 | .resume = stub_resume, |
| 527 | #endif | 492 | #endif |
| 528 | .supports_autosuspend = 0, | 493 | .supports_autosuspend = 0, |
| 494 | .dev_groups = usbip_groups, | ||
| 529 | }; | 495 | }; |
