diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/Kconfig | 90 | ||||
| -rw-r--r-- | cmd/bdinfo.c | 12 | ||||
| -rw-r--r-- | cmd/bootmenu.c | 4 | ||||
| -rw-r--r-- | cmd/clone.c | 2 | ||||
| -rw-r--r-- | cmd/cros_ec.c | 4 | ||||
| -rw-r--r-- | cmd/date.c | 11 | ||||
| -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/mmc.c | 21 | ||||
| -rw-r--r-- | cmd/ti/Kconfig | 18 | ||||
| -rw-r--r-- | cmd/ti/ddr4.c | 8 | ||||
| -rw-r--r-- | cmd/ubi.c | 272 | ||||
| -rw-r--r-- | cmd/ubifs.c | 2 | ||||
| -rw-r--r-- | cmd/ufetch.c | 33 | ||||
| -rw-r--r-- | cmd/upl.c | 2 | ||||
| -rw-r--r-- | cmd/x86/zboot.c | 3 |
17 files changed, 201 insertions, 310 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index a527b218949..c71c6824a19 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,22 +1208,15 @@ 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" @@ -1399,7 +1392,6 @@ config CMD_IOTRACE config CMD_I2C bool "i2c" - depends on DM_I2C || SYS_I2C_LEGACY help I2C support. @@ -1556,7 +1548,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" @@ -1614,7 +1606,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" @@ -1822,7 +1814,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" @@ -1879,8 +1871,8 @@ config CMD_PVBLOCK config CMD_VIRTIO bool "virtio" - depends on VIRTIO_BLK - default y if VIRTIO_BLK + depends on VIRTIO + default y if VIRTIO help VirtIO block device support @@ -1944,7 +1936,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. @@ -2650,9 +2642,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 @@ -3164,15 +3156,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" @@ -3185,7 +3177,7 @@ config CMD_STACKPROTECTOR_TEST endmenu config CMD_UBI - bool "Enable UBI - Unsorted block images commands" + tristate "Enable UBI - Unsorted block images commands" select MTD_UBI help UBI is a software layer above MTD layer which admits use of LVM-like @@ -3202,10 +3194,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 - bool "Enable UBIFS - Unsorted block images filesystem commands" + tristate "Enable UBIFS - Unsorted block images filesystem commands" depends on CMD_UBI default y if CMD_UBI select LZO diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index bf1eca75904..ddf77303735 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -77,15 +77,15 @@ void bdinfo_print_mhz(const char *name, unsigned long hz) printf("%-12s= %6s MHz\n", name, strmhz(buf, hz)); } -static void print_dram(const struct bd_info *bd) +static void print_bi_dram(const struct bd_info *bd) { int i; for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { - if (gd->dram[i].size) { + if (bd->bi_dram[i].size) { bdinfo_print_num_l("DRAM bank", i); - bdinfo_print_num_ll("-> start", gd->dram[i].start); - bdinfo_print_num_ll("-> size", gd->dram[i].size); + bdinfo_print_num_ll("-> start", bd->bi_dram[i].start); + bdinfo_print_num_ll("-> size", bd->bi_dram[i].size); } } } @@ -144,7 +144,7 @@ static int bdinfo_print_all(struct bd_info *bd) bdinfo_print_num_l("bd address", (ulong)bd); #endif bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params); - print_dram(bd); + print_bi_dram(bd); bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart); bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize); bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset); @@ -199,7 +199,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) print_eth(); return CMD_RET_SUCCESS; case 'm': - print_dram(bd); + print_bi_dram(bd); return CMD_RET_SUCCESS; default: return CMD_RET_USAGE; diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index b55f5579409..528afd221d0 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -526,7 +526,7 @@ static void handle_uefi_bootnext(void) */ static enum bootmenu_ret bootmenu_show(int uefi, int delay) { - int cmd_ret = CMD_RET_SUCCESS; + int cmd_ret; int init = 0; void *choice = NULL; char *title = NULL; @@ -628,7 +628,7 @@ cleanup: printf(ANSI_CURSOR_POSITION, 1, 1); } - if (title && command && *command) { + if (title && command) { debug("Starting entry '%s'\n", title); free(title); if (efi_ret == EFI_SUCCESS) diff --git a/cmd/clone.c b/cmd/clone.c index 371f06d917a..1f3cff1836d 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", destblk); + printf("Dest write error @blk %ld\n", srcblk); goto exit; } wrcnt += ret * destbz; diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c index 66a5f6d5210..7b60e415b6c 100644 --- a/cmd/cros_ec.c +++ b/cmd/cros_ec.c @@ -13,7 +13,7 @@ #include <dm/device-internal.h> #include <dm/uclass-internal.h> -/* Note: depends on enum ec_image */ +/* Note: depends on enum ec_current_image */ static const char * const ec_current_image_name[] = {"unknown", "RO", "RW"}; /** @@ -312,7 +312,7 @@ static int do_cros_ec(struct cmd_tbl *cmdtp, int flag, int argc, if (ret) printf("Error: %d\n", ret); } else if (0 == strcmp("curimage", cmd)) { - enum ec_image image; + enum ec_current_image image; if (cros_ec_read_current_image(dev, &image)) { debug("%s: Could not read KBC image\n", __func__); diff --git a/cmd/date.c b/cmd/date.c index 67cfaed0d48..d047872289c 100644 --- a/cmd/date.c +++ b/cmd/date.c @@ -16,7 +16,7 @@ static const char * const weekdays[] = { "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", }; -static int mk_date(const char *, struct rtc_time *); +int mk_date (const char *, struct rtc_time *); static struct rtc_time default_tm = { 0, 0, 0, 1, 1, 2000, 6, 0, 0 }; @@ -117,7 +117,7 @@ static int cnvrt2 (const char *str, int *valp) * Some basic checking for valid values is done, but this will not catch * all possible error conditions. */ -static int mk_date(const char *datestr, struct rtc_time *tmp) +int mk_date (const char *datestr, struct rtc_time *tmp) { int len, val; char *ptr; @@ -167,13 +167,12 @@ static int mk_date(const char *datestr, struct rtc_time *tmp) /* fall thru */ case 12: /* MMDDhhmmCCYY */ if (cnvrt2 (datestr+0, &val) || - val > 12 || val < 1) { + val > 12) { break; } tmp->tm_mon = val; - if (cnvrt2(datestr + 2, &val) || - val < 1 || - val > rtc_month_days(tmp->tm_mon - 1, tmp->tm_year)) { + if (cnvrt2 (datestr+2, &val) || + val > ((tmp->tm_mon==2) ? 29 : 31)) { break; } tmp->tm_mday = val; diff --git a/cmd/fastboot.c b/cmd/fastboot.c index f3929f88dfa..e71f873527b 100644 --- a/cmd/fastboot.c +++ b/cmd/fastboot.c @@ -103,15 +103,8 @@ static int do_fastboot_usb(int argc, char *const argv[], while (1) { if (g_dnl_detach()) break; - if (IS_ENABLED(CONFIG_CMD_FASTBOOT_ABORT_KEYED)) { - if (tstc()) { - getchar(); - puts("\rOperation aborted.\n"); - break; - } - } else if (ctrlc()) { + if (ctrlc()) break; - } schedule(); dm_usb_gadget_handle_interrupts(udc); } diff --git a/cmd/host.c b/cmd/host.c index 47a59f5ff20..e03576b4d2d 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -132,7 +132,10 @@ static int do_host_unbind(struct cmd_tbl *cmdtp, int flag, int argc, ret = device_unbind(dev); if (ret) { - printf("Cannot unbind device '%s'\n", dev->name); + printf("Cannot attach file\n"); + ret = device_unbind(dev); + if (ret) + printf("Cannot unbind device '%s'\n", dev->name); return CMD_RET_FAILURE; } diff --git a/cmd/ini.c b/cmd/ini.c index 3fe86209c32..96399017691 100644 --- a/cmd/ini.c +++ b/cmd/ini.c @@ -229,7 +229,6 @@ 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; @@ -237,16 +236,10 @@ static int do_ini(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_USAGE; section = argv[1]; - 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); + 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); return ini_parse(file_address, file_size, ini_handler, (void *)section); } diff --git a/cmd/mmc.c b/cmd/mmc.c index 54c799891e1..81b1ca4ad84 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -519,7 +519,7 @@ static int do_mmc_rescan(struct cmd_tbl *cmdtp, int flag, if (argc == 1) { mmc = init_mmc_device(curr_device, true); - } else if ((argc == 2) && (CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET))) { + } else if (argc == 2) { enum bus_mode speed_mode; speed_mode = (int)dectoul(argv[1], NULL); @@ -564,13 +564,11 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag, switch (argc) { case 4: - if (CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET)) { - speed_mode = (int)dectoul(argv[3], &endp); - if (*endp) { - printf("Invalid speed mode index '%s', did you specify a mode name?\n", - argv[3]); - return CMD_RET_USAGE; - } + speed_mode = (int)dectoul(argv[3], &endp); + if (*endp) { + printf("Invalid speed mode index '%s', did you specify a mode name?\n", + argv[3]); + return CMD_RET_USAGE; } fallthrough; @@ -1314,17 +1312,12 @@ U_BOOT_CMD( #endif "mmc erase blk# cnt\n" "mmc erase partname\n" -#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) "mmc rescan [mode]\n" + "mmc part - lists available partition on current mmc device\n" "mmc dev [dev] [part] [mode] - show or set current mmc device [partition] and set mode\n" " - the required speed mode is passed as the index from the following list\n" " [MMC_LEGACY, MMC_HS, SD_HS, MMC_HS_52, MMC_DDR_52, UHS_SDR12, UHS_SDR25,\n" " UHS_SDR50, UHS_DDR50, UHS_SDR104, MMC_HS_200, MMC_HS_400, MMC_HS_400_ES]\n" -#else - "mmc rescan\n" - "mmc dev [dev] [part] - show or set current mmc device [partition]\n" -#endif - "mmc part - lists available partition on current mmc device\n" "mmc list - lists available devices\n" "mmc wp [PART] - power on write protect boot partitions\n" " arguments:\n" diff --git a/cmd/ti/Kconfig b/cmd/ti/Kconfig index 17cf867dd91..43fe9ef2f08 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/ti/ddr4.c b/cmd/ti/ddr4.c index 36277cc154c..a8d71d11a91 100644 --- a/cmd/ti/ddr4.c +++ b/cmd/ti/ddr4.c @@ -227,10 +227,10 @@ static int do_ddr4_ecc_inject(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - if (!((start_addr >= gd->dram[0].start && - (start_addr <= (gd->dram[0].start + gd->dram[0].size - 1))) || - (start_addr >= gd->dram[1].start && - (start_addr <= (gd->dram[1].start + gd->dram[1].size - 1))))) { + if (!((start_addr >= gd->bd->bi_dram[0].start && + (start_addr <= (gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - 1))) || + (start_addr >= gd->bd->bi_dram[1].start && + (start_addr <= (gd->bd->bi_dram[1].start + gd->bd->bi_dram[1].size - 1))))) { puts("Address is not in the DDR range\n"); return CMD_RET_FAILURE; } diff --git a/cmd/ubi.c b/cmd/ubi.c index 2b206141a21..93de6f3aea2 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(const struct ubi_device *ubi) +static void display_volume_info(struct ubi_device *ubi) { int i; @@ -50,7 +50,7 @@ static void display_volume_info(const struct ubi_device *ubi) } } -static void display_ubi_info(const struct ubi_device *ubi) +static void display_ubi_info(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, const char *name) +static int ubi_check_volumename(const struct ubi_volume *vol, char *name) { return strcmp(vol->name, name); } -static int ubi_check(const char *name) +static int ubi_check(char *name) { int i; @@ -172,7 +172,7 @@ static int ubi_check(const 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; } -int ubi_create_vol(const char *volume, int64_t size, bool dynamic, int vol_id, - bool skipcheck) +static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id, + bool skipcheck) { struct ubi_mkvol_req req; int err; @@ -226,11 +226,7 @@ int ubi_create_vol(const char *volume, int64_t size, bool dynamic, int vol_id, req.vol_id = vol_id; req.alignment = 1; - - if (size < 0) - req.bytes = ubi->avail_pebs * ubi->leb_size; - else - req.bytes = size; + req.bytes = size; strcpy(req.name, volume); req.name_len = strlen(volume); @@ -245,12 +241,13 @@ int ubi_create_vol(const char *volume, int64_t size, bool 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); } -struct ubi_volume *ubi_find_volume(const char *volume) +static struct ubi_volume *ubi_find_volume(char *volume) { struct ubi_volume *vol; int i; @@ -261,26 +258,24 @@ struct ubi_volume *ubi_find_volume(const char *volume) return vol; } + printf("Volume %s not found!\n", volume); return NULL; } -static struct ubi_volume *ubi_require_volume(const char *volume) +static int ubi_remove_vol(char *volume) { - struct ubi_volume *vol = ubi_find_volume(volume); - - if (!vol) - printf("Volume %s not found!\n", volume); + int err, reserved_pebs, i; + struct ubi_volume *vol; - return vol; -} + vol = ubi_find_volume(volume); + if (vol == NULL) + return ENODEV; -static int __ubi_remove_vol(struct ubi_volume *vol) -{ - int err, reserved_pebs, i; + printf("Remove UBI volume %s (id %d)\n", vol->name, vol->vol_id); if (ubi->ro_mode) { printf("It's read-only mode\n"); - err = -EROFS; + err = EROFS; goto out_err; } @@ -315,40 +310,35 @@ static int __ubi_remove_vol(struct ubi_volume *vol) return 0; out_err: - ubi_err(ubi, "cannot remove volume %s, error %d", vol->name, err); + ubi_err(ubi, "cannot remove volume %s, error %d", volume, err); + if (err < 0) + err = -err; return err; } -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) +static int ubi_rename_vol(char *oldname, char *newname) { struct ubi_volume *vol; struct ubi_rename_entry rename; struct ubi_volume_desc desc; struct list_head list; - vol = ubi_require_volume(oldname); - if (!vol) - return -ENODEV; + vol = ubi_find_volume(oldname); + if (!vol) { + printf("%s: volume %s doesn't exist\n", __func__, oldname); + 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); @@ -364,25 +354,24 @@ static int ubi_rename_vol(const char *oldname, const char *newname) return ubi_rename_volumes(ubi, &list); } -static int ubi_volume_continue_write(const char *volume, const void *buf, - size_t size) +static int ubi_volume_continue_write(char *volume, void *buf, size_t size) { int err; struct ubi_volume *vol; - vol = ubi_require_volume(volume); + vol = ubi_find_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) { @@ -390,7 +379,7 @@ static int ubi_volume_continue_write(const char *volume, const void *buf, 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", @@ -405,27 +394,27 @@ static int ubi_volume_continue_write(const char *volume, const void *buf, return 0; } -int ubi_volume_begin_write(const char *volume, const void *buf, size_t size, - size_t full_size) +int ubi_volume_begin_write(char *volume, void *buf, size_t size, + size_t full_size) { int err; int rsvd_bytes; struct ubi_volume *vol; - vol = ubi_require_volume(volume); + vol = ubi_find_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 */ @@ -435,8 +424,8 @@ int ubi_volume_begin_write(const char *volume, const void *buf, size_t size, return ubi_volume_continue_write(volume, buf, size); } -static int ubi_volume_offset_write(const char *volume, const void *buf, - loff_t offset, size_t size) +static int ubi_volume_offset_write(char *volume, void *buf, loff_t offset, + size_t size) { int len, tbuf_size, ret; u64 lnum; @@ -444,7 +433,7 @@ static int ubi_volume_offset_write(const char *volume, const void *buf, loff_t off = offset; void *tbuf; - vol = ubi_require_volume(volume); + vol = ubi_find_volume(volume); if (!vol) return -ENODEV; @@ -498,8 +487,7 @@ exit: return ret; } -int ubi_volume_write(const char *volume, const void *buf, loff_t offset, - size_t size) +int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size) { int ret; @@ -515,28 +503,36 @@ int ubi_volume_write(const char *volume, const void *buf, loff_t offset, return ret; } -static int __ubi_volume_read(struct ubi_volume *vol, void *buf, loff_t offset, - size_t size) +int ubi_volume_read(char *volume, char *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) + if (size == 0) { + printf("No size specified -> Using max size (%lld)\n", vol->used_bytes); 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); @@ -549,7 +545,7 @@ static int __ubi_volume_read(struct ubi_volume *vol, void *buf, loff_t offset, tbuf = malloc_cache_aligned(tbuf_size); if (!tbuf) { printf("NO MEM\n"); - return -ENOMEM; + return ENOMEM; } len = size > tbuf_size ? tbuf_size : size; @@ -565,6 +561,7 @@ static int __ubi_volume_read(struct ubi_volume *vol, void *buf, loff_t offset, 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; @@ -590,19 +587,7 @@ static int __ubi_volume_read(struct ubi_volume *vol, void *buf, loff_t offset, return err; } -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) +static int ubi_dev_scan(struct mtd_info *info, const char *vid_header_offset) { char ubi_mtd_param_buffer[80]; int err; @@ -615,25 +600,28 @@ static int ubi_dev_scan(const struct mtd_info *info, 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(const char *volume, bool skip_check) +static int ubi_set_skip_check(char *volume, bool skip_check) { struct ubi_vtbl_record vtbl_rec; struct ubi_volume *vol; - vol = ubi_require_volume(volume); + vol = ubi_find_volume(volume); if (!vol) - return -ENODEV; + return ENODEV; + + printf("%sing skip_check on volume %s\n", + skip_check ? "Sett" : "Clear", volume); vtbl_rec = ubi->vtbl[vol->vol_id]; if (skip_check) { @@ -647,7 +635,7 @@ static int ubi_set_skip_check(const char *volume, bool skip_check) return ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec); } -int ubi_detach(void) +static int ubi_detach(void) { #ifdef CONFIG_CMD_UBIFS /* @@ -670,7 +658,7 @@ int ubi_detach(void) return 0; } -int ubi_part(const char *part_name, const char *vid_header_offset) +int ubi_part(char *part_name, const char *vid_header_offset) { struct mtd_info *mtd; int err; @@ -686,7 +674,7 @@ int ubi_part(const 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 -ENODEV; + return 1; } put_mtd_device(mtd); @@ -707,8 +695,6 @@ 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; @@ -723,7 +709,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 CMD_RET_FAILURE; + return 1; } printf("Device %d: %s, MTD partition %s\n", @@ -737,13 +723,12 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc > 3) vid_header_offset = argv[3]; - ret = ubi_part(argv[2], vid_header_offset); - return ret ? CMD_RET_FAILURE : 0; + return ubi_part(argv[2], vid_header_offset); } if ((strcmp(argv[1], "part") != 0) && !ubi) { printf("Error, no UBI device selected!\n"); - return CMD_RET_FAILURE; + return 1; } if (strcmp(argv[1], "info") == 0) { @@ -773,11 +758,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 CMD_RET_USAGE; + return 1; } if (strncmp(argv[1], "create", 6) == 0) { - bool dynamic = true; /* default: dynamic volume */ + int dynamic = 1; /* default: dynamic volume */ int id = UBI_VOL_NUM_AUTO; /* Use maximum available size */ @@ -798,10 +783,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 = false; + dynamic = 0; else if (strncmp(argv[4], "d", 1) != 0) { printf("Incorrect type\n"); - return CMD_RET_USAGE; + return 1; } argc--; } @@ -814,80 +799,38 @@ 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; - if (size) - printf("No size specified -> Using max size (%lld)\n", - size); + printf("No size specified -> Using max size (%lld)\n", size); } /* E.g., create volume */ if (argc == 3) { - 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; + return ubi_create_vol(argv[2], size, dynamic, id, + skipcheck); } } if (strncmp(argv[1], "remove", 6) == 0) { /* E.g., remove volume */ - 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 (argc == 3) + return ubi_remove_vol(argv[2]); } - 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 (IS_ENABLED(CONFIG_CMD_UBI_RENAME) && !strncmp(argv[1], "rename", 6)) + return ubi_rename_vol(argv[2], argv[3]); if (strncmp(argv[1], "skipcheck", 9) == 0) { /* E.g., change skip_check flag */ if (argc == 4) { skipcheck = strncmp(argv[3], "on", 2) == 0; - 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; + return ubi_set_skip_check(argv[2], skipcheck); } } if (strncmp(argv[1], "write", 5) == 0) { + int ret; + if (argc < 5) { printf("Please see usage\n"); - return CMD_RET_USAGE; + return 1; } addr = hextoul(argv[2], NULL); @@ -912,7 +855,7 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) argv[3]); } - return ret ? CMD_RET_FAILURE : 0; + return ret; } if (strncmp(argv[1], "read", 4) == 0) { @@ -931,29 +874,12 @@ static int do_ubi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } if (argc == 3) { - 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; + return ubi_volume_read(argv[3], (char *)addr, 0, size); } } printf("Please see usage\n"); - return CMD_RET_USAGE; + return 1; } U_BOOT_CMD( diff --git a/cmd/ubifs.c b/cmd/ubifs.c index 81f2d37fc7b..22e95db8ca5 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(const char *vol_name) +int cmd_ubifs_mount(char *vol_name) { int ret; diff --git a/cmd/ufetch.c b/cmd/ufetch.c index 763ab42c48a..f8dc904bdd0 100644 --- a/cmd/ufetch.c +++ b/cmd/ufetch.c @@ -157,37 +157,26 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, printf(" (%d baud)", gd->baudrate); putc('\n'); break; - case FEATURES: { - const char *sep = ""; - + case FEATURES: printf("Features:" RESET " "); - if (IS_ENABLED(CONFIG_NET)) { - printf("%sNet", sep); - sep = ", "; - } - if (IS_ENABLED(CONFIG_EFI_LOADER)) { - printf("%sEFI", sep); - sep = ", "; - } - if (IS_ENABLED(CONFIG_CMD_CAT)) { - printf("%scat :3", sep); - sep = ", "; - } + if (IS_ENABLED(CONFIG_NET_LEGACY)) + printf("Net"); + if (IS_ENABLED(CONFIG_EFI_LOADER)) + printf(", EFI"); + if (IS_ENABLED(CONFIG_CMD_CAT)) + printf(", cat :3"); #ifdef CONFIG_ARM64 switch (current_el()) { case 2: - printf("%sVMs", sep); - sep = ", "; + printf(", VMs"); break; case 3: - printf("%sfull control!", sep); - sep = ", "; + printf(", full control!"); break; } #endif printf("\n"); break; - } case RELOCATION: if (gd->flags & GD_FLG_SKIP_RELOC) printf("Relocated:" RESET " no\n"); @@ -202,8 +191,8 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, printf("CPU: " RESET CONFIG_SYS_ARCH " (%d cores, 1 in use)\n", n_cpus); break; case MEMORY: - for (int j = 0; j < CONFIG_NR_DRAM_BANKS && gd->dram[j].size; j++) - size += gd->dram[j].size; + for (int j = 0; j < CONFIG_NR_DRAM_BANKS && gd->bd->bi_dram[j].size; j++) + size += gd->bd->bi_dram[j].size; printf("Memory:" RESET " "); print_size(size, "\n"); break; diff --git a/cmd/upl.c b/cmd/upl.c index be21ec258cb..ef2183d8528 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 < 2) + if (argc < 1) return CMD_RET_USAGE; addr = hextoul(argv[1], NULL); diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index cc7292e10b7..3876d163236 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -66,6 +66,9 @@ 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; } |
