Commit a5c4067017631d903e1afa6ad615f0ce19fea517
1 parent
8000b086b3
Exists in
master
and in
54 other branches
UBI: Change parsing of size in commands to default to hex
Currently the size parameters of the UBI commands (e.g. "ubi write") are decoded as decimal instead of hex as default. This patch now interprets all these values consistantly as hex, as all other standard U-Boot commands do. Signed-off-by: Stefan Roese <sr@denx.de>
Showing 1 changed file with 4 additions and 32 deletions Side-by-side Diff
common/cmd_ubi.c
... | ... | @@ -29,6 +29,7 @@ |
29 | 29 | |
30 | 30 | /* Private own data */ |
31 | 31 | static struct ubi_device *ubi; |
32 | +static char buffer[80]; | |
32 | 33 | |
33 | 34 | struct selected_dev { |
34 | 35 | char dev_name[32]; /* NAND/OneNAND etc */ |
... | ... | @@ -113,19 +114,6 @@ |
113 | 114 | return 0; |
114 | 115 | } |
115 | 116 | |
116 | -static int parse_num(size_t *num, const char *token) | |
117 | -{ | |
118 | - char *endp; | |
119 | - size_t n; | |
120 | - | |
121 | - n = (size_t) ustrtoul(token, &endp, 0); | |
122 | - if (*endp) | |
123 | - return -EINVAL; | |
124 | - | |
125 | - *num = n; | |
126 | - return 0; | |
127 | -} | |
128 | - | |
129 | 117 | static int verify_mkvol_req(const struct ubi_device *ubi, |
130 | 118 | const struct ubi_mkvol_req *req) |
131 | 119 | { |
... | ... | @@ -378,7 +366,6 @@ |
378 | 366 | tmp = offp; |
379 | 367 | off = do_div(tmp, vol->usable_leb_size); |
380 | 368 | lnum = tmp; |
381 | - printf("off=%d lnum=%d\n", off, lnum); | |
382 | 369 | do { |
383 | 370 | if (off + len >= vol->usable_leb_size) |
384 | 371 | len = vol->usable_leb_size - off; |
385 | 372 | |
... | ... | @@ -397,9 +384,7 @@ |
397 | 384 | size -= len; |
398 | 385 | offp += len; |
399 | 386 | |
400 | - printf("buf = %x\n", (unsigned)buf); | |
401 | 387 | memcpy(buf, tbuf, len); |
402 | - printf("buf[0] = %x\n", buf[0]); | |
403 | 388 | |
404 | 389 | buf += len; |
405 | 390 | len = size > tbuf_size ? tbuf_size : size; |
... | ... | @@ -414,7 +399,6 @@ |
414 | 399 | struct mtd_device *dev; |
415 | 400 | struct part_info *part; |
416 | 401 | struct mtd_partition mtd_part; |
417 | - char buffer[32]; | |
418 | 402 | u8 pnum; |
419 | 403 | int err; |
420 | 404 | |
... | ... | @@ -543,11 +527,7 @@ |
543 | 527 | } |
544 | 528 | /* E.g., create volume size */ |
545 | 529 | if (argc == 4) { |
546 | - err = parse_num(&size, argv[3]); | |
547 | - if (err) { | |
548 | - printf("Incorrect type\n"); | |
549 | - return err; | |
550 | - } | |
530 | + addr = simple_strtoul(argv[3], NULL, 16); | |
551 | 531 | argc--; |
552 | 532 | } |
553 | 533 | /* Use maximum available size */ |
... | ... | @@ -571,11 +551,7 @@ |
571 | 551 | } |
572 | 552 | |
573 | 553 | addr = simple_strtoul(argv[2], NULL, 16); |
574 | - err = parse_num(&size, argv[4]); | |
575 | - if (err) { | |
576 | - printf("Please see usage\n"); | |
577 | - return err; | |
578 | - } | |
554 | + size = simple_strtoul(argv[4], NULL, 16); | |
579 | 555 | |
580 | 556 | return ubi_volume_write(argv[3], (void *)addr, size); |
581 | 557 | } |
... | ... | @@ -585,11 +561,7 @@ |
585 | 561 | |
586 | 562 | /* E.g., read volume size */ |
587 | 563 | if (argc == 5) { |
588 | - err = parse_num(&size, argv[4]); | |
589 | - if (err) { | |
590 | - printf("Please see usage\n"); | |
591 | - return err; | |
592 | - } | |
564 | + size = simple_strtoul(argv[4], NULL, 16); | |
593 | 565 | argc--; |
594 | 566 | } |
595 | 567 |