mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [RFC PATCH 5/7] firmware: allow to find manager by device node
Date: Thu,  4 Apr 2019 16:53:18 +0200	[thread overview]
Message-ID: <20190404145320.11465-6-m.tretter@pengutronix.de> (raw)
In-Reply-To: <20190404145320.11465-1-m.tretter@pengutronix.de>

The firmware manager can be found by using the id-String. The id cannot
be used, if the user of the firmware handler is a driver that only has a
handle to the firmware managers devicetree node, because there is no way
to map from the devicetree to the id.

Add a function that allows to get the firmware handler using its device
tree node.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 common/firmware.c  | 18 ++++++++++++++++++
 include/firmware.h |  1 +
 2 files changed, 19 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..ccd3b0669b 100644
--- a/include/firmware.h
+++ b/include/firmware.h
@@ -34,6 +34,7 @@ struct firmware_mgr;
 int firmwaremgr_register(struct firmware_handler *);
 
 struct firmware_mgr *firmwaremgr_find(const char *);
+struct firmware_mgr *firmwaremgr_find_by_node(const struct device_node *);
 
 void firmwaremgr_list_handlers(void);
 
-- 
2.20.1


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

  parent reply	other threads:[~2019-04-04 14:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 14:53 [RFC PATCH 0/7] Device Tree Overlay Support Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 1/7] commands: unify newlines for options Michael Tretter
2019-04-05 12:47   ` Sascha Hauer
2019-04-04 14:53 ` [RFC PATCH 2/7] dtc: add -@ option to enable __symbols__ Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 3/7] of: add support for devicetree overlays Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 4/7] commands: add oftree -o option for overlays Michael Tretter
2019-04-04 14:53 ` Michael Tretter [this message]
2019-04-04 14:53 ` [RFC PATCH 6/7] firmware: add support for fpga-regions Michael Tretter
2019-04-05 10:39   ` Sascha Hauer
2019-04-04 14:53 ` [RFC PATCH 7/7] blspec: add support for devicetree overlays Michael Tretter
2019-04-05 11:04   ` 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=20190404145320.11465-6-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