All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Hershberger <joe.hershberger@ni.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 32/39] env: Rename the redundancy flags
Date: Wed, 31 Jul 2019 21:20:58 +0000	[thread overview]
Message-ID: <CANr=Z=YDBS=hC=nEQZoi4PRLwrFVu9MHMWmyjCOut1Ua=B_ooA@mail.gmail.com> (raw)
In-Reply-To: <CAPnjgZ3Sg0m=k_PZfKNa5gcHwj-KGY1O3whPNAz86m7tP_5jnQ@mail.gmail.com>

On Wed, Jul 31, 2019 at 4:00 PM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Joe,
>
> On Tue, 30 Jul 2019 at 15:42, Joe Hershberger <joe.hershberger@ni.com> wrote:
> >
> > On Sun, Jul 28, 2019 at 9:27 AM Simon Glass <sjg@chromium.org> wrote:
> > >
> > > Add an ENV prefix to these two flags so that it is clear what they relate
> > > to. Also move them to env.h since they are part of the public API. Use an
> > > enum rather than a #define to tie them together.
> > >
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > ---
> > >
> > >  cmd/nvedit.c          |  2 +-
> > >  env/eeprom.c          | 10 ++++++----
> > >  env/flash.c           | 18 ++++++++++--------
> > >  env/sf.c              |  6 ++----
> > >  include/env.h         |  6 ++++++
> > >  include/environment.h |  5 +----
> > >  tools/env/fw_env.c    | 23 +++++++++++++----------
> > >  7 files changed, 39 insertions(+), 31 deletions(-)
> > >
> > > diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> > > index 7908d6cf0c..d6a86abb03 100644
> > > --- a/cmd/nvedit.c
> > > +++ b/cmd/nvedit.c
> > > @@ -1014,7 +1014,7 @@ NXTARG:           ;
> > >                 envp->crc = crc32(0, envp->data,
> > >                                 size ? size - offsetof(env_t, data) : ENV_SIZE);
> > >  #ifdef CONFIG_ENV_ADDR_REDUND
> > > -               envp->flags = ACTIVE_FLAG;
> > > +               envp->flags = ENVF_REDUND_ACTIVE;
> > >  #endif
> > >         }
> > >         env_set_hex("filesize", len + offsetof(env_t, data));
> > > diff --git a/env/eeprom.c b/env/eeprom.c
> > > index 8d82cf892c..0c30ca459c 100644
> > > --- a/env/eeprom.c
> > > +++ b/env/eeprom.c
> > > @@ -132,9 +132,11 @@ static int env_eeprom_load(void)
> > >                 gd->env_valid = ENV_REDUND;
> > >         } else {
> > >                 /* both ok - check serial */
> > > -               if (flags[0] == ACTIVE_FLAG && flags[1] == OBSOLETE_FLAG)
> > > +               if (flags[0] == ENVF_REDUND_ACTIVE &&
> > > +                   flags[1] == ENVF_REDUND_OBSOLETE)
> > >                         gd->env_valid = ENV_VALID;
> > > -               else if (flags[0] == OBSOLETE_FLAG && flags[1] == ACTIVE_FLAG)
> > > +               else if (flags[0] == ENVF_REDUND_OBSOLETE &&
> > > +                        flags[1] == ENVF_REDUND_ACTIVE)
> > >                         gd->env_valid = ENV_REDUND;
> > >                 else if (flags[0] == 0xFF && flags[1] == 0)
> > >                         gd->env_valid = ENV_REDUND;
> > > @@ -194,7 +196,7 @@ static int env_eeprom_save(void)
> > >         unsigned int off        = CONFIG_ENV_OFFSET;
> > >  #ifdef CONFIG_ENV_OFFSET_REDUND
> > >         unsigned int off_red    = CONFIG_ENV_OFFSET_REDUND;
> > > -       char flag_obsolete      = OBSOLETE_FLAG;
> > > +       char flag_obsolete      = ENVF_REDUND_OBSOLETE;
> > >  #endif
> > >
> > >         rc = env_export(&env_new);
> > > @@ -207,7 +209,7 @@ static int env_eeprom_save(void)
> > >                 off_red = CONFIG_ENV_OFFSET;
> > >         }
> > >
> > > -       env_new.flags = ACTIVE_FLAG;
> > > +       env_new.flags = ENVF_REDUND_ACTIVE;
> > >  #endif
> > >
> > >         rc = eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
> > > diff --git a/env/flash.c b/env/flash.c
> > > index 7a73466cf2..9566dd7f05 100644
> > > --- a/env/flash.c
> > > +++ b/env/flash.c
> > > @@ -95,10 +95,12 @@ static int env_flash_init(void)
> > >         } else if (!crc1_ok && !crc2_ok) {
> > >                 gd->env_addr    = addr_default;
> > >                 gd->env_valid   = ENV_INVALID;
> > > -       } else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) {
> > > +       } else if (flag1 == ENVF_REDUND_ACTIVE &&
> > > +                  flag2 == ENVF_REDUND_OBSOLETE) {
> > >                 gd->env_addr    = addr1;
> > >                 gd->env_valid   = ENV_VALID;
> > > -       } else if (flag1 == OBSOLETE_FLAG && flag2 == ACTIVE_FLAG) {
> > > +       } else if (flag1 == ENVF_REDUND_OBSOLETE &&
> > > +                  flag2 == ENVF_REDUND_ACTIVE) {
> > >                 gd->env_addr    = addr2;
> > >                 gd->env_valid   = ENV_VALID;
> > >         } else if (flag1 == flag2) {
> > > @@ -121,7 +123,7 @@ static int env_flash_save(void)
> > >  {
> > >         env_t   env_new;
> > >         char    *saved_data = NULL;
> > > -       char    flag = OBSOLETE_FLAG, new_flag = ACTIVE_FLAG;
> > > +       char    flag = ENVF_REDUND_OBSOLETE, new_flag = ENVF_REDUND_ACTIVE;
> > >         int     rc = 1;
> > >  #if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE
> > >         ulong   up_data = 0;
> > > @@ -322,9 +324,9 @@ static int env_flash_load(void)
> > >                 end_addr_new = ltmp;
> > >         }
> > >
> > > -       if (flash_addr_new->flags != OBSOLETE_FLAG &&
> > > +       if (flash_addr_new->flags != ENVF_REDUND_OBSOLETE &&
> > >             crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc) {
> > > -               char flag = OBSOLETE_FLAG;
> > > +               char flag = ENVF_REDUND_OBSOLETE;
> > >
> > >                 gd->env_valid = ENV_REDUND;
> > >                 flash_sect_protect(0, (ulong)flash_addr_new, end_addr_new);
> > > @@ -334,9 +336,9 @@ static int env_flash_load(void)
> > >                 flash_sect_protect(1, (ulong)flash_addr_new, end_addr_new);
> > >         }
> > >
> > > -       if (flash_addr->flags != ACTIVE_FLAG &&
> > > -           (flash_addr->flags & ACTIVE_FLAG) == ACTIVE_FLAG) {
> > > -               char flag = ACTIVE_FLAG;
> > > +       if (flash_addr->flags != ENVF_REDUND_ACTIVE &&
> > > +           (flash_addr->flags & ENVF_REDUND_ACTIVE) == ENVF_REDUND_ACTIVE) {
> > > +               char flag = ENVF_REDUND_ACTIVE;
> > >
> > >                 gd->env_valid = ENV_REDUND;
> > >                 flash_sect_protect(0, (ulong)flash_addr, end_addr);
> > > diff --git a/env/sf.c b/env/sf.c
> > > index 5531293e05..ae4136926b 100644
> > > --- a/env/sf.c
> > > +++ b/env/sf.c
> > > @@ -30,8 +30,6 @@ static ulong env_offset               = CONFIG_ENV_OFFSET;
> > >  static ulong env_new_offset    = CONFIG_ENV_OFFSET_REDUND;
> > >  #endif
> > >
> > > -#define ACTIVE_FLAG    1
> > > -#define OBSOLETE_FLAG  0
> > >  #endif /* CONFIG_ENV_OFFSET_REDUND */
> > >
> > >  DECLARE_GLOBAL_DATA_PTR;
> > > @@ -74,7 +72,7 @@ static int setup_flash_device(void)
> > >  static int env_sf_save(void)
> > >  {
> > >         env_t   env_new;
> > > -       char    *saved_buffer = NULL, flag = OBSOLETE_FLAG;
> > > +       char    *saved_buffer = NULL, flag = ENVF_REDUND_OBSOLETE;
> > >         u32     saved_size, saved_offset, sector;
> > >         int     ret;
> > >
> > > @@ -85,7 +83,7 @@ static int env_sf_save(void)
> > >         ret = env_export(&env_new);
> > >         if (ret)
> > >                 return -EIO;
> > > -       env_new.flags   = ACTIVE_FLAG;
> > > +       env_new.flags   = ENVF_REDUND_ACTIVE;
> > >
> > >         if (gd->env_valid == ENV_VALID) {
> > >                 env_new_offset = CONFIG_ENV_OFFSET_REDUND;
> > > diff --git a/include/env.h b/include/env.h
> > > index 3dbdf276cd..884b036d02 100644
> > > --- a/include/env.h
> > > +++ b/include/env.h
> > > @@ -55,6 +55,12 @@ struct env_clbk_tbl {
> > >         {#name, callback}
> > >  #endif
> > >
> > > +/** enum env_redund_flags - Flags for the redundand_environment */
> >
> > redundand_environment  -> redundant_environment
> >
> > Argh... that's actually the name of the function!?
>
> Yes
>
> >
> > Now I see that there was a patch for this [1] , but is assigned to Tom
> > and is deferred. What happened!?
> >
> > [1] - https://patchwork.ozlabs.org/patch/275224/
>
> Not a lot :-)

Was there a problem with it or just forgotten about. Tom?

It would be nice to recreate it in the modern codebase.

>
> >
> > > +enum env_redund_flags {
> > > +       ENVF_REDUND_OBSOLETE = 0,
> > > +       ENVF_REDUND_ACTIVE = 1,
> >
> > Again, I think just ENV here would be nicer.
>
> OK.
>
> - Simon
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

  reply	other threads:[~2019-07-31 21:20 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-28 14:03 [U-Boot] [PATCH 00/39] env: common: Remove environment definitions from common.h Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 01/39] common: Move gzip functions into a new gzip header Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 02/39] common: Drop the dpram_... functions Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 03/39] common: Move lcd_setmem() to lcd.h Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 04/39] common: Remove video_setmem() Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 05/39] env: Create a new file for environment functions Simon Glass
2019-07-30 20:52   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 06/39] env: Move get_env_id() to env.h Simon Glass
2019-07-30 20:51   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 07/39] env: Move env_get_f() " Simon Glass
2019-07-30 20:50   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 08/39] env: Move env_init() " Simon Glass
2019-07-30 20:53   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 09/39] env: Move env_relocate() " Simon Glass
2019-07-30 20:48   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 10/39] env: Move envmatch() " Simon Glass
2019-07-30 21:02   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 11/39] env: Move env_set_hex() " Simon Glass
2019-07-30 20:49   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 12/39] env: Move env_set_ulong() " Simon Glass
2019-07-30 21:05   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 13/39] env: Move env_get_ulong() " Simon Glass
2019-07-30 20:54   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 14/39] env: Move env_get_yesno() " Simon Glass
2019-07-30 20:49   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 15/39] env: Move env_get_hex() " Simon Glass
2019-07-30 20:49   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 16/39] env: Move env_set() " Simon Glass
2019-07-30 21:19   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 17/39] env: Move env_get() " Simon Glass
2019-07-30 21:04   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 18/39] env: Move eth_env_get/set_enetaddr() " Simon Glass
2019-07-30 20:55   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 19/39] env: Move uncommon functions " Simon Glass
2019-07-30 21:01   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 20/39] env: Move set_default_vars " Simon Glass
2019-07-30 20:59   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 21/39] env: Move env_load/save functions " Simon Glass
2019-07-30 20:57   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 22/39] env: Move env import/export " Simon Glass
2019-07-30 20:58   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 23/39] env: Drop env_crc_update() Simon Glass
2019-07-30 21:21   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 24/39] env: Move get/set_default_env() to env.h Simon Glass
2019-07-30 20:54   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 25/39] env: Move env_get_char() " Simon Glass
2019-07-30 21:21   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 26/39] env: Move env_reloc() " Simon Glass
2019-07-30 21:22   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 27/39] env: Rename environment to embedded_environment Simon Glass
2019-07-30 21:22   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 28/39] env: Move env_valid to env.h Simon Glass
2019-07-30 20:56   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 29/39] env: Move callback definitions " Simon Glass
2019-07-30 21:28   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 30/39] env: Drop the ENTRY typdef Simon Glass
2019-07-30 21:16   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 31/39] env: Drop _ENTRY Simon Glass
2019-07-30 21:35   ` Joe Hershberger
2019-07-31 20:57     ` Simon Glass
2019-07-31 21:07       ` Joe Hershberger
2019-07-31 21:55         ` Simon Glass
2019-07-31 22:03           ` Joe Hershberger
2019-08-02 14:07             ` Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 32/39] env: Rename the redundancy flags Simon Glass
2019-07-30 21:49   ` Joe Hershberger
2019-07-31 21:00     ` Simon Glass
2019-07-31 21:20       ` Joe Hershberger [this message]
2019-08-01  0:52         ` Tom Rini
2019-08-01  0:55           ` Joe Hershberger
2019-08-01 23:04             ` Tom Rini
2019-07-28 14:03 ` [U-Boot] [PATCH 33/39] env: Drop the ACTION typedef Simon Glass
2019-07-30 21:13   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 34/39] env: Drop the double underscores in search.h Simon Glass
2019-07-30 21:29   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 35/39] env: Move TOTAL_MALLOC_LEN to environment.h Simon Glass
2019-07-30 21:14   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 36/39] env: Drop environment.h header file where not needed Simon Glass
2019-07-30 21:20   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 37/39] env: Rename environment.h to env_internal.h Simon Glass
2019-07-30 21:02   ` Joe Hershberger
2019-07-28 14:03 ` [U-Boot] [PATCH 38/39] Drop PCMCIA Simon Glass
2019-07-28 14:03 ` [U-Boot] [PATCH 39/39] common: Add a note about the effort to reduce common.h Simon Glass

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='CANr=Z=YDBS=hC=nEQZoi4PRLwrFVu9MHMWmyjCOut1Ua=B_ooA@mail.gmail.com' \
    --to=joe.hershberger@ni.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.