All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ding Xiang <dingxiang@cmss.chinamobile.com>
Subject: [PATCH 10/12] USB: trancevibrator: convert to use dev_groups
Date: Tue,  6 Aug 2019 16:45:00 +0200	[thread overview]
Message-ID: <20190806144502.17792-11-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: Ding Xiang <dingxiang@cmss.chinamobile.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/misc/trancevibrator.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index ac357ce2d1a6..a3dfc77578ea 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -71,9 +71,14 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr,
 	}
 	return count;
 }
-
 static DEVICE_ATTR_RW(speed);
 
+static struct attribute *tv_attrs[] = {
+	&dev_attr_speed.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(tv);
+
 static int tv_probe(struct usb_interface *interface,
 		    const struct usb_device_id *id)
 {
@@ -89,15 +94,9 @@ static int tv_probe(struct usb_interface *interface,
 
 	dev->udev = usb_get_dev(udev);
 	usb_set_intfdata(interface, dev);
-	retval = device_create_file(&interface->dev, &dev_attr_speed);
-	if (retval)
-		goto error_create_file;
 
 	return 0;
 
-error_create_file:
-	usb_put_dev(udev);
-	usb_set_intfdata(interface, NULL);
 error:
 	kfree(dev);
 	return retval;
@@ -108,7 +107,6 @@ static void tv_disconnect(struct usb_interface *interface)
 	struct trancevibrator *dev;
 
 	dev = usb_get_intfdata (interface);
-	device_remove_file(&interface->dev, &dev_attr_speed);
 	usb_set_intfdata(interface, NULL);
 	usb_put_dev(dev->udev);
 	kfree(dev);
@@ -120,6 +118,7 @@ static struct usb_driver tv_driver = {
 	.probe =	tv_probe,
 	.disconnect =	tv_disconnect,
 	.id_table =	id_table,
+	.dev_groups =	tv_groups,
 };
 
 module_usb_driver(tv_driver);
-- 
2.22.0


  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 ` [PATCH 09/12] USB: lvstest: " Greg Kroah-Hartman
2019-08-06 14:45 ` Greg Kroah-Hartman [this message]
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-11-gregkh@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dingxiang@cmss.chinamobile.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.