[U-Boot] [PATCH] spl: fix calling "spl export .." more than once

running "spl export ..." more than once fails with:
Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order ERROR prep subcommand failed! Subcommand failed
reason is commmit: 35fc84fa1f: Refactor the bootm command to reduce code duplication
It used "state != BOOTM_STATE_START" but state is a bitfield, so check if the bit BOOTM_STATE_START is not set. With this fix, "spl export ..." can called more than once ...
Signed-off-by: Heiko Schocher hs@denx.de ---
common/cmd_bootm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 48199bf..4f77f22 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -78,7 +78,8 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_USAGE; }
- if (state != BOOTM_STATE_START && images.state >= state) { + if (((state & BOOTM_STATE_START) != BOOTM_STATE_START) && + images.state >= state) { printf("Trying to execute a command out of order\n"); return CMD_RET_USAGE; }

Hi Heiko,
On 23 February 2015 at 23:04, Heiko Schocher hs@denx.de wrote:
running "spl export ..." more than once fails with:
Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order ERROR prep subcommand failed! Subcommand failed
reason is commmit: 35fc84fa1f: Refactor the bootm command to reduce code duplication
It used "state != BOOTM_STATE_START" but state is a bitfield, so check if the bit BOOTM_STATE_START is not set. With this fix, "spl export ..." can called more than once ...
Signed-off-by: Heiko Schocher hs@denx.de
The original code expected that only one flag would be passed at once (I think that was always the case when the code was first changed). But that is not how we want it to work.
Reviewed-by: Simon Glass sjg@chromium.org
common/cmd_bootm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 48199bf..4f77f22 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -78,7 +78,8 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_USAGE; }
if (state != BOOTM_STATE_START && images.state >= state) {
if (((state & BOOTM_STATE_START) != BOOTM_STATE_START) &&
Maybe simpler as:
if (!(state & BOOTM_STATE_START) &&
images.state >= state) { printf("Trying to execute a command out of order\n"); return CMD_RET_USAGE; }
-- 2.1.0
Regards, Simon

On Tue, Feb 24, 2015 at 07:04:38AM +0100, Heiko Schocher wrote:
running "spl export ..." more than once fails with:
Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order Trying to execute a command out of order ERROR prep subcommand failed! Subcommand failed
reason is commmit: 35fc84fa1f: Refactor the bootm command to reduce code duplication
It used "state != BOOTM_STATE_START" but state is a bitfield, so check if the bit BOOTM_STATE_START is not set. With this fix, "spl export ..." can called more than once ...
Signed-off-by: Heiko Schocher hs@denx.de Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (3)
-
Heiko Schocher
-
Simon Glass
-
Tom Rini