mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/5] of: platform: Ensure timers are probed early
Date: Tue,  8 Mar 2022 12:51:03 +0100	[thread overview]
Message-ID: <20220308115103.3664883-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20220308115103.3664883-1-s.hauer@pengutronix.de>

Timers are a very crucial resource and are needed early. Without them
no delay function can work properly. With deep probe enabled they may
be initialized very late in the initialization order. Make sure they
are probed early. We do not know which device node provides the timer,
so probe all nodes named "timer".

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/platform.c | 26 ++++++++++++++++++++++++++
 include/of.h          |  1 +
 2 files changed, 27 insertions(+)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 4e96350ae2..e4e0b5dc40 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -529,6 +529,24 @@ int of_devices_ensure_probed_by_property(const char *property_name)
 }
 EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_property);
 
+int of_devices_ensure_probed_by_name(const char *name)
+{
+	struct device_node *node;
+	int err, ret = 0;
+
+	if (!deep_probe_is_supported())
+		return 0;
+
+	for_each_node_by_name(node, name) {
+		ret = of_device_ensure_probed(node);
+		if (err)
+			ret = err;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_name);
+
 static int of_stdoutpath_init(void)
 {
 	struct device_node *np;
@@ -545,3 +563,11 @@ static int of_stdoutpath_init(void)
 	return of_device_ensure_probed(np);
 }
 postconsole_initcall(of_stdoutpath_init);
+
+static int of_timer_init(void)
+{
+	of_devices_ensure_probed_by_name("timer");
+
+	return 0;
+}
+postcore_initcall(of_timer_init);
diff --git a/include/of.h b/include/of.h
index 9089409f9f..cf9950e9b3 100644
--- a/include/of.h
+++ b/include/of.h
@@ -287,6 +287,7 @@ extern struct device_d *of_device_enable_and_register_by_alias(
 extern int of_device_ensure_probed(struct device_node *np);
 extern int of_device_ensure_probed_by_alias(const char *alias);
 extern int of_devices_ensure_probed_by_property(const char *property_name);
+extern int of_devices_ensure_probed_by_name(const char *name);
 extern int of_devices_ensure_probed_by_dev_id(const struct of_device_id *ids);
 extern int of_partition_ensure_probed(struct device_node *np);
 
-- 
2.30.2


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


      parent reply	other threads:[~2022-03-08 11:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 11:50 [PATCH 0/5] of: platform: deep probe updates Sascha Hauer
2022-03-08 11:50 ` [PATCH 1/5] of: platform: return early when deep probe is not supported Sascha Hauer
2022-03-08 11:51 ` [PATCH 2/5] of: rename of_find_node_by_name() to of_find_node_by_name_address() Sascha Hauer
2022-03-08 11:51 ` [PATCH 3/5] of: Add of_find_node_by_name() with Linux semantics Sascha Hauer
2022-03-08 11:51 ` [PATCH 4/5] of: platform: Change of_devices_ensure_probed_by_property() return value Sascha Hauer
2022-03-08 11:51 ` Sascha Hauer [this message]

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=20220308115103.3664883-6-s.hauer@pengutronix.de \
    --to=s.hauer@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