On Fri, May 01, 2009 at 04:24:20PM -0400, Josh Karabin wrote: > @@ -119,8 +121,12 @@ arg_off_size(int argc, char *argv[], nand_info_t *nand, > ulong *off, size_t *size > } > *off = part->offset; > if (argc >= 2) { > - if (!(str2long(argv[1], (ulong *)size))) { > - printf("'%s' is not a number\n", > argv[1]); > + if (plussed && *ps == '+') { > + *plussed = 1; > + ps++; > + } > + if (!(str2long(ps, (ulong *)size))) { > + printf("'%s' is not a number\n", ps); > return -1; > } > if (*size > part->size) > @@ -145,8 +151,12 @@ arg_off_size(int argc, char *argv[], nand_info_t *nand, > ulong *off, size_t *size > } > > if (argc >= 2) { > - if (!(str2long(argv[1], (ulong *)size))) { > - printf("'%s' is not a number\n", argv[1]); > + if (plussed && *ps == '+') { > + *plussed = 1; > + ps++; > + } > + if (!(str2long(ps, (ulong *)size))) { > + printf("'%s' is not a number\n", ps); > return -1;
Hmm... would be nice to untangle the duplicated code path rather than add more stuff to both branches. > @@ -317,7 +327,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char > *argv[]) > > printf("\nNAND %s: ", scrub ? "scrub" : "erase"); > /* skip first two or three arguments, look for offset and size > */ > - if (arg_off_size(argc - o, argv + o, nand, &off, &size) != 0) > + if (arg_off_size(argc - o, argv + o, nand, &off, &size, NULL) > != 0) > return 1; > > memset(&opts, 0, sizeof(opts)); > @@ -378,8 +388,18 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char > *argv[]) > > read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */ > printf("\nNAND %s: ", read ? "read" : "write"); > - if (arg_off_size(argc - 3, argv + 3, nand, &off, &size) != 0) > + if (read && arg_off_size(argc - 3, argv + 3, nand, &off, &size, > NULL) != 0) > return 1; > + else if (!read) { > + int plussed = 0; > + if (arg_off_size(argc - 3, argv + 3, nand, &off, &size, > &plussed) != 0) > + return 1; Why not support plussed for read as well? > + if (plussed) { > + int tailsize = size & (nand->writesize - 1); > + memset ((u_char *)addr + size, 0xff, > nand->writesize - tailsize); > + size += nand->writesize - tailsize; NACK, you cannot write to arbitrary memory beyond the end of the range specified. Allocate a buffer to hold the partial page. Plus, this will append an entire page of padding if the size does happen to be page-aligned. > + } > + } Please keep lines under 80 characters. -Scott _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot