env: register erase command

this patch adds basic changes for adding a erase-subcommand to env

with this command the environment stored on non-volatile storage written
by saveenv can be cleared.

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>

squashed fixes
 - start message with "Erasing"
 - mark erase-function as optional
 - env: separate eraseenv from saveenv

Suggested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
This commit is contained in:
Frank Wunderlich
2019-06-29 11:36:19 +02:00
committed by Tom Rini
parent 4225f830c5
commit cd121bdb6d
4 changed files with 75 additions and 0 deletions

View File

@@ -200,6 +200,7 @@ enum env_operation {
ENVOP_INIT, /* we want to call the init function */
ENVOP_LOAD, /* we want to call the load function */
ENVOP_SAVE, /* we want to call the save function */
ENVOP_ERASE, /* we want to call the erase function */
};
struct env_driver {
@@ -225,6 +226,15 @@ struct env_driver {
*/
int (*save)(void);
/**
* erase() - Erase the environment on storage
*
* This method is optional and required for 'eraseenv' to work.
*
* @return 0 if OK, -ve on error
*/
int (*erase)(void);
/**
* init() - Set up the initial pre-relocation environment
*
@@ -303,6 +313,13 @@ int env_load(void);
*/
int env_save(void);
/**
* env_erase() - Erase the environment on storage
*
* @return 0 if OK, -ve on error
*/
int env_erase(void);
/**
* env_fix_drivers() - Updates envdriver as per relocation
*/