diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/Kconfig | 86 | ||||
| -rw-r--r-- | cmd/boot.c | 6 | ||||
| -rw-r--r-- | cmd/clone.c | 2 | ||||
| -rw-r--r-- | cmd/fastboot.c | 9 | ||||
| -rw-r--r-- | cmd/host.c | 5 | ||||
| -rw-r--r-- | cmd/ini.c | 15 | ||||
| -rw-r--r-- | cmd/lwip/ping.c | 19 | ||||
| -rw-r--r-- | cmd/lwip/sntp.c | 10 | ||||
| -rw-r--r-- | cmd/ti/Kconfig | 18 | ||||
| -rw-r--r-- | cmd/ubi.c | 272 | ||||
| -rw-r--r-- | cmd/ubifs.c | 2 | ||||
| -rw-r--r-- | cmd/upl.c | 2 | ||||
| -rw-r--r-- | cmd/x86/zboot.c | 3 |
13 files changed, 271 insertions, 178 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index 032e55e8127..a527b218949 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -881,12 +881,12 @@ config EEPROM_LAYOUT_VERSIONS via the -l option. config EEPROM_LAYOUT_HELP_STRING - string "Tells user what layout names are supported" - depends on EEPROM_LAYOUT_VERSIONS - default "<not defined>" - help - Help printed with the LAYOUT VERSIONS part of the 'eeprom' - command's help. + string "Tells user what layout names are supported" + depends on EEPROM_LAYOUT_VERSIONS + default "<not defined>" + help + Help printed with the LAYOUT VERSIONS part of the 'eeprom' + command's help. config SYS_I2C_EEPROM_BUS int "I2C bus of the EEPROM device." @@ -967,14 +967,14 @@ config CMD_MEMORY default y help Memory commands. - md - memory display - mm - memory modify (auto-incrementing address) - nm - memory modify (constant address) - mw - memory write (fill) - cp - memory copy - cmp - memory compare - base - print or set address offset - loop - initialize loop on address range + md - memory display + mm - memory modify (auto-incrementing address) + nm - memory modify (constant address) + mw - memory write (fill) + cp - memory copy + cmp - memory compare + base - print or set address offset + loop - initialize loop on address range config CMD_MEM_SEARCH bool "ms - Memory search" @@ -1115,9 +1115,9 @@ config CMD_ARMFFA help Provides a test command for the FF-A support supported options: - - Listing the partition(s) info - - Sending a data pattern to the specified partition - - Displaying the arm_ffa device info + - Listing the partition(s) info + - Sending a data pattern to the specified partition + - Displaying the arm_ffa device info config CMD_ARMFLASH bool "armflash" @@ -1208,15 +1208,22 @@ config CMD_FASTBOOT See doc/android/fastboot.rst for more information. +config CMD_FASTBOOT_ABORT_KEYED + bool "fastboot abort with any key" + depends on CMD_FASTBOOT && USB_FUNCTION_FASTBOOT + help + Allow interruption of USB fastboot mode by any key presses, + rather than just Ctrl-c. + config CMD_FLASH bool "flinfo, erase, protect" default y depends on FLASH_CFI_DRIVER || MTD_NOR_FLASH help NOR flash support. - flinfo - print FLASH memory information - erase - FLASH memory - protect - enable or disable FLASH write protection + flinfo - print FLASH memory information + erase - FLASH memory + protect - enable or disable FLASH write protection config CMD_FPGA bool "fpga" @@ -1392,6 +1399,7 @@ config CMD_IOTRACE config CMD_I2C bool "i2c" + depends on DM_I2C || SYS_I2C_LEGACY help I2C support. @@ -1548,7 +1556,7 @@ config CMD_OPTEE bool "Enable OP-TEE commands" depends on OPTEE help - OP-TEE commands support. + OP-TEE commands support. config CMD_MTD bool "mtd" @@ -1606,7 +1614,7 @@ config CMD_MUX bool "mux" depends on MULTIPLEXER help - List, select, and deselect mux controllers on the fly. + List, select, and deselect mux controllers on the fly. config CMD_NAND bool "nand" @@ -1814,7 +1822,7 @@ config CMD_UFS depends on UFS help "This provides commands to initialise and configure universal flash - subsystem devices" + subsystem devices" config CMD_USB bool "usb" @@ -1936,7 +1944,7 @@ config CMD_SETEXPR default y help Evaluate boolean and math expressions and store the result in an env - variable. + variable. Also supports loading the value at a memory location into a variable. If CONFIG_REGEX is enabled, setexpr also supports a gsub function. @@ -2642,9 +2650,9 @@ config CMD_PSTORE_ECC_SIZE depends on CMD_PSTORE default "0" help - if non-zero, the option enables ECC support and specifies ECC buffer - size in bytes (1 is a special value, means 16 bytes ECC), should be - identical to ramoops.ramoops_ecc parameter used by kernel + if non-zero, the option enables ECC support and specifies ECC buffer + size in bytes (1 is a special value, means 16 bytes ECC), should be + identical to ramoops.ramoops_ecc parameter used by kernel endif @@ -3156,15 +3164,15 @@ config CMD_AVB help Enables a "avb" command to perform verification of partitions using Android Verified Boot 2.0 functionality. It includes such subcommands: - avb init - initialize avb2 subsystem - avb read_rb - read rollback index - avb write_rb - write rollback index - avb is_unlocked - check device lock state - avb get_uuid - read and print uuid of a partition - avb read_part - read data from partition - avb read_part_hex - read data from partition and output to stdout - avb write_part - write data to partition - avb verify - run full verification chain + avb init - initialize avb2 subsystem + avb read_rb - read rollback index + avb write_rb - write rollback index + avb is_unlocked - check device lock state + avb get_uuid - read and print uuid of a partition + avb read_part - read data from partition + avb read_part_hex - read data from partition and output to stdout + avb write_part - write data to partition + avb verify - run full verification chain config CMD_STACKPROTECTOR_TEST bool "Test command for stack protector" @@ -3177,7 +3185,7 @@ config CMD_STACKPROTECTOR_TEST endmenu config CMD_UBI - tristate "Enable UBI - Unsorted block images commands" + bool "Enable UBI - Unsorted block images commands" select MTD_UBI help UBI is a software layer above MTD layer which admits use of LVM-like @@ -3194,10 +3202,10 @@ config CMD_UBI_RENAME depends on CMD_UBI help Enable a "ubi" command to rename ubi volume: - ubi rename <oldname> <newname> + ubi rename <oldname> <newname> config CMD_UBIFS - tristate "Enable UBIFS - Unsorted block images filesystem commands" + bool "Enable UBIFS - Unsorted block images filesystem commands" depends on CMD_UBI default y if CMD_UBI select LZO diff --git a/cmd/boot.c b/cmd/boot.c index 29cdf4a9a81..23496cafdf5 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -60,12 +60,6 @@ U_BOOT_CMD( reset, 2, 0, do_reset, "Perform RESET of the CPU", "- cold boot without level specifier\n" -#if IS_ENABLED(CONFIG_SYSRESET_CMD_RESET_ARGS) -// All options handled by sysreset drivers via their sysreset_ops.request_arg callback -#ifdef CONFIG_SYSRESET_QCOM_PSCI - "reset -edl - Boot to Emergency DownLoad mode\n" -#endif -#endif "reset -w - warm reset if implemented" ); diff --git a/cmd/clone.c b/cmd/clone.c index 1f3cff1836d..371f06d917a 100644 --- a/cmd/clone.c +++ b/cmd/clone.c @@ -97,7 +97,7 @@ read: write: ret = blk_dwrite(destdesc, destblk, towrite, buf + offset); if (ret < 0) { - printf("Dest write error @blk %ld\n", srcblk); + printf("Dest write error @blk %ld\n", destblk); goto exit; } wrcnt += ret * destbz; diff --git a/cmd/fastboot.c b/cmd/fastboot.c index e71f873527b..f3929f88dfa 100644 --- a/cmd/fastboot.c +++ b/cmd/fastboot.c @@ -103,8 +103,15 @@ static int do_fastboot_usb(int argc, char *const argv[], while (1) { if (g_dnl_detach()) break; - if (ctrlc()) + if (IS_ENABLED(CONFIG_CMD_FASTBOOT_ABORT_KEYED)) { + if (tstc()) { + getchar(); + puts("\rOperation aborted.\n"); + break; + } + } else if (ctrlc()) { break; + } schedule(); dm_usb_gadget_handle_interrupts(udc); } diff --git a/cmd/host.c b/cmd/host.c index e03576b4d2d..47a59f5ff20 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -132,10 +132,7 @@ static int do_host_unbind(struct cmd_tbl *cmdtp, int flag, int argc, ret = device_unbind(dev); if (ret) { - printf("Cannot attach file\n"); - ret = device_unbind(dev); - if (ret) - printf("Cannot unbind device '%s'\n", dev->name); + printf("Cannot unbind device '%s'\n", dev->name); return CMD_RET_FAILURE; } diff --git a/cmd/ini.c b/cmd/ini.c index 96399017691..3fe86209c32 100644 --- a/cmd/ini.c +++ b/cmd/ini.c @@ -229,6 +229,7 @@ static int ini_handler(void *user, char *section, char *name, char *value) static int do_ini(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { const char *section; + const char *addr_str, *size_str; char *file_address; size_t file_size; @@ -236,10 +237,16 @@ static int do_ini(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_USAGE; section = argv[1]; - file_address = (char *)hextoul(argc < 3 ? env_get("loadaddr") : argv[2], - NULL); - file_size = (size_t)hextoul(argc < 4 ? env_get("filesize") : argv[3], - NULL); + addr_str = argc < 3 ? env_get("loadaddr") : argv[2]; + size_str = argc < 4 ? env_get("filesize") : argv[3]; + + if (!addr_str || !size_str) { + printf("ini: loadaddr/filesize not set\n"); + return CMD_RET_USAGE; + } + + file_address = (char *)hextoul(addr_str, NULL); + file_size = (size_t)hextoul(size_str, NULL); return ini_parse(file_address, file_size, ini_handler, (void *)section); } diff --git a/cmd/lwip/ping.c b/cmd/lwip/ping.c index fc4cf7bde5f..98fa8e22bce 100644 --- a/cmd/lwip/ping.c +++ b/cmd/lwip/ping.c @@ -163,6 +163,7 @@ static int ping_loop(struct udevice *udev, const ip_addr_t *addr) int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { ip_addr_t addr; + int ret; if (argc < 2) return CMD_RET_USAGE; @@ -171,13 +172,15 @@ int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_USAGE; net_try_count = 1; -restart: - if (net_lwip_eth_start() < 0 || ping_loop(eth_get_dev(), &addr) < 0) { - if (net_start_again() == 0) - goto restart; - else - return CMD_RET_FAILURE; - } - return CMD_RET_SUCCESS; + do { + if (net_lwip_eth_start() == 0) { + ret = ping_loop(eth_get_dev(), &addr); + net_lwip_eth_stop(); + if (ret == 0) + return CMD_RET_SUCCESS; + } + } while (net_start_again() == 0); + + return CMD_RET_FAILURE; } diff --git a/cmd/lwip/sntp.c b/cmd/lwip/sntp.c index 608345c873b..5fa400b104a 100644 --- a/cmd/lwip/sntp.c +++ b/cmd/lwip/sntp.c @@ -101,6 +101,7 @@ int do_sntp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) ip_addr_t *srvip; char *server; ip_addr_t ipaddr; + int ret = CMD_RET_FAILURE; switch (argc) { case 1: @@ -127,7 +128,12 @@ int do_sntp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_FAILURE; if (sntp_loop(eth_get_dev(), srvip) < 0) - return CMD_RET_FAILURE; + goto out; + + ret = CMD_RET_SUCCESS; + +out: + net_lwip_eth_stop(); - return CMD_RET_SUCCESS; + return ret; } diff --git a/cmd/ti/Kconfig b/cmd/ti/Kconfig index 43fe9ef2f08..17cf867dd91 100644 --- a/cmd/ti/Kconfig +++ b/cmd/ti/Kconfig @@ -4,24 +4,24 @@ config CMD_DDR3 bool "command for verifying DDR features" depends on ARCH_KEYSTONE || DRA7XX help - Support for testing ddr3 on TI platforms. This command - supports memory verification, memory comapre and ecc - verification if supported. + Support for testing ddr3 on TI platforms. This command + supports memory verification, memory comapre and ecc + verification if supported. config CMD_DDR4 bool "command for verifying DDRSS Inline ECC features" depends on ARCH_K3 help - Support for testing DDRSS on TI platforms. This command supports - memory verification, memory compare and inline ECC verification - if supported. + Support for testing DDRSS on TI platforms. This command supports + memory verification, memory compare and inline ECC verification + if supported. config CMD_PD bool "command for verifying power domains" depends on TI_POWER_DOMAIN help - Debug command for K3 power domains. For this to work, the - K3 power domain driver must be enabled for the u-boot; by - default it is only enabled for SPL. + Debug command for K3 power domains. For this to work, the + K3 power domain driver must be enabled for the u-boot; by + default it is only enabled for SPL. endmenu diff --git a/cmd/ubi.c b/cmd/ubi.c index 93de6f3aea2..2b206141a21 100644 --- a/cmd/ubi.c +++ b/cmd/ubi.c @@ -39,7 +39,7 @@ static struct ubi_device *ubi; #include <ubifs_uboot.h> #endif -static void display_volume_info(struct ubi_device *ubi) +static void display_volume_info(const struct ubi_device *ubi) { int i; @@ -50,7 +50,7 @@ static void display_volume_info(struct ubi_device *ubi) } } -static void display_ubi_info(struct ubi_device *ubi) +static void display_ubi_info(const struct ubi_device *ubi) { ubi_msg("MTD device name: \"%s\"", ubi->mtd->name); ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20); @@ -149,12 +149,12 @@ static int ubi_list(const char *var, int numeric) return 0; } -static int ubi_check_volumename(const struct ubi_volume *vol, char *name) +static int ubi_check_volumename(const struct ubi_volume *vol, const char *name) { return strcmp(vol->name, name); } -static int ubi_check(char *name) +static int ubi_check(const char *name) { int i; @@ -172,7 +172,7 @@ static int ubi_check(char *name) static int verify_mkvol_req(const struct ubi_device *ubi, const struct ubi_mkvol_req *req) { - int n, err = EINVAL; + int n, err = -EINVAL; if (req->bytes < 0 || req->alignment < 0 || req->vol_type < 0 || req->name_len < 0) @@ -187,7 +187,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi, if (req->bytes == 0) { printf("No space left in UBI device!\n"); - err = ENOMEM; + err = -ENOMEM; goto bad; } @@ -204,7 +204,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi, if (req->name_len > UBI_VOL_NAME_MAX) { printf("Name too long!\n"); - err = ENAMETOOLONG; + err = -ENAMETOOLONG; goto bad; } @@ -213,8 +213,8 @@ bad: return err; } -static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id, - bool skipcheck) +int ubi_create_vol(const char *volume, int64_t size, bool dynamic, int vol_id, + bool skipcheck) { struct ubi_mkvol_req req; int err; @@ -226,7 +226,11 @@ static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id, req.vol_id = vol_id; req.alignment = 1; - req.bytes = size; + + if (size < 0) + req.bytes = ubi->avail_pebs * ubi->leb_size; + else + req.bytes = size; strcpy(req.name, volume); req.name_len = strlen(volume); @@ -241,13 +245,12 @@ static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id, printf("verify_mkvol_req failed %d\n", err); return err; } - printf("Creating %s volume %s of size %lld\n", - dynamic ? "dynamic" : "static", volume, size); + /* Call real ubi create volume */ return ubi_create_volume(ubi, &req); } -static struct ubi_volume *ubi_find_volume(char *volume) +struct ubi_volume *ubi_find_volume(const char *volume) { struct ubi_volume *vol; int i; @@ -258,24 +261,26 @@ static struct ubi_volume *ubi_find_volume(char *volume) return vol; } - printf("Volume %s not found!\n", volume); return NULL; } -static int ubi_remove_vol(char *volume) +static struct ubi_volume *ubi_require_volume(const char *volume) { - int err, reserved_pebs, i; - struct ubi_volume *vol; + struct ubi_volume *vol = ubi_find_volume(volume); - vol = ubi_find_volume(volume); - if (vol == NULL) - return ENODEV; + if (!vol) + printf("Volume %s not found!\n", volume); + + return vol; +} - printf("Remove UBI volume %s (id %d)\n", vol->name, vol->vol_id); +static int __ubi_remove_vol(struct ubi_volume *vol) +{ + int err, reserved_pebs, i; if (ubi->ro_mode) { printf("It's read-only mode\n"); - err = EROFS; + err = -EROFS; goto out_err; } @@ -310,35 +315,40 @@ static int ubi_remove_vol(char *volume) return 0; out_err: - ubi_err(ubi, "cannot remove volume %s, error %d", volume, err); - if (err < 0) - err = -err; + ubi_err(ubi, "cannot remove volume %s, error %d", vol->name, err); return err; } -static int ubi_rename_vol(char *oldname, char *newname) +int ubi_remove_vol(const char *volume) +{ + struct ubi_volume *vol; + + vol = ubi_require_volume(volume); + if (!vol) + return -ENODEV; + + return __ubi_remove_vol(vol); +} + +static int ubi_rename_vol(const char *oldname, const char *newname) { struct ubi_volume *vol; struct ubi_rename_entry rename; struct ubi_volume_desc desc; struct list_head list; - vol = ubi_find_volume(oldname); - if (!vol) { - printf("%s: volume %s doesn't exist\n", __func__, oldname); - return ENODEV; - } + vol = ubi_require_volume(oldname); + if (!vol) + return -ENODEV; if (!ubi_check(newname)) { printf("%s: volume %s already exist\n", __func__, newname); - return EINVAL; + return -EINVAL; } - printf("Rename UBI volume %s to %s\n", oldname, newname); - if (ubi->ro_mode) { printf("%s: ubi device is in read-only mode\n", __func__); - return EROFS; + return -EROFS; } rename.new_name_len = strlen(newname); @@ -354,24 +364,25 @@ static int ubi_rename_vol(char *oldname, char *newname) return ubi_rename_volumes(ubi, &list); } -static int ubi_volume_continue_write(char *volume, void *buf, size_t size) +static int ubi_volume_continue_write(const char *volume, const void *buf, + size_t size) { int err; struct ubi_volume *vol; - vol = ubi_find_volume(volume); + vol = ubi_require_volume(volume); if (vol == NULL) - return ENODEV; + return -ENODEV; if (!vol->updating) { printf("UBI volume update was not initiated\n"); - return EINVAL; + return -EINVAL; } err = ubi_more_update_data(ubi, vol, buf, size); if (err < 0) { printf("Couldnt or partially wrote data\n"); - return -err; + return err; } if (err) { @@ -379,7 +390,7 @@ static int ubi_volume_continue_write(char *volume, void *buf, size_t size) err = ubi_check_volume(ubi, vol->vol_id); if (err < 0) - return -err; + return err; if (err) { ubi_warn(ubi, "volume %d on UBI device %d is corrupt", @@ -394,27 +405,27 @@ static int ubi_volume_continue_write(char *volume, void *buf, size_t size) return 0; } -int ubi_volume_begin_write(char *volume, void *buf, size_t size, - size_t full_size) +int ubi_volume_begin_write(const char *volume, const void *buf, size_t size, + size_t full_size) { int err; int rsvd_bytes; struct ubi_volume *vol; - vol = ubi_find_volume(volume); + vol = ubi_require_volume(volume); if (vol == NULL) - return ENODEV; + return -ENODEV; rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad); if (size > rsvd_bytes) { printf("size > volume size! Aborting!\n"); - return EINVAL; + return -EINVAL; } err = ubi_start_update(ubi, vol, full_size); if (err < 0) { printf("Cannot start volume update\n"); - return -err; + return err; } /* The volume is just wiped out */ @@ -424,8 +435,8 @@ int ubi_volume_begin_write(char *volume, void *buf, size_t size, return ubi_volume_continue_write(volume, buf, size); } -static int ubi_volume_offset_write(char *volume, void *buf, loff_t offset, - size_t size) +static int ubi_volume_offset_write(const char *volume, const void *buf, + loff_t offset, size_t size) { int len, tbuf_size, ret; u64 lnum; @@ -433,7 +444,7 @@ static int ubi_volume_offset_write(char *volume, void *buf, loff_t offset, loff_t off = offset; void *tbuf; - vol = ubi_find_volume(volume); + vol = ubi_require_volume(volume); if (!vol) return -ENODEV; @@ -487,7 +498,8 @@ exit: return ret; } -int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size) +int ubi_volume_write(const char *volume, const void *buf, loff_t offset, + size_t size) { int ret; @@ -503,36 +515,28 @@ int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size) return ret; } -int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) +static int __ubi_volume_read(struct ubi_volume *vol, void *buf, loff_t offset, + size_t size) { int err, lnum, off, len, tbuf_size; void *tbuf; unsigned long long tmp; - struct ubi_volume *vol; loff_t offp = offset; size_t len_read; - vol = ubi_find_volume(volume); - if (vol == NULL) - return ENODEV; - if (vol->updating) { printf("updating"); - return EBUSY; + return -EBUSY; } if (vol->upd_marker) { printf("damaged volume, update marker is set"); - return EBADF; + return -EBADF; } if (offp == vol->used_bytes) return 0; - if (size == 0) { - printf("No size specified -> Using max size (%lld)\n", vol->used_bytes); + if (size == 0) size = vol->used_bytes; - } - - printf("Read %zu bytes from volume %s to %p\n", size, volume, buf); if (vol->corrupted) printf("read from corrupted volume %d", vol->vol_id); @@ -545,7 +549,7 @@ int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) tbuf = malloc_cache_aligned(tbuf_size); if (!tbuf) { printf("NO MEM\n"); - return ENOMEM; + return -ENOMEM; } len = size > tbuf_size ? tbuf_size : size; @@ -561,7 +565,6 @@ int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) err = ubi_eba_read_leb(ubi, vol, lnum, tbuf, off, len, 0); if (err) { printf("read err %x\n", err); - err = -err; break; } off += len; @@ -587,7 +590,19 @@ int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size) return err; } -static int ubi_dev_scan(struct mtd_info *info, const char *vid_header_offset) +int ubi_volume_read(const char *volume, void *buf, loff_t offset, size_t size) +{ + struct ubi_volume *vol; + + vol = ubi_require_volume(volume); + if (!vol) + return -ENODEV; + + return __ubi_volume_read(vol, buf, offset, size); +} + +static int ubi_dev_scan(const struct mtd_info *info, + const char *vid_header_offset) { char ubi_mtd_param_buffer[80]; int err; @@ -600,28 +615,25 @@ static int ubi_dev_scan(struct mtd_info *info, const char *vid_header_offset) err = ubi_mtd_param_parse(ubi_mtd_param_buffer, NULL); if (err) - return -err; + return err; led_activity_blink(); err = ubi_init(); led_activity_off(); if (err) - return -err; + return err; return 0; } -static int ubi_set_skip_check(char *volume, bool skip_check) +static int ubi_set_skip_check(const char *volume, bool skip_check) { struct ubi_vtbl_record vtbl_rec; struct ubi_volume *vol; - vol = ubi_find_volume(volume); + vol = ubi_require_volume(volume); if (!vol) - return ENODEV; - - printf("%sing skip_check on volume %s\n", - skip_check ? "Sett" : "Clear", volume); + return -ENODEV; vtbl_rec = ubi->vtbl[vol->vol_id]; if (skip_check) { @@ -635,7 +647,7 @@ static int ubi_set_skip_check(char *volume, bool skip_check) return ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec); } -static int ubi_detach(void) +int ubi_detach(void) { #ifdef CONFIG_CMD_UBIFS /* @@ -658,7 +670,7 @@ static int ubi_detach(void) return 0; } -int ubi_part(char *part_name, const char *vid_header_offset) +int ubi_part(const char *part_name, const char *vid_header_offset) { struct mtd_info *mtd; int err; @@ -674,7 +686,7 @@ int ubi_part(char *part_name, const char *vid_header_offset) mtd = get_mtd_device_nm(part_name); if (IS_ERR(mtd)) { printf("Partition %s not found!\n", part_name); - return 1; + return -ENODEV; } put_mtd_device(mtd); @@ -695,6 +707,8 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) int64_t size; ulong addr = 0; bool skipcheck = false; + struct ubi_volume *vol; + int ret; if (argc < 2) return CMD_RET_USAGE; @@ -709,7 +723,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc == 2) { if (!ubi) { printf("Error, no UBI device selected!\n"); - return 1; + return CMD_RET_FAILURE; } printf("Device %d: %s, MTD partition %s\n", @@ -723,12 +737,13 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc > 3) vid_header_offset = argv[3]; - return ubi_part(argv[2], vid_header_offset); + ret = ubi_part(argv[2], vid_header_offset); + return ret ? CMD_RET_FAILURE : 0; } if ((strcmp(argv[1], "part") != 0) && !ubi) { printf("Error, no UBI device selected!\n"); - return 1; + return CMD_RET_FAILURE; } if (strcmp(argv[1], "info") == 0) { @@ -758,11 +773,11 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return ubi_check(argv[2]); printf("Error, no volume name passed\n"); - return 1; + return CMD_RET_USAGE; } if (strncmp(argv[1], "create", 6) == 0) { - int dynamic = 1; /* default: dynamic volume */ + bool dynamic = true; /* default: dynamic volume */ int id = UBI_VOL_NUM_AUTO; /* Use maximum available size */ @@ -783,10 +798,10 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* E.g., create volume size type */ if (argc == 5) { if (strncmp(argv[4], "s", 1) == 0) - dynamic = 0; + dynamic = false; else if (strncmp(argv[4], "d", 1) != 0) { printf("Incorrect type\n"); - return 1; + return CMD_RET_USAGE; } argc--; } @@ -799,38 +814,80 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* Use maximum available size */ if (!size) { size = (int64_t)ubi->avail_pebs * ubi->leb_size; - printf("No size specified -> Using max size (%lld)\n", size); + if (size) + printf("No size specified -> Using max size (%lld)\n", + size); } /* E.g., create volume */ if (argc == 3) { - return ubi_create_vol(argv[2], size, dynamic, id, - skipcheck); + ret = ubi_create_vol(argv[2], size, dynamic, id, + skipcheck); + if (ret) + return CMD_RET_FAILURE; + + printf("Created %s volume %s of size %lld\n", + dynamic ? "dynamic" : "static", argv[2], size); + + return 0; } } if (strncmp(argv[1], "remove", 6) == 0) { /* E.g., remove volume */ - if (argc == 3) - return ubi_remove_vol(argv[2]); + if (argc == 3) { + int vol_id; + + vol = ubi_require_volume(argv[2]); + if (!vol) + return CMD_RET_FAILURE; + + vol_id = vol->vol_id; + + ret = __ubi_remove_vol(vol); + if (ret) + return CMD_RET_FAILURE; + + printf("Removed UBI volume %s (id %d)\n", argv[2], + vol_id); + + return 0; + } } - if (IS_ENABLED(CONFIG_CMD_UBI_RENAME) && !strncmp(argv[1], "rename", 6)) - return ubi_rename_vol(argv[2], argv[3]); + if (IS_ENABLED(CONFIG_CMD_UBI_RENAME) && !strncmp(argv[1], "rename", 6)) { + if (argc < 4) { + printf("Please see usage\n"); + return CMD_RET_USAGE; + } + + ret = ubi_rename_vol(argv[2], argv[3]); + if (ret) + return CMD_RET_FAILURE; + + printf("UBI volume %s renamed to %s\n", argv[2], argv[3]); + + return 0; + } if (strncmp(argv[1], "skipcheck", 9) == 0) { /* E.g., change skip_check flag */ if (argc == 4) { skipcheck = strncmp(argv[3], "on", 2) == 0; - return ubi_set_skip_check(argv[2], skipcheck); + ret = ubi_set_skip_check(argv[2], skipcheck); + if (ret) + return CMD_RET_FAILURE; + + printf("%s skip_check on volume %s\n", + skipcheck ? "Set" : "Cleared", argv[2]); + + return 0; } } if (strncmp(argv[1], "write", 5) == 0) { - int ret; - if (argc < 5) { printf("Please see usage\n"); - return 1; + return CMD_RET_USAGE; } addr = hextoul(argv[2], NULL); @@ -855,7 +912,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) argv[3]); } - return ret; + return ret ? CMD_RET_FAILURE : 0; } if (strncmp(argv[1], "read", 4) == 0) { @@ -874,12 +931,29 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } if (argc == 3) { - return ubi_volume_read(argv[3], (char *)addr, 0, size); + vol = ubi_require_volume(argv[3]); + if (!vol) + return CMD_RET_FAILURE; + + if (!size) { + printf("No size specified -> Using max size (%lld)\n", + vol->used_bytes); + size = vol->used_bytes; + } + + ret = __ubi_volume_read(vol, (void *)addr, 0, size); + if (ret) + return CMD_RET_FAILURE; + + printf("%lld bytes read from volume %s to 0x%lx\n", + size, argv[3], addr); + + return 0; } } printf("Please see usage\n"); - return 1; + return CMD_RET_USAGE; } U_BOOT_CMD( diff --git a/cmd/ubifs.c b/cmd/ubifs.c index 22e95db8ca5..81f2d37fc7b 100644 --- a/cmd/ubifs.c +++ b/cmd/ubifs.c @@ -19,7 +19,7 @@ static int ubifs_initialized; static int ubifs_mounted; -int cmd_ubifs_mount(char *vol_name) +int cmd_ubifs_mount(const char *vol_name) { int ret; diff --git a/cmd/upl.c b/cmd/upl.c index ef2183d8528..be21ec258cb 100644 --- a/cmd/upl.c +++ b/cmd/upl.c @@ -93,7 +93,7 @@ static int do_upl_read(struct cmd_tbl *cmdtp, int flag, int argc, ulong addr; int ret; - if (argc < 1) + if (argc < 2) return CMD_RET_USAGE; addr = hextoul(argv[1], NULL); diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index 3876d163236..cc7292e10b7 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -66,9 +66,6 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - if (zboot_setup()) - return CMD_RET_FAILURE; - return 0; } |
