* [PATCH 1/2] of: skip machine device creation on subsequent of_probe
@ 2021-11-25 16:06 Ahmad Fatoum
2021-11-25 16:06 ` [PATCH 2/2] of: base: improve documentation of global exports Ahmad Fatoum
2021-11-30 10:36 ` [PATCH 1/2] of: skip machine device creation on subsequent of_probe Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-11-25 16:06 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
of_probe may be called more than once, e.g. after oftree -p or by board
code after fixing up device tree. This currently leads to a harmless,
but annoying error message about machine already being registered.
Avoid this by creating the device only once.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/of/base.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 910348fb81b9..ec4f9327036c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2333,9 +2333,12 @@ mem_initcall(of_probe_memory);
static void of_platform_device_create_root(struct device_node *np)
{
- struct device_d *dev;
+ static struct device_d *dev;
int ret;
+ if (dev)
+ return;
+
dev = xzalloc(sizeof(*dev));
dev->id = DEVICE_ID_SINGLE;
dev->device_node = np;
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] of: base: improve documentation of global exports
2021-11-25 16:06 [PATCH 1/2] of: skip machine device creation on subsequent of_probe Ahmad Fatoum
@ 2021-11-25 16:06 ` Ahmad Fatoum
2021-11-30 10:36 ` [PATCH 1/2] of: skip machine device creation on subsequent of_probe Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-11-25 16:06 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Most comments are probably from the initial Linux port. Fix some
discrepancies and add docs for barebox-specific of_probe.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/of/base.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ec4f9327036c..065265ec9756 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -171,8 +171,7 @@ static int of_alias_id_parse(const char *start, int *len)
* of_alias_scan - Scan all properties of 'aliases' node
*
* The function scans all the properties of 'aliases' node and populates
- * the global lookup table with the properties. It returns the
- * number of alias_prop found, or error code in error case.
+ * the global lookup table with the properties.
*/
void of_alias_scan(void)
{
@@ -2354,6 +2353,13 @@ static const struct of_device_id reserved_mem_matches[] = {
{}
};
+/**
+ * of_probe - Probe unflattened device tree starting at of_get_root_node
+ *
+ * The function walks the device tree and creates devices as needed.
+ * With care, it can be called more than once, but if you really need that,
+ * consider first if deep probe would help instead.
+ */
int of_probe(void)
{
struct device_node *node;
@@ -2727,8 +2733,6 @@ struct device_node *of_find_node_by_reproducible_name(struct device_node *from,
* of_graph_parse_endpoint() - parse common endpoint node properties
* @node: pointer to endpoint device_node
* @endpoint: pointer to the OF endpoint data structure
- *
- * The caller should hold a reference to @node.
*/
int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint)
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] of: skip machine device creation on subsequent of_probe
2021-11-25 16:06 [PATCH 1/2] of: skip machine device creation on subsequent of_probe Ahmad Fatoum
2021-11-25 16:06 ` [PATCH 2/2] of: base: improve documentation of global exports Ahmad Fatoum
@ 2021-11-30 10:36 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-11-30 10:36 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Thu, Nov 25, 2021 at 05:06:36PM +0100, Ahmad Fatoum wrote:
> of_probe may be called more than once, e.g. after oftree -p or by board
> code after fixing up device tree. This currently leads to a harmless,
> but annoying error message about machine already being registered.
>
> Avoid this by creating the device only once.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/of/base.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
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:[~2021-11-30 10:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 16:06 [PATCH 1/2] of: skip machine device creation on subsequent of_probe Ahmad Fatoum
2021-11-25 16:06 ` [PATCH 2/2] of: base: improve documentation of global exports Ahmad Fatoum
2021-11-30 10:36 ` [PATCH 1/2] of: skip machine device creation on subsequent of_probe Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox