All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 2/4] env: mmc: add erase-function
Date: Mon, 24 Jun 2019 22:19:25 +0200	[thread overview]
Message-ID: <CAAh8qswkpW=1v26hSzGQVhqf8KYGkkVMM24tk5qayYu_+LA7ng@mail.gmail.com> (raw)
In-Reply-To: <FB4BC420-447C-4FEE-AD1B-9E46ADD90A24@public-files.de>

Frank Wunderlich <frank-w@public-files.de> schrieb am Mo., 24. Juni 2019,
22:09:

> You mean passing the offset (normal/redundant) instead of a bool?
>

Would you mind keeping the mail style of this list and stop top-responses
please?

I don't care where you make the difference between bool and actual offset,
but you should keep all this as a changeset to env/mmc.c only to keep it
consistent to existing redundant env code. Don't expose the bool to the env
driver interface or the command file.

Regards,
Simon


> Am 24. Juni 2019 21:40:36 MESZ schrieb Simon Goldschmidt <
> simon.k.r.goldschmidt at gmail.com>:
> >Am 28.04.2019 um 10:51 schrieb Frank Wunderlich:
> >> this adds erase environment for mmc storage
> >>
> >> Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
> >
> >I think this is still too complex.
> >
> >I'd drop patches 3/4 and 4/4 and just erase both redundant storages
> >here
> >in env/mmc.c by calling the actual erase function twice.
> >
> >To do that, it would help to do as I suggested in response to v3: copy
> >the 2-function style used by the save env code, then you can just call
> >that 2nd function twice with a different offset (all in env/mmc.c).
> >
> >Regards,
> >Simon
> >
> >>
> >> squashed fixes:
> >>   - fix bogus indent
> >>   - add CONFIG_CMD_ERASEENV
> >>
> >> Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> >> =2D--
> >>   env/mmc.c | 31 +++++++++++++++++++++++++++++++
> >>   1 file changed, 31 insertions(+)
> >>
> >> diff --git a/env/mmc.c b/env/mmc.c
> >> index c3cf35d01b..9ae9b1a66a 100644
> >> =2D-- a/env/mmc.c
> >> +++ b/env/mmc.c
> >> @@ -242,6 +242,34 @@ fini:
> >>      fini_mmc_for_env(mmc);
> >>      return ret;
> >>   }
> >> +
> >> +#if defined(CONFIG_CMD_ERASEENV)
> >> +static int env_mmc_erase(void)
> >> +{
> >> +    int dev =3D mmc_get_env_dev();
> >> +    struct mmc *mmc =3D find_mmc_device(dev);
> >> +    int n, blk, cnt;
> >> +
> >> +    if (!mmc)
> >> +            return CMD_RET_FAILURE;
> >> +
> >> +    blk =3D CONFIG_ENV_OFFSET / mmc->read_bl_len;
> >> +    cnt =3D CONFIG_ENV_SIZE / mmc->read_bl_len;
> >> +
> >> +    printf("\nMMC erase env: dev # %d, block # %d (0x%x), count %d
> >(0x%x)\n"=
> >> ,
> >> +           dev, blk, blk * mmc->read_bl_len,
> >> +           cnt, cnt * mmc->read_bl_len);
> >> +
> >> +    if (mmc_getwp(mmc) =3D=3D 1) {
> >> +            printf("Error: card is write protected!\n");
> >> +            return CMD_RET_FAILURE;
> >> +    }
> >> +    n =3D blk_derase(mmc_get_blk_desc(mmc), blk, cnt);
> >> +    printf("%d blocks erased: %s\n", n, (n =3D=3D cnt) ? "OK" :
> >"ERROR");
> >> +
> >> +    return (n =3D=3D cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
> >> +}
> >> +#endif /* CONFIG_CMD_ERASEENV */
> >>   #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
> >>
> >>   static inline int read_env(struct mmc *mmc, unsigned long size,
> >> @@ -351,5 +379,8 @@ U_BOOT_ENV_LOCATION(mmc) =3D {
> >>      .load           =3D env_mmc_load,
> >>   #ifndef CONFIG_SPL_BUILD
> >>      .save           =3D env_save_ptr(env_mmc_save),
> >> +#if defined(CONFIG_CMD_ERASEENV)
> >> +    .erase          =3D env_mmc_erase,
> >> +#endif
> >>   #endif
> >>   };
> >> =2D-
> >> 2.17.1
> >>
>

  reply	other threads:[~2019-06-24 20:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-28  8:51 [U-Boot] [PATCH v4 0/4] add command env erase Frank Wunderlich
2019-04-28  8:51 ` [U-Boot] [PATCH v4 1/4] env: register erase command Frank Wunderlich
2019-06-24 19:26   ` Simon Goldschmidt
2019-04-28  8:51 ` [U-Boot] [PATCH v4 2/4] env: mmc: add erase-function Frank Wunderlich
2019-06-24 19:40   ` Simon Goldschmidt
2019-06-24 20:08     ` Frank Wunderlich
2019-06-24 20:19       ` Simon Goldschmidt [this message]
2019-04-28  8:51 ` [U-Boot] [PATCH v4 3/4] env: add option to use redundant offset Frank Wunderlich
2019-04-28  8:51 ` [U-Boot] [PATCH v4 4/4] [RFC] env: call env_erase twice if CONFIG_ENV_OFFSET_REDUND is set Frank Wunderlich
2019-05-20 18:34 ` [U-Boot] [PATCH v4 0/4] add command env erase Frank Wunderlich
2019-06-24 10:30   ` Frank Wunderlich
2019-06-24 18:16     ` Tom Rini
2019-06-24 19:25     ` 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='CAAh8qswkpW=1v26hSzGQVhqf8KYGkkVMM24tk5qayYu_+LA7ng@mail.gmail.com' \
    --to=simon.k.r.goldschmidt@gmail.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.