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

Am 24. Juni 2019 21:40:36 MESZ schrieb Simon Goldschmidt 
<simon.k.r.goldschm...@gmail.com>:
>Am 28.04.2019 um 10:51 schrieb Frank Wunderlich:
>> this adds erase environment for mmc storage
>> 
>> Signed-off-by: Frank Wunderlich <fran...@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.goldschm...@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
>> 
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to