[U-Boot] [PATCH v2 13/15] env: Mark env_get_location as weak

Simon Glass sjg at chromium.org
Wed Jan 17 22:07:58 UTC 2018


Hi Maxime,

On 16 January 2018 at 01:16, Maxime Ripard
<maxime.ripard at free-electrons.com> wrote:
> Allow boards and architectures to override the default environment lookup
> code by overriding env_get_location.
>
> Reviewed-by: Andre Przywara <andre.przywara at arm.com>
> Reviewed-by: Lukasz Majewski <lukma at denx.de>
> Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>
> ---
>  env/env.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>

I still don't really understand why this needs to be a weak function.
If the board knows the priority order, can it not put it into
global_data? We could have a little u8 array of 4 items with a
terminator?

> diff --git a/env/env.c b/env/env.c
> index 75da2b921804..6d0ab8ebe1a4 100644
> --- a/env/env.c
> +++ b/env/env.c
> @@ -79,7 +79,25 @@ static void env_set_inited(enum env_location location)
>
>  static enum env_location env_load_location;
>
> -static enum env_location env_get_location(enum env_operation op, int prio)
> +/**
> + * env_get_location() - Returns the best env location for a board
> + * @op: operations performed on the environment
> + * @prio: priority between the multiple environments, 0 being the
> + *        highest priority
> + *
> + * This will return the preferred environment for the given
> + * priority. This is overridable by boards if they need to.
> + *
> + * All implementations are free to use the operation, the priority and
> + * any other data relevant to their choice, but must take into account
> + * the fact that the lowest prority (0) is the most important location
> + * in the system. The following locations should be returned by order
> + * of descending priorities, from the highest to the lowest priority.
> + *
> + * Returns:
> + * an enum env_location value on success, a negative error code otherwise
> + */
> +__weak enum env_location env_get_location(enum env_operation op, int prio)
>  {
>         switch (op) {
>         case ENVOP_GET_CHAR:
> --
> git-series 0.9.1

Regards,
Simon


More information about the U-Boot mailing list