Re: [PATCH v4 13/14] env: ext4: add support of command env erase

2020-07-31 Thread Tom Rini
On Tue, Jul 28, 2020 at 11:51:26AM +0200, Patrick Delaunay wrote:

> Add support of opts erase for env in ext4,
> this opts is used by command 'env erase'.
> 
> This command only fill the env file (CONFIG_ENV_EXT4_FILE)
> with 0, the CRC and the saved environment becomes invalid.
> 
> Signed-off-by: Patrick Delaunay 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v4 13/14] env: ext4: add support of command env erase

2020-07-28 Thread Patrick Delaunay
Add support of opts erase for env in ext4,
this opts is used by command 'env erase'.

This command only fill the env file (CONFIG_ENV_EXT4_FILE)
with 0, the CRC and the saved environment becomes invalid.

Signed-off-by: Patrick Delaunay 
---

(no changes since v2)

Changes in v2:
- use CONFIG_IS_ENABLED to set .erase (same as .save)

 env/ext4.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/env/ext4.c b/env/ext4.c
index 0a10a5e050..cc36504154 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -99,6 +99,23 @@ static int env_ext4_save(void)
return 0;
 }
 
+static int env_ext4_erase(void)
+{
+   env_t env_new;
+   int err;
+
+   memset(_new, 0, sizeof(env_t));
+
+   err = env_ext4_save_buffer(_new);
+   if (err)
+   return err;
+
+   gd->env_valid = ENV_INVALID;
+   puts("done\n");
+
+   return 0;
+}
+
 static int env_ext4_load(void)
 {
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -156,4 +173,6 @@ U_BOOT_ENV_LOCATION(ext4) = {
ENV_NAME("EXT4")
.load   = env_ext4_load,
.save   = ENV_SAVE_PTR(env_ext4_save),
+   .erase  = CONFIG_IS_ENABLED(CMD_ERASEENV) ? env_ext4_erase :
+   NULL,
 };
-- 
2.17.1