All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 09/15] env: Support multiple environments
Date: Wed, 7 Feb 2018 09:32:53 +0100	[thread overview]
Message-ID: <563b6cc9-e021-3931-cdd3-e98b2e1ffa2b@de.pepperl-fuchs.com> (raw)
In-Reply-To: <1517905247.6070.60.camel@infinera.com>

On 06.02.2018 09:20, Joakim Tjernlund wrote:
> On Thu, 1970-01-01 at 00:00 +0000, Simon Goldschmidt wrote:
>
> .....
>>> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>>> ---
>>>    env/env.c | 80 +++++++++++++++++++++++++++++++++++---------------------
>>>    1 file changed, 50 insertions(+), 30 deletions(-)
>>>
>>> diff --git a/env/env.c b/env/env.c
>>> index 906f28ee50a1..1182fdb545db 100644
>>> --- a/env/env.c
>>> +++ b/env/env.c
>>> @@ -26,6 +26,41 @@ static struct env_driver *_env_driver_lookup(enum env_location loc)
>>>        return NULL;
>>>    }
>>>
>>> +static enum env_location env_locations[] = {
> Don't use static/global variables. They cause a lot of relocation work/size
> and is less flexible.

In this specific case, I think this array should be const anyway, would 
that prevent the relocation problems you see?

> There is no way to #define ENVL_EEPROM to a function
> when a variable.

ENVL_EEPROM is an enum value, why would you define it to a function?

Simon


>
>   Jocke
>
>>> +#ifdef CONFIG_ENV_IS_IN_EEPROM
>>> +     ENVL_EEPROM,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_FAT
>>> +     ENVL_FAT,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_FLASH
>>> +     ENVL_FLASH,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_MMC
>>> +     ENVL_MMC,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_NAND
>>> +     ENVL_NAND,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_NVRAM
>>> +     ENVL_NVRAM,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_REMOTE
>>> +     ENVL_REMOTE,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
>>> +     ENVL_SPI_FLASH,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_IN_UBI
>>> +     ENVL_UBI,
>>> +#endif
>>> +#ifdef CONFIG_ENV_IS_NOWHERE
>>> +     ENVL_NOWHERE,
>>> +#endif
>>> +};
>>> +
>>> +static enum env_location env_load_location = ENVL_UNKNOWN;
>>> +
>>>    /**
>>>     * env_get_location() - Returns the best env location for a board
>>>     * @op: operations performed on the environment
>>> @@ -45,36 +80,21 @@ static struct env_driver *_env_driver_lookup(enum env_location loc)
>>>     */
>>>    static enum env_location env_get_location(enum env_operation op, int prio)
>>>    {
>>> -     /*
>>> -      * We support a single environment, so any environment asked
>>> -      * with a priority that is not zero is out of our supported
>>> -      * bounds.
>>> -      */
>>> -     if (prio >= 1)
>>> -             return ENVL_UNKNOWN;
>>> -
>>> -     if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM)
>>> -             return ENVL_EEPROM;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT)
>>> -             return ENVL_FAT;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH)
>>> -             return ENVL_FLASH;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC)
>>> -             return ENVL_MMC;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_NAND)
>>> -             return ENVL_NAND;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_NVRAM)
>>> -             return ENVL_NVRAM;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_REMOTE)
>>> -             return ENVL_REMOTE;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)
>>> -             return ENVL_SPI_FLASH;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_IN_UBI)
>>> -             return ENVL_UBI;
>>> -     else if IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
>>> -             return ENVL_NOWHERE;
>>> -     else
>>> -             return ENVL_UNKNOWN;
>>> +     switch (op) {
>>> +     case ENVOP_GET_CHAR:
>>> +     case ENVOP_INIT:
>>> +     case ENVOP_LOAD:
>>> +             if (prio >= ARRAY_SIZE(env_locations))
>>> +                     return ENVL_UNKNOWN;
>>> +
>>> +             env_load_location = env_locations[prio];
>>> +             return env_load_location;
>>> +
>>> +     case ENVOP_SAVE:
>>> +             return env_load_location;
>>> +     }
>>> +
>>> +     return ENVL_UNKNOWN;
>>>    }
>>>
>>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> https://lists.denx.de/listinfo/u-boot

  parent reply	other threads:[~2018-02-07  8:32 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23 20:16 [U-Boot] [PATCH v3 00/15] env: Multiple env support and env transition for sunxi Maxime Ripard
2018-01-23 20:16 ` [U-Boot] [PATCH v3 01/15] cmd: nvedit: Get rid of the env lookup Maxime Ripard
2018-01-27 19:20   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 02/15] env: Rename env_driver_lookup_default and env_get_default_location Maxime Ripard
2018-01-27 19:20   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 03/15] env: Pass additional parameters to the env lookup function Maxime Ripard
2018-01-27 19:20   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-04-05 10:48   ` [U-Boot] [PATCH v3 " Simon Goldschmidt
2018-01-23 20:16 ` [U-Boot] [PATCH v3 04/15] env: Make the env save message a bit more explicit Maxime Ripard
2018-01-27 19:20   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 05/15] env: Make it explicit where we're loading our environment from Maxime Ripard
2018-01-27 19:20   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 06/15] env: fat: Make the debug messages play a little nicer Maxime Ripard
2018-01-27 19:20   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 07/15] env: mmc: " Maxime Ripard
2018-01-24 13:52   ` Jaehoon Chung
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 08/15] env: common: " Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:16 ` [U-Boot] [PATCH v3 09/15] env: Support multiple environments Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot,v3,09/15] " Tom Rini
2018-01-30  8:19   ` [U-Boot] [PATCH v3 09/15] " Simon Goldschmidt
2018-01-30 19:39     ` York Sun
2018-01-30 20:16       ` York Sun
2018-01-30 23:02         ` York Sun
2018-01-31  6:41           ` Simon Goldschmidt
2018-02-07  8:43           ` Maxime Ripard
2018-02-07 20:18             ` York Sun
2018-02-06  8:09   ` Simon Goldschmidt
2018-02-06  8:20     ` Joakim Tjernlund
2018-02-07  8:18       ` Maxime Ripard
2018-02-07  8:34         ` Joakim Tjernlund
2018-02-07  8:32       ` Simon Goldschmidt [this message]
2018-02-07  8:45         ` Joakim Tjernlund
2018-02-07 18:23           ` Maxime Ripard
2018-02-07  8:19     ` Maxime Ripard
2018-02-07  8:25       ` Simon Goldschmidt
2018-02-07 18:48         ` Maxime Ripard
2018-01-23 20:16 ` [U-Boot] [PATCH v3 10/15] env: Initialise all the environments Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:17 ` [U-Boot] [PATCH v3 11/15] env: mmc: depends on the MMC framework Maxime Ripard
2018-01-24 13:51   ` Jaehoon Chung
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:17 ` [U-Boot] [PATCH v3 12/15] env: Allow to build multiple environments in Kconfig Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-02-01 10:06   ` [U-Boot] [PATCH v3 " Simon Goldschmidt
2018-02-02 19:47     ` Maxime Ripard
2018-01-23 20:17 ` [U-Boot] [PATCH v3 13/15] env: Mark env_get_location as weak Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot,v3,13/15] " Tom Rini
2018-01-30  8:12   ` [U-Boot] [PATCH v3 13/15] " Simon Goldschmidt
2018-01-30  8:18     ` Maxime Ripard
2018-01-23 20:17 ` [U-Boot] [PATCH v3 14/15] sunxi: Transition from the MMC to a FAT-based environment Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-01-23 20:17 ` [U-Boot] [PATCH v3 15/15] env: sunxi: Enable FAT-based environment support by default Maxime Ripard
2018-01-27 19:21   ` [U-Boot] [U-Boot, v3, " Tom Rini
2018-02-07 20:45 [U-Boot] [PATCH v3 09/15] env: Support multiple environments Goldschmidt Simon
2018-02-07 21:18 ` York Sun
2018-02-08  5:30   ` Simon Goldschmidt

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=563b6cc9-e021-3931-cdd3-e98b2e1ffa2b@de.pepperl-fuchs.com \
    --to=sgoldschmidt@de.pepperl-fuchs.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.