[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1559577023-558-29-git-send-email-suzuki.poulose@arm.com>
Date: Mon, 3 Jun 2019 16:49:54 +0100
From: Suzuki K Poulose <suzuki.poulose@....com>
To: linux-kernel@...r.kernel.org
Cc: gregkh@...uxfoundation.org, rafael@...nel.org,
suzuki.poulose@....com
Subject: [RFC PATCH 28/57] drivers: class: Add variants of class_find_device()
Similar to the bus_find_device_by_*() helpers add wrappers
for class_find_device() to find devices by generic attributes.
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@....com>
---
include/linux/device.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index e8d1267..1945c3d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -528,6 +528,64 @@ extern int class_for_each_device(struct class *class, struct device *start,
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: the class we're iterating
+ * @start: Device to begin with
+ * @name: name of the device to match
+ *
+ * This is similar to the class_find_device() above, but it handles searching
+ * by a name automatically.
+ */
+static inline struct device *class_find_device_by_name(struct class *class,
+ struct device *start,
+ const void *name)
+{
+ return class_find_device(class, start, name, device_match_name);
+}
+
+/**
+ * class_find_device_by_devt - device iterator for locating a particular device
+ * by devt.
+ * @class: the class we're iterating
+ * @start: Device to begin with
+ * @devt: devt 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);
+}
+
+/**
+ * class_find_device_by_of_node - device iterator for locating a particular device
+ * by of_node.
+ * @class: the class we're iterating
+ * @start: Device to begin with
+ * @np: of_node of the device to match
+ */
+static inline struct device *class_find_device_by_of_node(struct class *class,
+ struct device *start,
+ struct device_node *np)
+{
+ return class_find_device(class, start, np, device_match_of_node);
+}
+
+/**
+ * class_find_device_by_fwnode - device iterator for locating a particular device
+ * by fwnode.
+ * @class: the class we're iterating
+ * @start: Device to begin with
+ * @fwnode: fwnode of the device to match
+ */
+static inline struct device *class_find_device_by_fwnode(struct class *class,
+ struct device *start,
+ struct fwnode_handle *fwnode)
+{
+ return class_find_device(class, start, fwnode, device_match_fwnode);
+}
struct class_attribute {
struct attribute attr;
--
2.7.4
Powered by blists - more mailing lists