diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/adc.c | 33 | ||||
-rw-r--r-- | cmd/dtimg.c | 2 | ||||
-rw-r--r-- | cmd/gpio.c | 2 | ||||
-rw-r--r-- | cmd/help.c | 2 | ||||
-rw-r--r-- | cmd/mmc.c | 13 | ||||
-rw-r--r-- | cmd/mtd.c | 448 | ||||
-rw-r--r-- | cmd/nvedit.c | 4 | ||||
-rw-r--r-- | cmd/sf.c | 2 | ||||
-rw-r--r-- | cmd/tpm-v2.c | 2 | ||||
-rw-r--r-- | cmd/ubi.c | 6 | ||||
-rw-r--r-- | cmd/unzip.c | 2 | ||||
-rw-r--r-- | cmd/zip.c | 2 |
12 files changed, 293 insertions, 225 deletions
@@ -146,37 +146,14 @@ static int do_adc_scan(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } -static cmd_tbl_t cmd_adc_sub[] = { - U_BOOT_CMD_MKENT(list, 1, 1, do_adc_list, "", ""), - U_BOOT_CMD_MKENT(info, 2, 1, do_adc_info, "", ""), - U_BOOT_CMD_MKENT(single, 3, 1, do_adc_single, "", ""), - U_BOOT_CMD_MKENT(scan, 3, 1, do_adc_scan, "", ""), -}; - -static int do_adc(cmd_tbl_t *cmdtp, int flag, int argc, - char *const argv[]) -{ - cmd_tbl_t *c; - - if (argc < 2) - return CMD_RET_USAGE; - - /* Strip off leading 'adc' command argument */ - argc--; - argv++; - - c = find_cmd_tbl(argv[0], &cmd_adc_sub[0], ARRAY_SIZE(cmd_adc_sub)); - - if (c) - return c->cmd(cmdtp, flag, argc, argv); - else - return CMD_RET_USAGE; -} - static char adc_help_text[] = "list - list ADC devices\n" "adc info <name> - Get ADC device info\n" "adc single <name> <channel> - Get Single data of ADC device channel\n" "adc scan <name> [channel mask] - Scan all [or masked] ADC channels"; -U_BOOT_CMD(adc, 4, 1, do_adc, "ADC sub-system", adc_help_text); +U_BOOT_CMD_WITH_SUBCMDS(adc, "ADC sub-system", adc_help_text, + U_BOOT_SUBCMD_MKENT(list, 1, 1, do_adc_list), + U_BOOT_SUBCMD_MKENT(info, 2, 1, do_adc_info), + U_BOOT_SUBCMD_MKENT(single, 3, 1, do_adc_single), + U_BOOT_SUBCMD_MKENT(scan, 3, 1, do_adc_scan)); diff --git a/cmd/dtimg.c b/cmd/dtimg.c index 65c8d101b9..ae7d82f26d 100644 --- a/cmd/dtimg.c +++ b/cmd/dtimg.c @@ -116,7 +116,7 @@ static int do_dtimg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!cp || argc > cp->maxargs) return CMD_RET_USAGE; - if (flag == CMD_FLAG_REPEAT && !cp->repeatable) + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) return CMD_RET_SUCCESS; return cp->cmd(cmdtp, flag, argc, argv); diff --git a/cmd/gpio.c b/cmd/gpio.c index ecdc453918..c60946bc06 100644 --- a/cmd/gpio.c +++ b/cmd/gpio.c @@ -213,7 +213,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } gpio_direction_output(gpio, value); } - printf("gpio: pin %s (gpio %i) value is ", str_gpio, gpio); + printf("gpio: pin %s (gpio %u) value is ", str_gpio, gpio); if (IS_ERR_VALUE(value)) printf("unknown (ret=%d)\n", value); else diff --git a/cmd/help.c b/cmd/help.c index 503fa632e7..fa2010c67e 100644 --- a/cmd/help.c +++ b/cmd/help.c @@ -29,7 +29,7 @@ U_BOOT_CMD( /* This does not use the U_BOOT_CMD macro as ? can't be used in symbol names */ ll_entry_declare(cmd_tbl_t, question_mark, cmd) = { - "?", CONFIG_SYS_MAXARGS, 1, do_help, + "?", CONFIG_SYS_MAXARGS, cmd_always_repeatable, do_help, "alias for 'help'", #ifdef CONFIG_SYS_LONGHELP "" @@ -101,10 +101,19 @@ static struct mmc *init_mmc_device(int dev, bool force_init) return NULL; } + if (!mmc_getcd(mmc)) + force_init = true; + if (force_init) mmc->has_init = 0; if (mmc_init(mmc)) return NULL; + +#ifdef CONFIG_BLOCK_CACHE + struct blk_desc *bd = mmc_get_blk_desc(mmc); + blkcache_invalidate(bd->if_type, bd->devnum); +#endif + return mmc; } static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) @@ -247,7 +256,7 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag, if (cp == NULL || argc > cp->maxargs) return CMD_RET_USAGE; - if (flag == CMD_FLAG_REPEAT && !cp->repeatable) + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) return CMD_RET_SUCCESS; mmc = init_mmc_device(curr_device, false); @@ -907,7 +916,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (cp == NULL || argc > cp->maxargs) return CMD_RET_USAGE; - if (flag == CMD_FLAG_REPEAT && !cp->repeatable) + if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) return CMD_RET_SUCCESS; if (curr_device < 0) { @@ -15,6 +15,22 @@ #include <mapmem.h> #include <mtd.h> +#include <linux/ctype.h> + +static struct mtd_info *get_mtd_by_name(const char *name) +{ + struct mtd_info *mtd; + + mtd_probe_devices(); + + mtd = get_mtd_device_nm(name); + if (IS_ERR_OR_NULL(mtd)) + printf("MTD device %s not found, ret %ld\n", name, + PTR_ERR(mtd)); + + return mtd; +} + static uint mtd_len_to_pages(struct mtd_info *mtd, u64 len) { do_div(len, mtd->writesize); @@ -177,7 +193,8 @@ static bool mtd_oob_write_is_empty(struct mtd_oob_ops *op) return true; } -static int do_mtd_list(void) +static int do_mtd_list(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) { struct mtd_info *mtd; int dev_nb = 0; @@ -221,229 +238,287 @@ static int mtd_special_write_oob(struct mtd_info *mtd, u64 off, return ret; } -static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_mtd_io(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { + bool dump, read, raw, woob, write_empty_pages, has_pages = false; + u64 start_off, off, len, remaining, default_len; + struct mtd_oob_ops io_op = {}; + uint user_addr = 0, npages; + const char *cmd = argv[0]; struct mtd_info *mtd; - const char *cmd; - char *mtd_name; + u32 oob_len; + u8 *buf; + int ret; - /* All MTD commands need at least two arguments */ if (argc < 2) return CMD_RET_USAGE; - /* Parse the command name and its optional suffixes */ - cmd = argv[1]; + mtd = get_mtd_by_name(argv[1]); + if (IS_ERR_OR_NULL(mtd)) + return CMD_RET_FAILURE; - /* List the MTD devices if that is what the user wants */ - if (strcmp(cmd, "list") == 0) - return do_mtd_list(); + if (mtd->type == MTD_NANDFLASH || mtd->type == MTD_MLCNANDFLASH) + has_pages = true; - /* - * The remaining commands require also at least a device ID. - * Check the selected device is valid. Ensure it is probed. - */ - if (argc < 3) - return CMD_RET_USAGE; + dump = !strncmp(cmd, "dump", 4); + read = dump || !strncmp(cmd, "read", 4); + raw = strstr(cmd, ".raw"); + woob = strstr(cmd, ".oob"); + write_empty_pages = !has_pages || strstr(cmd, ".dontskipff"); - mtd_name = argv[2]; - mtd_probe_devices(); - mtd = get_mtd_device_nm(mtd_name); - if (IS_ERR_OR_NULL(mtd)) { - printf("MTD device %s not found, ret %ld\n", - mtd_name, PTR_ERR(mtd)); - return CMD_RET_FAILURE; - } - put_mtd_device(mtd); + argc -= 2; + argv += 2; - argc -= 3; - argv += 3; - - /* Do the parsing */ - if (!strncmp(cmd, "read", 4) || !strncmp(cmd, "dump", 4) || - !strncmp(cmd, "write", 5)) { - bool has_pages = mtd->type == MTD_NANDFLASH || - mtd->type == MTD_MLCNANDFLASH; - bool dump, read, raw, woob, write_empty_pages; - struct mtd_oob_ops io_op = {}; - uint user_addr = 0, npages; - u64 start_off, off, len, remaining, default_len; - u32 oob_len; - u8 *buf; - int ret; - - dump = !strncmp(cmd, "dump", 4); - read = dump || !strncmp(cmd, "read", 4); - raw = strstr(cmd, ".raw"); - woob = strstr(cmd, ".oob"); - write_empty_pages = !has_pages || strstr(cmd, ".dontskipff"); - - if (!dump) { - if (!argc) - return CMD_RET_USAGE; - - user_addr = simple_strtoul(argv[0], NULL, 16); - argc--; - argv++; + if (!dump) { + if (!argc) { + ret = CMD_RET_USAGE; + goto out_put_mtd; } - start_off = argc > 0 ? simple_strtoul(argv[0], NULL, 16) : 0; - if (!mtd_is_aligned_with_min_io_size(mtd, start_off)) { - printf("Offset not aligned with a page (0x%x)\n", - mtd->writesize); - return CMD_RET_FAILURE; - } + user_addr = simple_strtoul(argv[0], NULL, 16); + argc--; + argv++; + } - default_len = dump ? mtd->writesize : mtd->size; - len = argc > 1 ? simple_strtoul(argv[1], NULL, 16) : - default_len; - if (!mtd_is_aligned_with_min_io_size(mtd, len)) { - len = round_up(len, mtd->writesize); - printf("Size not on a page boundary (0x%x), rounding to 0x%llx\n", - mtd->writesize, len); - } + start_off = argc > 0 ? simple_strtoul(argv[0], NULL, 16) : 0; + if (!mtd_is_aligned_with_min_io_size(mtd, start_off)) { + printf("Offset not aligned with a page (0x%x)\n", + mtd->writesize); + ret = CMD_RET_FAILURE; + goto out_put_mtd; + } - remaining = len; - npages = mtd_len_to_pages(mtd, len); - oob_len = woob ? npages * mtd->oobsize : 0; + default_len = dump ? mtd->writesize : mtd->size; + len = argc > 1 ? simple_strtoul(argv[1], NULL, 16) : default_len; + if (!mtd_is_aligned_with_min_io_size(mtd, len)) { + len = round_up(len, mtd->writesize); + printf("Size not on a page boundary (0x%x), rounding to 0x%llx\n", + mtd->writesize, len); + } - if (dump) - buf = kmalloc(len + oob_len, GFP_KERNEL); - else - buf = map_sysmem(user_addr, 0); + remaining = len; + npages = mtd_len_to_pages(mtd, len); + oob_len = woob ? npages * mtd->oobsize : 0; - if (!buf) { - printf("Could not map/allocate the user buffer\n"); - return CMD_RET_FAILURE; + if (dump) + buf = kmalloc(len + oob_len, GFP_KERNEL); + else + buf = map_sysmem(user_addr, 0); + + if (!buf) { + printf("Could not map/allocate the user buffer\n"); + ret = CMD_RET_FAILURE; + goto out_put_mtd; + } + + if (has_pages) + printf("%s %lld byte(s) (%d page(s)) at offset 0x%08llx%s%s%s\n", + read ? "Reading" : "Writing", len, npages, start_off, + raw ? " [raw]" : "", woob ? " [oob]" : "", + !read && write_empty_pages ? " [dontskipff]" : ""); + else + printf("%s %lld byte(s) at offset 0x%08llx\n", + read ? "Reading" : "Writing", len, start_off); + + io_op.mode = raw ? MTD_OPS_RAW : MTD_OPS_AUTO_OOB; + io_op.len = has_pages ? mtd->writesize : len; + io_op.ooblen = woob ? mtd->oobsize : 0; + io_op.datbuf = buf; + io_op.oobbuf = woob ? &buf[len] : NULL; + + /* Search for the first good block after the given offset */ + off = start_off; + while (mtd_block_isbad(mtd, off)) + off += mtd->erasesize; + + /* Loop over the pages to do the actual read/write */ + while (remaining) { + /* Skip the block if it is bad */ + if (mtd_is_aligned_with_block_size(mtd, off) && + mtd_block_isbad(mtd, off)) { + off += mtd->erasesize; + continue; } - if (has_pages) - printf("%s %lld byte(s) (%d page(s)) at offset 0x%08llx%s%s%s\n", - read ? "Reading" : "Writing", len, npages, start_off, - raw ? " [raw]" : "", woob ? " [oob]" : "", - !read && write_empty_pages ? " [dontskipff]" : ""); + if (read) + ret = mtd_read_oob(mtd, off, &io_op); else - printf("%s %lld byte(s) at offset 0x%08llx\n", - read ? "Reading" : "Writing", len, start_off); - - io_op.mode = raw ? MTD_OPS_RAW : MTD_OPS_AUTO_OOB; - io_op.len = has_pages ? mtd->writesize : len; - io_op.ooblen = woob ? mtd->oobsize : 0; - io_op.datbuf = buf; - io_op.oobbuf = woob ? &buf[len] : NULL; - - /* Search for the first good block after the given offset */ - off = start_off; - while (mtd_block_isbad(mtd, off)) - off += mtd->erasesize; + ret = mtd_special_write_oob(mtd, off, &io_op, + write_empty_pages, woob); - /* Loop over the pages to do the actual read/write */ - while (remaining) { - /* Skip the block if it is bad */ - if (mtd_is_aligned_with_block_size(mtd, off) && - mtd_block_isbad(mtd, off)) { - off += mtd->erasesize; - continue; - } + if (ret) { + printf("Failure while %s at offset 0x%llx\n", + read ? "reading" : "writing", off); + break; + } - if (read) - ret = mtd_read_oob(mtd, off, &io_op); - else - ret = mtd_special_write_oob(mtd, off, &io_op, - write_empty_pages, - woob); - - if (ret) { - printf("Failure while %s at offset 0x%llx\n", - read ? "reading" : "writing", off); - return CMD_RET_FAILURE; - } + off += io_op.retlen; + remaining -= io_op.retlen; + io_op.datbuf += io_op.retlen; + io_op.oobbuf += io_op.oobretlen; + } - off += io_op.retlen; - remaining -= io_op.retlen; - io_op.datbuf += io_op.retlen; - io_op.oobbuf += io_op.oobretlen; - } + if (!ret && dump) + mtd_dump_device_buf(mtd, start_off, buf, len, woob); - if (!ret && dump) - mtd_dump_device_buf(mtd, start_off, buf, len, woob); + if (dump) + kfree(buf); + else + unmap_sysmem(buf); - if (dump) - kfree(buf); - else - unmap_sysmem(buf); + if (ret) { + printf("%s on %s failed with error %d\n", + read ? "Read" : "Write", mtd->name, ret); + ret = CMD_RET_FAILURE; + } else { + ret = CMD_RET_SUCCESS; + } - if (ret) { - printf("%s on %s failed with error %d\n", - read ? "Read" : "Write", mtd->name, ret); - return CMD_RET_FAILURE; - } +out_put_mtd: + put_mtd_device(mtd); - } else if (!strcmp(cmd, "erase")) { - bool scrub = strstr(cmd, ".dontskipbad"); - struct erase_info erase_op = {}; - u64 off, len; - int ret; + return ret; +} - off = argc > 0 ? simple_strtoul(argv[0], NULL, 16) : 0; - len = argc > 1 ? simple_strtoul(argv[1], NULL, 16) : mtd->size; +static int do_mtd_erase(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + struct erase_info erase_op = {}; + struct mtd_info *mtd; + u64 off, len; + bool scrub; + int ret; - if (!mtd_is_aligned_with_block_size(mtd, off)) { - printf("Offset not aligned with a block (0x%x)\n", - mtd->erasesize); - return CMD_RET_FAILURE; - } + if (argc < 2) + return CMD_RET_USAGE; - if (!mtd_is_aligned_with_block_size(mtd, len)) { - printf("Size not a multiple of a block (0x%x)\n", - mtd->erasesize); - return CMD_RET_FAILURE; - } + mtd = get_mtd_by_name(argv[1]); + if (IS_ERR_OR_NULL(mtd)) + return CMD_RET_FAILURE; - printf("Erasing 0x%08llx ... 0x%08llx (%d eraseblock(s))\n", - off, off + len - 1, mtd_div_by_eb(len, mtd)); + scrub = strstr(argv[0], ".dontskipbad"); - erase_op.mtd = mtd; - erase_op.addr = off; - erase_op.len = len; - erase_op.scrub = scrub; + argc -= 2; + argv += 2; - while (erase_op.len) { - ret = mtd_erase(mtd, &erase_op); + off = argc > 0 ? simple_strtoul(argv[0], NULL, 16) : 0; + len = argc > 1 ? simple_strtoul(argv[1], NULL, 16) : mtd->size; - /* Abort if its not a bad block error */ - if (ret != -EIO) - break; + if (!mtd_is_aligned_with_block_size(mtd, off)) { + printf("Offset not aligned with a block (0x%x)\n", + mtd->erasesize); + ret = CMD_RET_FAILURE; + goto out_put_mtd; + } - printf("Skipping bad block at 0x%08llx\n", - erase_op.fail_addr); + if (!mtd_is_aligned_with_block_size(mtd, len)) { + printf("Size not a multiple of a block (0x%x)\n", + mtd->erasesize); + ret = CMD_RET_FAILURE; + goto out_put_mtd; + } - /* Skip bad block and continue behind it */ - erase_op.len -= erase_op.fail_addr - erase_op.addr; - erase_op.len -= mtd->erasesize; - erase_op.addr = erase_op.fail_addr + mtd->erasesize; - } + printf("Erasing 0x%08llx ... 0x%08llx (%d eraseblock(s))\n", + off, off + len - 1, mtd_div_by_eb(len, mtd)); - if (ret && ret != -EIO) - return CMD_RET_FAILURE; - } else if (!strcmp(cmd, "bad")) { - loff_t off; + erase_op.mtd = mtd; + erase_op.addr = off; + erase_op.len = len; + erase_op.scrub = scrub; - if (!mtd_can_have_bb(mtd)) { - printf("Only NAND-based devices can have bad blocks\n"); - return CMD_RET_SUCCESS; - } + while (erase_op.len) { + ret = mtd_erase(mtd, &erase_op); - printf("MTD device %s bad blocks list:\n", mtd->name); - for (off = 0; off < mtd->size; off += mtd->erasesize) - if (mtd_block_isbad(mtd, off)) - printf("\t0x%08llx\n", off); - } else { + /* Abort if its not a bad block error */ + if (ret != -EIO) + break; + + printf("Skipping bad block at 0x%08llx\n", erase_op.fail_addr); + + /* Skip bad block and continue behind it */ + erase_op.len -= erase_op.fail_addr - erase_op.addr; + erase_op.len -= mtd->erasesize; + erase_op.addr = erase_op.fail_addr + mtd->erasesize; + } + + if (ret && ret != -EIO) + ret = CMD_RET_FAILURE; + else + ret = CMD_RET_SUCCESS; + +out_put_mtd: + put_mtd_device(mtd); + + return ret; +} + +static int do_mtd_bad(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + struct mtd_info *mtd; + loff_t off; + + if (argc < 2) return CMD_RET_USAGE; + + mtd = get_mtd_by_name(argv[1]); + if (IS_ERR_OR_NULL(mtd)) + return CMD_RET_FAILURE; + + if (!mtd_can_have_bb(mtd)) { + printf("Only NAND-based devices can have bad blocks\n"); + goto out_put_mtd; + } + + printf("MTD device %s bad blocks list:\n", mtd->name); + for (off = 0; off < mtd->size; off += mtd->erasesize) { + if (mtd_block_isbad(mtd, off)) + printf("\t0x%08llx\n", off); } +out_put_mtd: + put_mtd_device(mtd); + return CMD_RET_SUCCESS; } +#ifdef CONFIG_AUTO_COMPLETE +static int mtd_name_complete(int argc, char * const argv[], char last_char, + int maxv, char *cmdv[]) +{ + int len = 0, n_found = 0; + struct mtd_info *mtd; + + argc--; + argv++; + + if (argc > 1 || + (argc == 1 && (last_char == '\0' || isblank(last_char)))) + return 0; + + if (argc) + len = strlen(argv[0]); + + mtd_for_each_device(mtd) { + if (argc && + (len > strlen(mtd->name) || + strncmp(argv[0], mtd->name, len))) + continue; + + if (n_found >= maxv - 2) { + cmdv[n_found++] = "..."; + break; + } + + cmdv[n_found++] = mtd->name; + } + + cmdv[n_found] = NULL; + + return n_found; +} +#endif /* CONFIG_AUTO_COMPLETE */ + static char mtd_help_text[] = #ifdef CONFIG_SYS_LONGHELP "- generic operations on memory technology devices\n\n" @@ -470,4 +545,15 @@ static char mtd_help_text[] = #endif ""; -U_BOOT_CMD(mtd, 10, 1, do_mtd, "MTD utils", mtd_help_text); +U_BOOT_CMD_WITH_SUBCMDS(mtd, "MTD utils", mtd_help_text, + U_BOOT_SUBCMD_MKENT(list, 1, 1, do_mtd_list), + U_BOOT_SUBCMD_MKENT_COMPLETE(read, 5, 0, do_mtd_io, + mtd_name_complete), + U_BOOT_SUBCMD_MKENT_COMPLETE(write, 5, 0, do_mtd_io, + mtd_name_complete), + U_BOOT_SUBCMD_MKENT_COMPLETE(dump, 4, 0, do_mtd_io, + mtd_name_complete), + U_BOOT_SUBCMD_MKENT_COMPLETE(erase, 4, 0, do_mtd_erase, + mtd_name_complete), + U_BOOT_SUBCMD_MKENT_COMPLETE(bad, 2, 1, do_mtd_bad, + mtd_name_complete)); diff --git a/cmd/nvedit.c b/cmd/nvedit.c index de16c72c23..ebaa16b754 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -708,8 +708,8 @@ int env_get_f(const char *name, char *buf, unsigned len) if (n) *--buf = '\0'; - printf("env_buf [%d bytes] too small for value of \"%s\"\n", - len, name); + printf("env_buf [%u bytes] too small for value of \"%s\"\n", + len, name); return n; } @@ -413,7 +413,7 @@ static void show_time(struct test_info *test, int stage) do_div(speed, test->time_ms[stage] * 1024); bps = speed * 8; - printf("%d %s: %d ticks, %d KiB/s %d.%03d Mbps\n", stage, + printf("%d %s: %u ticks, %d KiB/s %d.%03d Mbps\n", stage, stage_name[stage], test->time_ms[stage], (int)speed, bps / 1000, bps % 1000); } diff --git a/cmd/tpm-v2.c b/cmd/tpm-v2.c index bb51834c47..459a955d29 100644 --- a/cmd/tpm-v2.c +++ b/cmd/tpm-v2.c @@ -151,7 +151,7 @@ static int do_tpm_pcr_read(cmd_tbl_t *cmdtp, int flag, int argc, rc = tpm2_pcr_read(dev, index, priv->pcr_select_min, data, &updates); if (!rc) { - printf("PCR #%u content (%d known updates):\n", index, updates); + printf("PCR #%u content (%u known updates):\n", index, updates); print_byte_string(data, TPM2_DIGEST_LEN); } @@ -472,12 +472,8 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; - if (strcmp(argv[1], "detach") == 0) { - if (argc < 2) - return CMD_RET_USAGE; - + if (strcmp(argv[1], "detach") == 0) return ubi_detach(); - } if (strcmp(argv[1], "part") == 0) { const char *vid_header_offset = NULL; diff --git a/cmd/unzip.c b/cmd/unzip.c index f7aabf72d1..6c0f97cb4b 100644 --- a/cmd/unzip.c +++ b/cmd/unzip.c @@ -27,7 +27,7 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (gunzip((void *) dst, dst_len, (void *) src, &src_len) != 0) return 1; - printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len); + printf("Uncompressed size: %lu = 0x%lX\n", src_len, src_len); env_set_hex("filesize", src_len); return 0; @@ -28,7 +28,7 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (gzip((void *) dst, &dst_len, (void *) src, src_len) != 0) return 1; - printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len); + printf("Compressed size: %lu = 0x%lX\n", dst_len, dst_len); env_set_hex("filesize", dst_len); return 0; |