From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 09/12] USB: lvstest: convert to use dev_groups
Date: Tue, 6 Aug 2019 16:44:59 +0200 [thread overview]
Message-ID: <20190806144502.17792-10-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org>
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.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/misc/lvstest.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
index e5c03c6d16e9..407fe7570f3b 100644
--- a/drivers/usb/misc/lvstest.c
+++ b/drivers/usb/misc/lvstest.c
@@ -310,7 +310,7 @@ static ssize_t enable_compliance_store(struct device *dev,
}
static DEVICE_ATTR_WO(enable_compliance);
-static struct attribute *lvs_attributes[] = {
+static struct attribute *lvs_attrs[] = {
&dev_attr_get_dev_desc.attr,
&dev_attr_u1_timeout.attr,
&dev_attr_u2_timeout.attr,
@@ -321,10 +321,7 @@ static struct attribute *lvs_attributes[] = {
&dev_attr_enable_compliance.attr,
NULL
};
-
-static const struct attribute_group lvs_attr_group = {
- .attrs = lvs_attributes,
-};
+ATTRIBUTE_GROUPS(lvs);
static void lvs_rh_work(struct work_struct *work)
{
@@ -439,12 +436,6 @@ static int lvs_rh_probe(struct usb_interface *intf,
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);
maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
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,
ret = usb_submit_urb(lvs->urb, GFP_KERNEL);
if (ret < 0) {
dev_err(&intf->dev, "couldn't submit lvs urb %d\n", ret);
- goto sysfs_remove;
+ goto free_urb;
}
return ret;
-sysfs_remove:
- sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group);
free_urb:
usb_free_urb(lvs->urb);
return ret;
@@ -469,7 +458,6 @@ static void lvs_rh_disconnect(struct usb_interface *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 */
flush_work(&lvs->rh_work);
usb_free_urb(lvs->urb);
@@ -479,6 +467,7 @@ static struct usb_driver lvs_driver = {
.name = "lvs",
.probe = lvs_rh_probe,
.disconnect = lvs_rh_disconnect,
+ .dev_groups = lvs_groups,
};
module_usb_driver(lvs_driver);
--
2.22.0
next prev parent reply other threads:[~2019-08-06 14:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-06 14:44 [PATCH 00/12] USB: dev_groups support for usb drivers Greg Kroah-Hartman
2019-08-05 19:36 ` [PATCH] USB: musb: convert platform driver to use dev_groups Greg Kroah-Hartman
2019-08-07 18:25 ` Bin Liu
2019-08-06 14:44 ` [PATCH 01/12] USB: add support for dev_groups to struct usb_driver Greg Kroah-Hartman
2019-08-06 14:44 ` [PATCH 02/12] USB: add support for dev_groups to struct usb_device_driver Greg Kroah-Hartman
2019-08-06 14:44 ` [PATCH 03/12] USB: atm: cxacru: convert to use dev_groups Greg Kroah-Hartman
2019-08-06 14:44 ` [PATCH 04/12] USB: ueagle-atm: " Greg Kroah-Hartman
2019-08-06 14:44 ` [PATCH 05/12] USB: usblp: " Greg Kroah-Hartman
2019-08-08 20:35 ` Pete Zaitcev
2019-08-06 14:44 ` [PATCH 06/12] USB: usbtmc: " Greg Kroah-Hartman
2019-08-06 14:44 ` [PATCH 07/12] USB: cypress_cy7c63: " Greg Kroah-Hartman
2019-08-06 14:44 ` [PATCH 08/12] USB: cytherm: " Greg Kroah-Hartman
2019-08-06 14:44 ` Greg Kroah-Hartman [this message]
2019-08-06 14:45 ` [PATCH 10/12] USB: trancevibrator: " Greg Kroah-Hartman
2019-08-06 14:45 ` [PATCH 11/12] USB: usbsevseg: " Greg Kroah-Hartman
2019-08-06 14:45 ` [PATCH 12/12] USB: usbip: " Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190806144502.17792-10-gregkh@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).