mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] driver: add function to look up device by DT node
@ 2019-12-19 10:10 Lucas Stach
  2019-12-19 10:52 ` Peter Mamonov
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2019-12-19 10:10 UTC (permalink / raw)
  To: barebox

Useful if we need to remove a deivce from the Barebox internal DT.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
This is a prerequisite for "ARM: zii-imx8mq-dev: add DT fixups", which
I missed to send out in the series.
---
 drivers/base/driver.c | 12 ++++++++++++
 include/driver.h      |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index eec2a2d8a2a5..437b0162d3f7 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -70,6 +70,18 @@ static struct device_d *get_device_by_name_id(const char *name, int id)
 	return NULL;
 }
 
+struct device_d *get_device_by_device_node(struct device_node *np)
+{
+	struct device_d *dev;
+
+	for_each_device(dev) {
+		if(dev->device_node == np)
+			return dev;
+	}
+
+	return NULL;
+}
+
 int get_free_deviceid(const char *name_template)
 {
 	int i = 0;
diff --git a/include/driver.h b/include/driver.h
index ad59ce90c3a3..4e3b2443a708 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -170,6 +170,7 @@ int unregister_device(struct device_d *);
 struct device_d *get_device_by_type(ulong type, struct device_d *last);
 struct device_d *get_device_by_id(const char *id);
 struct device_d *get_device_by_name(const char *name);
+struct device_d *get_device_by_device_node(struct device_node *np);
 
 /* Find a free device id from the given template. This is archieved by
  * appending a number to the template. Dynamically created devices should
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-19 10:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 10:10 [PATCH] driver: add function to look up device by DT node Lucas Stach
2019-12-19 10:52 ` Peter Mamonov
2019-12-19 10:55   ` Lucas Stach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox