[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1537422122-6166-1-git-send-email-svellattu@mvista.com>
Date: Thu, 20 Sep 2018 11:12:02 +0530
From: Silesh C V <svellattu@...sta.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>
Cc: linux-kernel@...r.kernel.org, Silesh C V <svellattu@...sta.com>
Subject: [PATCH] Driver core: add bus_find_device_by_of_node
Similar to bus_find_device_by_name, but finds the device having a
specific of_node.
Signed-off-by: Silesh C V <svellattu@...sta.com>
---
drivers/base/bus.c | 21 +++++++++++++++++++++
include/linux/device.h | 3 +++
2 files changed, 24 insertions(+)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8bfd27e..39f90d1 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -373,6 +373,27 @@ struct device *bus_find_device_by_name(struct bus_type *bus,
}
EXPORT_SYMBOL_GPL(bus_find_device_by_name);
+static int match_of_node(struct device *dev, void *data)
+{
+ struct device_node *node = data;
+
+ return dev->of_node == node;
+}
+
+/**
+ * bus_find_device_by_name - device iterator for locating a particular device
+ * having a specific device node
+ * @bus: bus type
+ * @start: Device to begin with
+ * @node: device node pointer
+ */
+struct device *bus_find_device_by_of_node(struct bus_type *bus,
+ struct device *start, struct device_node *node)
+{
+ return bus_find_device(bus, start, (void *)node, match_of_node);
+}
+EXPORT_SYMBOL_GPL(bus_find_device_by_of_node);
+
/**
* subsys_find_device_by_id - find a device with a specific enumeration number
* @subsys: subsystem
diff --git a/include/linux/device.h b/include/linux/device.h
index 055a69d..49006fd 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -171,6 +171,9 @@ struct device *bus_find_device(struct bus_type *bus, struct device *start,
struct device *bus_find_device_by_name(struct bus_type *bus,
struct device *start,
const char *name);
+struct device *bus_find_device_by_of_node(struct bus_type *bus,
+ struct device *start,
+ struct device_node *node);
struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
struct device *hint);
int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
--
1.9.1
Powered by blists - more mailing lists