[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1559747630-28065-11-git-send-email-suzuki.poulose@arm.com>
Date: Wed, 5 Jun 2019 16:13:47 +0100
From: Suzuki K Poulose <suzuki.poulose@....com>
To: linux-kernel@...r.kernel.org
Cc: gregkh@...uxfoundation.org, rafael@...nel.org,
suzuki.poulose@....com, Alessandro Zummo <a.zummo@...ertech.it>,
Alexander Aring <alex.aring@...il.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Andrew Lunn <andrew@...n.ch>, Arnd Bergmann <arnd@...db.de>,
Dan Murphy <dmurphy@...com>,
"David S. Miller" <davem@...emloft.net>,
Florian Fainelli <f.fainelli@...il.com>,
Harald Freudenberger <freude@...ux.ibm.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
Jiri Slaby <jslaby@...e.com>,
Liam Girdwood <lgirdwood@...il.com>,
linux-leds@...r.kernel.org, linux-rtc@...r.kernel.org,
linux-usb@...r.kernel.org, linux-wpan@...r.kernel.org,
Mark Brown <broonie@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Pavel Machek <pavel@....cz>, Peter Rosin <peda@...ntia.se>,
Stefan Schmidt <stefan@...enfreihafen.org>,
Tomas Winkler <tomas.winkler@...el.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Subject: [PATCH 10/13] drivers: Introduce variants of class_find_device()
Now that we have generic helpers to match various generic
device attributes, provide wrappers to the class_find_device()
to lookup devices by individual properties. The new wrappers
except the lookup by devt, drops the "start" device pointer as
none of the existing users need it and the attributes are usually
unique. The idea is to stop the proliferation of custom match
functions to do generic attribute matching.
So now we have :
class_find_device_by_name
class_find_device_by_of_node
class_find_device_by_fwnode
class_find_device_by_devt
Cc: Alessandro Zummo <a.zummo@...ertech.it>
Cc: Alexander Aring <alex.aring@...il.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@...tlin.com>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Dan Murphy <dmurphy@...com>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Florian Fainelli <f.fainelli@...il.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Harald Freudenberger <freude@...ux.ibm.com>
Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc: Heiko Carstens <heiko.carstens@...ibm.com>
Cc: Heiner Kallweit <hkallweit1@...il.com>
Cc: Jacek Anaszewski <jacek.anaszewski@...il.com>
Cc: Jiri Slaby <jslaby@...e.com>
Cc: Liam Girdwood <lgirdwood@...il.com>
Cc: linux-leds@...r.kernel.org
Cc: linux-rtc@...r.kernel.org
Cc: linux-usb@...r.kernel.org
Cc: linux-wpan@...r.kernel.org
Cc: Mark Brown <broonie@...nel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@...il.com>
Cc: Pavel Machek <pavel@....cz>
Cc: Peter Rosin <peda@...ntia.se>
Cc: Stefan Schmidt <stefan@...enfreihafen.org>
Cc: Tomas Winkler <tomas.winkler@...el.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@....com>
---
include/linux/device.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index 8c8727b..4396edc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -474,6 +474,57 @@ extern struct device *class_find_device(struct class *class,
struct device *start, const void *data,
int (*match)(struct device *, const void *));
+/**
+ * class_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @class: class type
+ * @name: name of the device to match
+ */
+static inline struct device *class_find_device_by_name(struct class *class,
+ const char *name)
+{
+ return class_find_device(class, NULL, name, device_match_name);
+}
+
+/**
+ * class_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @class: class type
+ * @np: of_node of the device to match.
+ */
+static inline struct device *
+class_find_device_by_of_node(struct class *class, const struct device_node *np)
+{
+ return class_find_device(class, NULL, np, device_match_of_node);
+}
+
+/**
+ * class_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @class: class type
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *
+class_find_device_by_fwnode(struct class *class,
+ const struct fwnode_handle *fwnode)
+{
+ return class_find_device(class, NULL, fwnode, device_match_fwnode);
+}
+
+/**
+ * class_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @class: class type
+ * @start: device to start search from
+ * @devt: device type of the device to match.
+ */
+static inline struct device *class_find_device_by_devt(struct class *class,
+ struct device *start,
+ dev_t devt)
+{
+ return class_find_device(class, start, &devt, device_match_devt);
+}
+
struct class_attribute {
struct attribute attr;
ssize_t (*show)(struct class *class, struct class_attribute *attr,
--
2.7.4
Powered by blists - more mailing lists