[PATCH v3 2/4] environment: implement of_env_get_device_alias_by_path helper
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Dec 2 03:24:35 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_device_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>
---
v2 -> v3:
- rename from of_env_get_alias_by_path to of_env_get_device_alias_by_path
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 85e356f5ac0f..dc90c0cb3ada 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_device_alias_by_path(const char *of_path)
+{
+ return of_property_get_alias(of_path, "device-path");
+}
+
static char *environment_probe_1node_binding(struct device *dev)
{
struct cdev *cdev;
diff --git a/include/envfs.h b/include/envfs.h
index 767b34c943de..a6614c0a15ee 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_device_alias_by_path(const char *of_path);
+#else
+static inline const char *of_env_get_device_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