From: Michael Tretter <m.tretter@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH v3 4/8] firmware: add function to find firmware by devicetree node
Date: Fri, 13 Sep 2019 15:14:42 +0200 [thread overview]
Message-ID: <20190913131446.8202-5-m.tretter@pengutronix.de> (raw)
In-Reply-To: <20190913131446.8202-1-m.tretter@pengutronix.de>
Allows to get the firmware manager using a phandle from the devicetree.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
Changelog:
v2->v3:
- new separate patch for adding the function
---
common/firmware.c | 18 ++++++++++++++++++
include/firmware.h | 15 +++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/common/firmware.c b/common/firmware.c
index 9d55d73e7a..609cf11822 100644
--- a/common/firmware.c
+++ b/common/firmware.c
@@ -62,6 +62,24 @@ struct firmware_mgr *firmwaremgr_find(const char *id)
return NULL;
}
+/*
+ * 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
diff --git a/include/firmware.h b/include/firmware.h
index 284e0f9705..7c01a77118 100644
--- a/include/firmware.h
+++ b/include/firmware.h
@@ -34,10 +34,25 @@ struct firmware_mgr;
int firmwaremgr_register(struct firmware_handler *);
struct firmware_mgr *firmwaremgr_find(const char *);
+#ifdef CONFIG_FIRMWARE
+struct firmware_mgr *firmwaremgr_find_by_node(const struct device_node *np);
+#else
+static inline struct firmware_mgr *firmwaremgr_find_by_node(const struct device_node *np)
+{
+ return NULL;
+}
+#endif
void firmwaremgr_list_handlers(void);
+#ifdef CONFIG_FIRMWARE
int firmwaremgr_load_file(struct firmware_mgr *, const char *path);
+#else
+static inline int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *path)
+{
+ return -ENOSYS;
+}
+#endif
#define get_builtin_firmware(name, start, size) \
{ \
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-09-13 13:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 13:14 [PATCH v3 0/8] Device Tree Overlay Support Michael Tretter
2019-09-13 13:14 ` [PATCH v3 1/8] of: add support for devicetree overlays Michael Tretter
2019-09-13 13:14 ` [PATCH v3 2/8] blspec: " Michael Tretter
2019-09-13 13:14 ` [PATCH v3 3/8] of: add iterator for overlays Michael Tretter
2019-09-13 13:14 ` Michael Tretter [this message]
2019-09-13 13:14 ` [PATCH v3 5/8] firmware: add support to load firmware from dt overlay Michael Tretter
2019-09-13 13:14 ` [PATCH v3 6/8] blspec: load firmware if specified in " Michael Tretter
2019-09-13 13:14 ` [PATCH v3 7/8] commands: add of_overlay command for device tree overlays Michael Tretter
2019-09-13 13:14 ` [PATCH v3 8/8] dtc: optionally add add __symbols__ to build-in devicetree Michael Tretter
2019-09-16 7:07 ` [PATCH v3 0/8] Device Tree Overlay Support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190913131446.8202-5-m.tretter@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox