@@ -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;
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@linuxfoundation.org> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- include/linux/device.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) -- 2.7.4