summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2010-08-25 15:24:01 -0500
committerScott Wood <scottwood@freescale.com>2010-10-11 15:10:26 -0500
commit8c5659a6daa2a3af75ec762d25f40dd053bed26f (patch)
tree1fb1bc5deb620cb717aefc3240714009e297925e
parent30486322517c99f09eabc53f5fad43063656a4f0 (diff)
downloadu-boot-imx-8c5659a6daa2a3af75ec762d25f40dd053bed26f.zip
u-boot-imx-8c5659a6daa2a3af75ec762d25f40dd053bed26f.tar.gz
u-boot-imx-8c5659a6daa2a3af75ec762d25f40dd053bed26f.tar.bz2
nand commands: make only "dump" repeatable.
The dump command is made to increment its address on repeat, as md does. Other commands do not make sense to issue repeatedly, and can be irritating when it happens accidentally, so don't. Signed-off-by: Scott Wood <scottwood@freescale.com> Tested-by: Ben Gardiner <bengardiner@nanometrics.ca>
-rw-r--r--common/cmd_nand.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index dcccc19..8a81237 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -37,10 +37,16 @@ int find_dev_and_part(const char *id, struct mtd_device **dev,
u8 *part_num, struct part_info **part);
#endif
-static int nand_dump(nand_info_t *nand, ulong off, int only_oob)
+static int nand_dump(nand_info_t *nand, ulong off, int only_oob, int repeat)
{
int i;
u_char *datbuf, *oobbuf, *p;
+ static loff_t last;
+
+ if (repeat)
+ off = last + nand->writesize;
+
+ last = off;
datbuf = malloc(nand->writesize + nand->oobsize);
oobbuf = malloc(nand->oobsize);
@@ -381,6 +387,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
#endif
const char *quiet_str = getenv("quiet");
int dev = nand_curr_device;
+ int repeat = flag & CMD_FLAG_REPEAT;
/* at least two arguments please */
if (argc < 2)
@@ -391,6 +398,10 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
cmd = argv[1];
+ /* Only "dump" is repeatable. */
+ if (repeat && strcmp(cmd, "dump"))
+ return 0;
+
if (strcmp(cmd, "info") == 0) {
putc('\n');
@@ -532,16 +543,10 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
if (argc < 3)
goto usage;
- s = strchr(cmd, '.');
off = (int)simple_strtoul(argv[2], NULL, 16);
-
- if (s != NULL && strcmp(s, ".oob") == 0)
- ret = nand_dump(nand, off, 1);
- else
- ret = nand_dump(nand, off, 0);
+ ret = nand_dump(nand, off, !strcmp(&cmd[4], ".oob"), repeat);
return ret == 0 ? 1 : 0;
-
}
if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) {