From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ukleinek@kernel.org, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] of: fixup reset source device path into DT if known
Date: Wed, 20 Nov 2024 15:49:12 +0100 [thread overview]
Message-ID: <20241120144912.4053300-1-a.fatoum@pengutronix.de> (raw)
The existing code has several shortcomings:
- reset_source_get_device returns a static variable that's never set
due to a separate bug, so this could never have worked as-is.
- A phandle to the barebox internal device tree is not a useful
information to fix up into the kernel device tree.
- phandles are unexpected in /chosen. Other chosen bindings use full
node paths instead (e.g. stdout-path)
Fix this by using the full name of the kernel device tree's node instead.
Fixes: e208e049f98d ("oftree: expose reset_source device in device tree")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/oftree.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/common/oftree.c b/common/oftree.c
index b7762f1a2c57..1e506bbdddaf 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -139,6 +139,27 @@ static int of_fixup_bootargs_bootsource(struct device_node *root,
return ret;
}
+static int of_fixup_bootargs_reset_source(struct device_node *root,
+ struct device_node *chosen)
+{
+ struct device_node *np;
+ struct device *dev;
+ char *name;
+
+ dev = reset_source_get_device();
+ if (!dev || !dev->of_node)
+ return 0;
+
+ name = of_get_reproducible_name(dev->of_node);
+ np = of_find_node_by_reproducible_name(root, name);
+ free(name);
+
+ if (!np)
+ return 0;
+
+ return of_property_write_string(chosen, "reset-source-device", np->full_name);
+}
+
static void watchdog_build_bootargs(struct watchdog *watchdog, struct device_node *root)
{
int alias_id;
@@ -200,7 +221,6 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
struct device_node *node;
int err;
int instance = reset_source_get_instance();
- struct device *dev;
const char *serialno;
const char *compat;
@@ -227,17 +247,9 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
of_property_write_u32(node, "reset-source-instance", instance);
- dev = reset_source_get_device();
- if (dev && dev->of_node) {
- phandle phandle;
-
- phandle = of_node_create_phandle(dev->of_node);
-
- err = of_property_write_u32(node,
- "reset-source-device", phandle);
- if (err)
- return err;
- }
+ err = of_fixup_bootargs_reset_source(root, node);
+ if (err)
+ return err;
err = of_fixup_bootargs_bootsource(root, node);
if (err)
--
2.39.5
reply other threads:[~2024-11-20 14:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20241120144912.4053300-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ukleinek@kernel.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