[U-Boot] [PATCH] saveenv: standardize enablement

Rather than special casing each environment type for enabling the saveenv command, have them all behave the same. This avoids bitrot as new env sources are added/removed.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- common/cmd_nvedit.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 85025da..b93de13 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -546,11 +546,8 @@ int getenv_r (char *name, char *buf, unsigned len) return (-1); }
-#if ((defined(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ - && !defined(CONFIG_ENV_IS_NOWHERE)) +#if defined(CONFIG_CMD_ENV) && !defined(CONFIG_ENV_IS_NOWHERE) + int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { extern char * env_name_spec; @@ -560,6 +557,12 @@ int do_saveenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return (saveenv() ? 1 : 0); }
+U_BOOT_CMD( + saveenv, 1, 0, do_saveenv, + "saveenv - save environment variables to persistent storage\n", + NULL +); + #endif
@@ -602,19 +605,6 @@ U_BOOT_CMD( " - delete environment variable 'name'\n" );
-#if ((defined(CONFIG_ENV_IS_IN_NVRAM) || defined(CONFIG_ENV_IS_IN_EEPROM) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_FLASH)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_NAND)) \ - || (defined(CONFIG_CMD_ENV) && defined(CONFIG_CMD_ONENAND))) \ - && !defined(CONFIG_ENV_IS_NOWHERE)) -U_BOOT_CMD( - saveenv, 1, 0, do_saveenv, - "saveenv - save environment variables to persistent storage\n", - NULL -); - -#endif - #if defined(CONFIG_CMD_ASKENV)
U_BOOT_CMD(

Dear Mike Frysinger,
In message 1230623965-16546-1-git-send-email-vapier@gentoo.org you wrote:
Rather than special casing each environment type for enabling the saveenv command, have them all behave the same. This avoids bitrot as new env sources are added/removed.
Signed-off-by: Mike Frysinger vapier@gentoo.org
common/cmd_nvedit.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Dear Mike,
In message 1230623965-16546-1-git-send-email-vapier@gentoo.org you wrote:
Rather than special casing each environment type for enabling the saveenv command, have them all behave the same. This avoids bitrot as new env sources are added/removed.
Signed-off-by: Mike Frysinger vapier@gentoo.org
common/cmd_nvedit.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-)
This patch breaks support for the
This board is a bit unusual as it is ROM based - it has CONFIG_ENV_IS_IN_FLASH set because the default environment is embedded in the ROM, but does not enable the flash driver (because there is no flash on the board). So the test in "common/cmd_nvedit.c":
549 #if defined(CONFIG_CMD_ENV) && !defined(CONFIG_ENV_IS_NOWHERE)
fails - it enables do_saveenv(), but there is no underlying saveenv() function. Result:
common/libcommon.a(cmd_nvedit.o): In function `do_saveenv': common/cmd_nvedit.c:557: undefined reference to `saveenv' make: *** [u-boot] Error 1
Please fix.
Best regards,
Wolfgang Denk

On Wednesday 28 January 2009 03:17:06 Wolfgang Denk wrote:
In message 1230623965-16546-1-git-send-email-vapier@gentoo.org you wrote:
Rather than special casing each environment type for enabling the saveenv command, have them all behave the same. This avoids bitrot as new env sources are added/removed.
Signed-off-by: Mike Frysinger vapier@gentoo.org
common/cmd_nvedit.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-)
This patch breaks support for the
looks like the actual board name was missed in your e-mail ? -mike

Dear Mike Frysinger,
In message 200901280350.10310.vapier@gentoo.org you wrote:
This patch breaks support for the
looks like the actual board name was missed in your e-mail ?
Oops.
... for the SPD823TS board.
Thanks.
Best regards,
Wolfgang Denk

Since the SPD823TS board does not actually have any writable flash to save its environment, undefine CONFIG_CMD_ENV so the "saveenv" command is disabled.
This fixes the build error: common/libcommon.a(cmd_nvedit.o): In function `do_saveenv': common/cmd_nvedit.c:557: undefined reference to `saveenv' make: *** [u-boot] Error 1
Signed-off-by: Mike Frysinger vapier@gentoo.org --- include/configs/SPD823TS.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/configs/SPD823TS.h b/include/configs/SPD823TS.h index 9201346..d4154d2 100644 --- a/include/configs/SPD823TS.h +++ b/include/configs/SPD823TS.h @@ -67,6 +67,7 @@
#define CONFIG_CMD_IDE
+#undef CONFIG_CMD_ENV #undef CONFIG_CMD_FLASH

On Wednesday 28 January 2009 13:48:55 Mike Frysinger wrote:
Since the SPD823TS board does not actually have any writable flash to save its environment, undefine CONFIG_CMD_ENV so the "saveenv" command is disabled.
btw, i find the "CONFIG_CMD_ENV -> saveenv" bindings a bit confusing. any qualms with doing a giant sed to convert it to CONFIG_CMD_SAVEENV ? sed -i 's:CONFIG_CMD_ENV>:CONFIG_CMD_SAVEENV:g' \ include/*.h include/configs/*.h common/*.c README -mike

Dear Mike Frysinger,
In message 200901281354.18466.vapier@gentoo.org you wrote:
btw, i find the "CONFIG_CMD_ENV -> saveenv" bindings a bit confusing. any qualms with doing a giant sed to convert it to CONFIG_CMD_SAVEENV ? sed -i 's:CONFIG_CMD_ENV>:CONFIG_CMD_SAVEENV:g' \ include/*.h include/configs/*.h common/*.c README
Feel free to go on.
Best regards,
Wolfgang Denk

Dear Mike Frysinger,
In message 1233168535-16153-1-git-send-email-vapier@gentoo.org you wrote:
Since the SPD823TS board does not actually have any writable flash to save its environment, undefine CONFIG_CMD_ENV so the "saveenv" command is disabled.
This fixes the build error: common/libcommon.a(cmd_nvedit.o): In function `do_saveenv': common/cmd_nvedit.c:557: undefined reference to `saveenv' make: *** [u-boot] Error 1
Signed-off-by: Mike Frysinger vapier@gentoo.org
include/configs/SPD823TS.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
participants (2)
-
Mike Frysinger
-
Wolfgang Denk