[PATCH v2 2/4] environment: implement of_env_get_alias_by_path helper

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Nov 15 04:38:03 PST 2024


On 15.11.24 13:16, Ahmad Fatoum wrote:
> 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>

Thinking about it, of_env_get_device_alias_by_path may be a bit verbose,
but is a better name.

I'll wait for more feedback before sending v3 though.

Cheers,
Ahmad

> ---
> 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);


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list