Commit 04a0625e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: usbtmc: 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: Guido Kiener <guido.kiener@rohde-schwarz.com>
Cc: Steve Bayless <steve_bayless@keysight.com>
Link: https://lore.kernel.org/r/20190806144502.17792-7-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c847a365
...@@ -1836,17 +1836,14 @@ capability_attribute(device_capabilities); ...@@ -1836,17 +1836,14 @@ capability_attribute(device_capabilities);
capability_attribute(usb488_interface_capabilities); capability_attribute(usb488_interface_capabilities);
capability_attribute(usb488_device_capabilities); capability_attribute(usb488_device_capabilities);
static struct attribute *capability_attrs[] = { static struct attribute *usbtmc_attrs[] = {
&dev_attr_interface_capabilities.attr, &dev_attr_interface_capabilities.attr,
&dev_attr_device_capabilities.attr, &dev_attr_device_capabilities.attr,
&dev_attr_usb488_interface_capabilities.attr, &dev_attr_usb488_interface_capabilities.attr,
&dev_attr_usb488_device_capabilities.attr, &dev_attr_usb488_device_capabilities.attr,
NULL, NULL,
}; };
ATTRIBUTE_GROUPS(usbtmc);
static const struct attribute_group capability_attr_grp = {
.attrs = capability_attrs,
};
static int usbtmc_ioctl_indicator_pulse(struct usbtmc_device_data *data) static int usbtmc_ioctl_indicator_pulse(struct usbtmc_device_data *data)
{ {
...@@ -2383,9 +2380,6 @@ static int usbtmc_probe(struct usb_interface *intf, ...@@ -2383,9 +2380,6 @@ static int usbtmc_probe(struct usb_interface *intf,
retcode = get_capabilities(data); retcode = get_capabilities(data);
if (retcode) if (retcode)
dev_err(&intf->dev, "can't read capabilities\n"); dev_err(&intf->dev, "can't read capabilities\n");
else
retcode = sysfs_create_group(&intf->dev.kobj,
&capability_attr_grp);
if (data->iin_ep_present) { if (data->iin_ep_present) {
/* allocate int urb */ /* allocate int urb */
...@@ -2432,7 +2426,6 @@ static int usbtmc_probe(struct usb_interface *intf, ...@@ -2432,7 +2426,6 @@ static int usbtmc_probe(struct usb_interface *intf,
return 0; return 0;
error_register: error_register:
sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
usbtmc_free_int(data); usbtmc_free_int(data);
err_put: err_put:
kref_put(&data->kref, usbtmc_delete); kref_put(&data->kref, usbtmc_delete);
...@@ -2445,7 +2438,6 @@ static void usbtmc_disconnect(struct usb_interface *intf) ...@@ -2445,7 +2438,6 @@ static void usbtmc_disconnect(struct usb_interface *intf)
struct list_head *elem; struct list_head *elem;
usb_deregister_dev(intf, &usbtmc_class); usb_deregister_dev(intf, &usbtmc_class);
sysfs_remove_group(&intf->dev.kobj, &capability_attr_grp);
mutex_lock(&data->io_mutex); mutex_lock(&data->io_mutex);
data->zombie = 1; data->zombie = 1;
wake_up_interruptible_all(&data->waitq); wake_up_interruptible_all(&data->waitq);
...@@ -2551,6 +2543,7 @@ static struct usb_driver usbtmc_driver = { ...@@ -2551,6 +2543,7 @@ static struct usb_driver usbtmc_driver = {
.resume = usbtmc_resume, .resume = usbtmc_resume,
.pre_reset = usbtmc_pre_reset, .pre_reset = usbtmc_pre_reset,
.post_reset = usbtmc_post_reset, .post_reset = usbtmc_post_reset,
.dev_groups = usbtmc_groups,
}; };
module_usb_driver(usbtmc_driver); module_usb_driver(usbtmc_driver);
......
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