public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Jean Delvare <khali@linux-fr.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
	Guenter Roeck <linux@roeck-us.net>
Subject: [RFC PATCH 2/5] hwmon: Introduce hwmon_device_register_groups
Date: Sat,  6 Jul 2013 10:24:52 -0700	[thread overview]
Message-ID: <1373131495-13465-3-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1373131495-13465-1-git-send-email-linux@roeck-us.net>

hwmon_device_register_groups() lets callers register a hwmon device
together with all sysfs attributes in a single call.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/hwmon.c |   14 +++++++++++---
 include/linux/hwmon.h |    4 ++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 646314f..e94a053 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -38,7 +38,9 @@ static DEFINE_IDA(hwmon_ida);
  *
  * Returns the pointer to the new device.
  */
-struct device *hwmon_device_register(struct device *dev)
+struct device *
+hwmon_device_register_groups(struct device *dev, void *drvdata,
+			     const struct attribute_group **groups)
 {
 	struct device *hwdev;
 	int id;
@@ -47,14 +49,20 @@ struct device *hwmon_device_register(struct device *dev)
 	if (id < 0)
 		return ERR_PTR(id);
 
-	hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL,
-			      HWMON_ID_FORMAT, id);
+	hwdev = device_create_groups(hwmon_class, dev, MKDEV(0, 0), drvdata,
+				     groups, HWMON_ID_FORMAT, id);
 
 	if (IS_ERR(hwdev))
 		ida_simple_remove(&hwmon_ida, id);
 
 	return hwdev;
 }
+EXPORT_SYMBOL_GPL(hwmon_device_register_groups);
+
+struct device *hwmon_device_register(struct device *dev)
+{
+	return hwmon_device_register_groups(dev, NULL, NULL);
+}
 EXPORT_SYMBOL_GPL(hwmon_device_register);
 
 /**
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index b2514f7..ad91c45 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -15,8 +15,12 @@
 #define _HWMON_H_
 
 struct device;
+struct attribute_group;
 
 struct device *hwmon_device_register(struct device *dev);
+struct device *
+hwmon_device_register_groups(struct device *dev, void *drvdata,
+			     const struct attribute_group **groups);
 
 void hwmon_device_unregister(struct device *dev);
 
-- 
1.7.9.7


  parent reply	other threads:[~2013-07-06 17:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-06 17:24 [RFC PATCH 0/5] Introduce and use device_create_groups Guenter Roeck
2013-07-06 17:24 ` [RFC PATCH 1/5] driver core: Introduce device_create_groups Guenter Roeck
2013-07-06 17:47   ` Greg Kroah-Hartman
2013-07-06 19:22     ` Guenter Roeck
2013-07-06 17:24 ` Guenter Roeck [this message]
2013-07-06 17:24 ` [RFC PATCH 3/5] hwmon: (ds1621) Convert to use hwmon_device_register_groups Guenter Roeck
2013-07-06 17:57   ` Greg Kroah-Hartman
2013-07-06 18:01     ` Jean Delvare
2013-07-06 19:18       ` Guenter Roeck
2013-07-06 19:31         ` Greg Kroah-Hartman
2013-07-06 19:48           ` Guenter Roeck
2013-07-06 19:59             ` Jean Delvare
2013-07-06 20:14               ` Guenter Roeck
2013-07-06 19:54           ` Jean Delvare
2013-07-06 20:45             ` Guenter Roeck
2013-07-06 17:24 ` [RFC PATCH 4/5] hwmon: (gpio-fan) " Guenter Roeck
2013-07-06 17:24 ` [RFC PATCH 5/5] hwmon: (ltc4245) " Guenter Roeck
2013-07-06 17:33 ` [RFC PATCH 0/5] Introduce and use device_create_groups 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=1373131495-13465-3-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.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