Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Matthieu CASTET <castet.matthieu@free.fr>,
	Stanislaw Gruszka <stf_xl@wp.pl>
Subject: [PATCH 04/12] USB: ueagle-atm: convert to use dev_groups
Date: Tue,  6 Aug 2019 16:44:54 +0200
Message-ID: <20190806144502.17792-5-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.

Cc: Matthieu CASTET <castet.matthieu@free.fr>
Cc: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/atm/ueagle-atm.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 8faa51b1a520..8b0ea8c70d73 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2458,7 +2458,7 @@ static int claim_interface(struct usb_device *usb_dev,
 	return ret;
 }
 
-static struct attribute *attrs[] = {
+static struct attribute *uea_attrs[] = {
 	&dev_attr_stat_status.attr,
 	&dev_attr_stat_mflags.attr,
 	&dev_attr_stat_human_status.attr,
@@ -2479,9 +2479,7 @@ static struct attribute *attrs[] = {
 	&dev_attr_stat_firmid.attr,
 	NULL,
 };
-static const struct attribute_group attr_grp = {
-	.attrs = attrs,
-};
+ATTRIBUTE_GROUPS(uea);
 
 static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
 		   const struct usb_device_id *id)
@@ -2550,18 +2548,12 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
 		}
 	}
 
-	ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
-	if (ret < 0)
-		goto error;
-
 	ret = uea_boot(sc);
 	if (ret < 0)
-		goto error_rm_grp;
+		goto error;
 
 	return 0;
 
-error_rm_grp:
-	sysfs_remove_group(&intf->dev.kobj, &attr_grp);
 error:
 	kfree(sc);
 	return ret;
@@ -2571,7 +2563,6 @@ static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
 {
 	struct uea_softc *sc = usbatm->driver_data;
 
-	sysfs_remove_group(&intf->dev.kobj, &attr_grp);
 	uea_stop(sc);
 	kfree(sc);
 }
@@ -2721,6 +2712,7 @@ static struct usb_driver uea_driver = {
 	.id_table = uea_ids,
 	.probe = uea_probe,
 	.disconnect = uea_disconnect,
+	.dev_groups = uea_groups,
 };
 
 MODULE_DEVICE_TABLE(usb, uea_ids);
-- 
2.22.0


  parent reply index

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 ` Greg Kroah-Hartman [this message]
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 ` [PATCH 09/12] USB: lvstest: " Greg Kroah-Hartman
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 publically 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-5-gregkh@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=castet.matthieu@free.fr \
    --cc=linux-usb@vger.kernel.org \
    --cc=stf_xl@wp.pl \
    /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

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org linux-usb@archiver.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/ public-inbox