[PATCH v2 2/4] environment: implement of_env_get_alias_by_path helper
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Nov 15 04:16:00 PST 2024
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 at 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
More information about the barebox
mailing list