summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2019-09-13 15:14:42 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-09-16 09:06:18 +0200
commit32559cecae49998091dd5645b386ed917f5c468d (patch)
treeaf91b1a8977ac3ad1f3178760bc5b6cf9ba5f597 /common
parentca7b8f85f0d9455b631461288535a3cef7e58fdf (diff)
downloadbarebox-32559cecae49998091dd5645b386ed917f5c468d.tar.gz
firmware: add function to find firmware by devicetree node
Allows to get the firmware manager using a phandle from the devicetree. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/firmware.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/firmware.c b/common/firmware.c
index 9d55d73..609cf11 100644
--- a/common/firmware.c
+++ b/common/firmware.c
@@ -63,6 +63,24 @@ struct firmware_mgr *firmwaremgr_find(const char *id)
}
/*
+ * firmwaremgr_find_by_node - find a firmware device handler
+ *
+ * Find a firmware device handler using the device node of the firmware
+ * handler. This allows to retrieve the firmware handler with a phandle from
+ * the device tree.
+ */
+struct firmware_mgr *firmwaremgr_find_by_node(const struct device_node *np)
+{
+ struct firmware_mgr *mgr;
+
+ list_for_each_entry(mgr, &firmwaremgr_list, list)
+ if (mgr->handler->dev->parent->device_node == np)
+ return mgr;
+
+ return NULL;
+}
+
+/*
* firmwaremgr_list_handlers - list registered firmware device handlers
* in pretty format
*/