From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: h.assmann@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 2/4] environment: implement of_env_get_alias_by_path helper
Date: Fri, 15 Nov 2024 13:16:00 +0100 [thread overview]
Message-ID: <20241115121602.3999375-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241115121602.3999375-1-a.fatoum@pengutronix.de>
For use by board-code that wants to get the alias pointing at the
backing device of an environment node add a simple
of_env_get_alias_by_path() helper, so board code doesn't need to worry
about property name and whether the binding uses a phandle or string path.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
- no change
---
drivers/of/barebox.c | 5 +++++
include/envfs.h | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
index ed5d171e43a8..7d433e280ba5 100644
--- a/drivers/of/barebox.c
+++ b/drivers/of/barebox.c
@@ -15,6 +15,11 @@
#define ENV_MNT_DIR "/boot" /* If env on filesystem, where to mount */
+const char *of_env_get_alias_by_path(const char *of_path)
+{
+ return of_property_get_alias(of_path, "device-path");
+}
+
/* If dev describes a file on a fs, mount the fs and return a pointer
* to the file's path. Otherwise return an error code or NULL if the
* device path should be used.
diff --git a/include/envfs.h b/include/envfs.h
index 767b34c943de..8bfc83b6b008 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -118,6 +118,16 @@ static inline const char *default_environment_path_get(void)
}
#endif
+#ifdef CONFIG_OF_BAREBOX_DRIVERS
+const char *of_env_get_alias_by_path(const char *of_path);
+#else
+static inline const char *of_env_get_alias_by_path(const char *of_path)
+{
+ return NULL;
+}
+#endif
+
+
#ifdef CONFIG_DEFAULT_ENVIRONMENT
void defaultenv_append(void *buf, unsigned int size, const char *name);
int defaultenv_load(const char *dir, unsigned flags);
--
2.39.5
next prev parent reply other threads:[~2024-11-15 12:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 12:15 [PATCH v2 1/4] of: add helpers to get alias from device node path + property name Ahmad Fatoum
2024-11-15 12:16 ` Ahmad Fatoum [this message]
2024-11-15 12:38 ` [PATCH v2 2/4] environment: implement of_env_get_alias_by_path helper Ahmad Fatoum
2024-11-15 12:16 ` [PATCH v2 3/4] bootsource: have bootsource_get_alias_name return const char * Ahmad Fatoum
2024-11-15 12:16 ` [PATCH v2 4/4] ARM: i.MX8MP: tqma8mpxl: fix bbu registration for other boards using SoM Ahmad Fatoum
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=20241115121602.3999375-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=h.assmann@pengutronix.de \
/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