Commit 899ad6d6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: lvstest: 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.

Link: https://lore.kernel.org/r/20190806144502.17792-10-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 524f3ac1
...@@ -310,7 +310,7 @@ static ssize_t enable_compliance_store(struct device *dev, ...@@ -310,7 +310,7 @@ static ssize_t enable_compliance_store(struct device *dev,
} }
static DEVICE_ATTR_WO(enable_compliance); static DEVICE_ATTR_WO(enable_compliance);
static struct attribute *lvs_attributes[] = { static struct attribute *lvs_attrs[] = {
&dev_attr_get_dev_desc.attr, &dev_attr_get_dev_desc.attr,
&dev_attr_u1_timeout.attr, &dev_attr_u1_timeout.attr,
&dev_attr_u2_timeout.attr, &dev_attr_u2_timeout.attr,
...@@ -321,10 +321,7 @@ static struct attribute *lvs_attributes[] = { ...@@ -321,10 +321,7 @@ static struct attribute *lvs_attributes[] = {
&dev_attr_enable_compliance.attr, &dev_attr_enable_compliance.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(lvs);
static const struct attribute_group lvs_attr_group = {
.attrs = lvs_attributes,
};
static void lvs_rh_work(struct work_struct *work) static void lvs_rh_work(struct work_struct *work)
{ {
...@@ -439,12 +436,6 @@ static int lvs_rh_probe(struct usb_interface *intf, ...@@ -439,12 +436,6 @@ static int lvs_rh_probe(struct usb_interface *intf,
INIT_WORK(&lvs->rh_work, lvs_rh_work); INIT_WORK(&lvs->rh_work, lvs_rh_work);
ret = sysfs_create_group(&intf->dev.kobj, &lvs_attr_group);
if (ret < 0) {
dev_err(&intf->dev, "Failed to create sysfs node %d\n", ret);
goto free_urb;
}
pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp, usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp,
...@@ -453,13 +444,11 @@ static int lvs_rh_probe(struct usb_interface *intf, ...@@ -453,13 +444,11 @@ static int lvs_rh_probe(struct usb_interface *intf,
ret = usb_submit_urb(lvs->urb, GFP_KERNEL); ret = usb_submit_urb(lvs->urb, GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
dev_err(&intf->dev, "couldn't submit lvs urb %d\n", ret); dev_err(&intf->dev, "couldn't submit lvs urb %d\n", ret);
goto sysfs_remove; goto free_urb;
} }
return ret; return ret;
sysfs_remove:
sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
free_urb: free_urb:
usb_free_urb(lvs->urb); usb_free_urb(lvs->urb);
return ret; return ret;
...@@ -469,7 +458,6 @@ static void lvs_rh_disconnect(struct usb_interface *intf) ...@@ -469,7 +458,6 @@ static void lvs_rh_disconnect(struct usb_interface *intf)
{ {
struct lvs_rh *lvs = usb_get_intfdata(intf); struct lvs_rh *lvs = usb_get_intfdata(intf);
sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
usb_poison_urb(lvs->urb); /* used in scheduled work */ usb_poison_urb(lvs->urb); /* used in scheduled work */
flush_work(&lvs->rh_work); flush_work(&lvs->rh_work);
usb_free_urb(lvs->urb); usb_free_urb(lvs->urb);
...@@ -479,6 +467,7 @@ static struct usb_driver lvs_driver = { ...@@ -479,6 +467,7 @@ static struct usb_driver lvs_driver = {
.name = "lvs", .name = "lvs",
.probe = lvs_rh_probe, .probe = lvs_rh_probe,
.disconnect = lvs_rh_disconnect, .disconnect = lvs_rh_disconnect,
.dev_groups = lvs_groups,
}; };
module_usb_driver(lvs_driver); module_usb_driver(lvs_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