diff options
author | Rostislav Lisovy <lisovy@gmail.com> | 2014-09-16 14:38:52 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-09-24 18:30:29 -0400 |
commit | 93d3232d9607669f33a34d3a552b24e1d727413b (patch) | |
tree | b2f65d29e91a3e34fe6f4466e2fe47e1a317f8e9 | |
parent | 97d5e9d149ca910e1bd20d06a13b9e9cceb0e502 (diff) | |
download | u-boot-imx-93d3232d9607669f33a34d3a552b24e1d727413b.zip u-boot-imx-93d3232d9607669f33a34d3a552b24e1d727413b.tar.gz u-boot-imx-93d3232d9607669f33a34d3a552b24e1d727413b.tar.bz2 |
cmd_nand: Update (nand_info_t*)nand after arg_off(_size) call
The arg_off() and arg_off_size() update the 'current NAND
device' variable (dev). This is then used when assigning the
(nand_info_t*)nand value. Place the assignment after the
arg_off(_size) calls to prevent using incorrect (nand_info_t*)
nand value.
Signed-off-by: Rostislav Lisovy <lisovy@merica.cz>
-rw-r--r-- | common/cmd_nand.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/cmd_nand.c b/common/cmd_nand.c index f9ced9d..7f962dc 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -647,8 +647,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */ printf("\nNAND %s: ", read ? "read" : "write"); - nand = &nand_info[dev]; - s = strchr(cmd, '.'); if (s && !strcmp(s, ".raw")) { @@ -657,6 +655,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (arg_off(argv[3], &dev, &off, &size, &maxsize)) return 1; + nand = &nand_info[dev]; + if (argc > 4 && !str2long(argv[4], &pagecount)) { printf("'%s' is not a number\n", argv[4]); return 1; @@ -679,6 +679,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) rwsize = size; } + nand = &nand_info[dev]; + if (!s || !strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")) { if (read) |