diff options
author | Simon Glass <sjg@chromium.org> | 2021-07-24 09:03:29 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-08-02 13:32:14 -0400 |
commit | 7e5f460ec457fe310156e399198a41eb0ce1e98c (patch) | |
tree | 7e89e4d15fcea2d2263c4b4af1be69905537ef42 /common | |
parent | 031725f8cdf33e836d19f35d3fe82c5baa5a2976 (diff) | |
download | u-boot-7e5f460ec457fe310156e399198a41eb0ce1e98c.tar.gz |
global: Convert simple_strtoul() with hex to hextoul()
It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.
Add a proper comment to simple_strtoul() while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/bedbug.c | 2 | ||||
-rw-r--r-- | common/bootm_os.c | 5 | ||||
-rw-r--r-- | common/fdt_support.c | 2 | ||||
-rw-r--r-- | common/hash.c | 12 | ||||
-rw-r--r-- | common/image-fdt.c | 6 | ||||
-rw-r--r-- | common/image-fit.c | 2 | ||||
-rw-r--r-- | common/image.c | 12 | ||||
-rw-r--r-- | common/kallsyms.c | 2 | ||||
-rw-r--r-- | common/lcd.c | 2 | ||||
-rw-r--r-- | common/splash.c | 4 | ||||
-rw-r--r-- | common/splash_source.c | 2 | ||||
-rw-r--r-- | common/update.c | 2 |
12 files changed, 26 insertions, 27 deletions
diff --git a/common/bedbug.c b/common/bedbug.c index 18a35ca23e..6e1fb58080 100644 --- a/common/bedbug.c +++ b/common/bedbug.c @@ -1005,7 +1005,7 @@ long read_number (char *txt) } if (txt[0] == '0' && (txt[1] == 'x' || txt[1] == 'X')) /* hex */ - val = simple_strtoul (&txt[2], NULL, 16); + val = hextoul(&txt[2], NULL); else /* decimal */ val = simple_strtoul (txt, NULL, 10); diff --git a/common/bootm_os.c b/common/bootm_os.c index 0b6325db66..d635037064 100644 --- a/common/bootm_os.c +++ b/common/bootm_os.c @@ -238,7 +238,7 @@ static int do_bootm_plan9(int flag, int argc, char *const argv[], /* See README.plan9 */ s = env_get("confaddr"); if (s != NULL) { - char *confaddr = (char *)simple_strtoul(s, NULL, 16); + char *confaddr = (char *)hextoul(s, NULL); if (argc > 0) { copy_args(confaddr, argc, argv, '\n'); @@ -360,8 +360,7 @@ int do_bootm_vxworks(int flag, int argc, char *const argv[], /* find f=0xnumber flag */ if ((bootargs[pos] == '=') && (pos >= 1) && (bootargs[pos - 1] == 'f')) { - vxflags = simple_strtoul(&bootargs[pos + 1], - NULL, 16); + vxflags = hextoul(&bootargs[pos + 1], NULL); if (vxflags & VXWORKS_SYSFLG_STD_DTB) std_dtb = true; } diff --git a/common/fdt_support.c b/common/fdt_support.c index 240f1e57d1..4341d84bd5 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -579,7 +579,7 @@ void fdt_fixup_ethernet(void *fdt) for (j = 0; j < 6; j++) { mac_addr[j] = tmp ? - simple_strtoul(tmp, &end, 16) : 0; + hextoul(tmp, &end) : 0; if (tmp) tmp = (*end) ? end + 1 : end; } diff --git a/common/hash.c b/common/hash.c index 059d381e23..dca23635ab 100644 --- a/common/hash.c +++ b/common/hash.c @@ -397,7 +397,7 @@ int hash_parse_string(const char *algo_name, const char *str, uint8_t *result) char chr[3]; strlcpy(chr, &str[i * 2], 3); - result[i] = simple_strtoul(chr, NULL, 16); + result[i] = hextoul(chr, NULL); } return 0; @@ -470,7 +470,7 @@ static void store_result(struct hash_algo *algo, const uint8_t *sum, ulong addr; void *buf; - addr = simple_strtoul(dest, NULL, 16); + addr = hextoul(dest, NULL); buf = map_sysmem(addr, algo->digest_size); memcpy(buf, sum, algo->digest_size); unmap_sysmem(buf); @@ -510,7 +510,7 @@ static int parse_verify_sum(struct hash_algo *algo, char *verify_str, ulong addr; void *buf; - addr = simple_strtoul(verify_str, NULL, 16); + addr = hextoul(verify_str, NULL); buf = map_sysmem(addr, algo->digest_size); memcpy(vsum, buf, algo->digest_size); } else { @@ -555,8 +555,8 @@ int hash_command(const char *algo_name, int flags, struct cmd_tbl *cmdtp, if ((argc < 2) || ((flags & HASH_FLAG_VERIFY) && (argc < 3))) return CMD_RET_USAGE; - addr = simple_strtoul(*argv++, NULL, 16); - len = simple_strtoul(*argv++, NULL, 16); + addr = hextoul(*argv++, NULL); + len = hextoul(*argv++, NULL); if (multi_hash()) { struct hash_algo *algo; @@ -628,7 +628,7 @@ int hash_command(const char *algo_name, int flags, struct cmd_tbl *cmdtp, addr, addr + len - 1, crc); if (argc >= 3) { - ptr = (ulong *)simple_strtoul(argv[0], NULL, 16); + ptr = (ulong *)hextoul(argv[0], NULL); *ptr = crc; } } diff --git a/common/image-fdt.c b/common/image-fdt.c index 06dce92a28..9441e63a3d 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -186,7 +186,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size) /* If fdt_high is set use it to select the relocation address */ fdt_high = env_get("fdt_high"); if (fdt_high) { - void *desired_addr = (void *)simple_strtoul(fdt_high, NULL, 16); + void *desired_addr = (void *)hextoul(fdt_high, NULL); if (((ulong) desired_addr) == ~0UL) { /* All ones means use fdt in place */ @@ -297,7 +297,7 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, *of_size = 0; img_addr = (argc == 0) ? image_load_addr : - simple_strtoul(argv[0], NULL, 16); + hextoul(argv[0], NULL); buf = map_sysmem(img_addr, 0); if (argc > 2) @@ -329,7 +329,7 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch, } else #endif { - fdt_addr = simple_strtoul(select, NULL, 16); + fdt_addr = hextoul(select, NULL); debug("* fdt: cmdline image address = 0x%08lx\n", fdt_addr); } diff --git a/common/image-fit.c b/common/image-fit.c index d6b2c3c7ec..aff4670be3 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -53,7 +53,7 @@ static int fit_parse_spec(const char *spec, char sepc, ulong addr_curr, sep = strchr(spec, sepc); if (sep) { if (sep - spec > 0) - *addr = simple_strtoul(spec, NULL, 16); + *addr = hextoul(spec, NULL); *name = sep + 1; return 1; diff --git a/common/image.c b/common/image.c index 51854aae5d..59c52a1f9a 100644 --- a/common/image.c +++ b/common/image.c @@ -662,7 +662,7 @@ static int on_loadaddr(const char *name, const char *value, enum env_op op, switch (op) { case env_op_create: case env_op_overwrite: - image_load_addr = simple_strtoul(value, NULL, 16); + image_load_addr = hextoul(value, NULL); break; default: break; @@ -676,7 +676,7 @@ ulong env_get_bootm_low(void) { char *s = env_get("bootm_low"); if (s) { - ulong tmp = simple_strtoul(s, NULL, 16); + ulong tmp = hextoul(s, NULL); return tmp; } @@ -1060,7 +1060,7 @@ ulong genimg_get_kernel_addr_fit(char * const img_addr, *fit_uname_kernel, kernel_addr); #endif } else { - kernel_addr = simple_strtoul(img_addr, NULL, 16); + kernel_addr = hextoul(img_addr, NULL); debug("* kernel: cmdline image address = 0x%08lx\n", kernel_addr); } @@ -1227,7 +1227,7 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, } else #endif { - rd_addr = simple_strtoul(select, NULL, 16); + rd_addr = hextoul(select, NULL); debug("* ramdisk: cmdline image address = " "0x%08lx\n", rd_addr); @@ -1301,7 +1301,7 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, if (select) end = strchr(select, ':'); if (end) { - rd_len = simple_strtoul(++end, NULL, 16); + rd_len = hextoul(++end, NULL); rd_data = rd_addr; } else #endif @@ -1379,7 +1379,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, /* a value of "no" or a similar string will act like 0, * turning the "load high" feature off. This is intentional. */ - initrd_high = simple_strtoul(s, NULL, 16); + initrd_high = hextoul(s, NULL); if (initrd_high == ~0) initrd_copy_to_ram = 0; } else { diff --git a/common/kallsyms.c b/common/kallsyms.c index ce42a932bb..13344e634b 100644 --- a/common/kallsyms.c +++ b/common/kallsyms.c @@ -31,7 +31,7 @@ const char *symbol_lookup(unsigned long addr, unsigned long *caddr) *caddr = 0; while (*sym) { - sym_addr = simple_strtoul(sym, &esym, 16); + sym_addr = hextoul(sym, &esym); sym = esym; if (sym_addr > addr) break; diff --git a/common/lcd.c b/common/lcd.c index ab5614ad0e..16a0a7cea8 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -747,7 +747,7 @@ static int on_splashimage(const char *name, const char *value, enum env_op op, if (op == env_op_delete) return 0; - addr = simple_strtoul(value, NULL, 16); + addr = hextoul(value, NULL); /* See README.displaying-bmps */ aligned = (addr % 4 == 2); if (!aligned) { diff --git a/common/splash.c b/common/splash.c index 2b9313e03f..de720df9f5 100644 --- a/common/splash.c +++ b/common/splash.c @@ -65,7 +65,7 @@ static int splash_video_logo_load(void) if (!splashimage) return -ENOENT; - bmp_load_addr = simple_strtoul(splashimage, 0, 16); + bmp_load_addr = hextoul(splashimage, 0); if (!bmp_load_addr) { printf("Error: bad 'splashimage' address\n"); return -EFAULT; @@ -162,7 +162,7 @@ int splash_display(void) if (!s) return -EINVAL; - addr = simple_strtoul(s, NULL, 16); + addr = hextoul(s, NULL); ret = splash_screen_prepare(); if (ret) return ret; diff --git a/common/splash_source.c b/common/splash_source.c index 3cf926d91a..d05670f5ee 100644 --- a/common/splash_source.c +++ b/common/splash_source.c @@ -414,7 +414,7 @@ int splash_source_load(struct splash_location *locations, uint size) if (env_splashimage_value == NULL) return -ENOENT; - bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16); + bmp_load_addr = hextoul(env_splashimage_value, 0); if (bmp_load_addr == 0) { printf("Error: bad splashimage address specified\n"); return -EFAULT; diff --git a/common/update.c b/common/update.c index f0848954e5..f5c8684f1b 100644 --- a/common/update.c +++ b/common/update.c @@ -272,7 +272,7 @@ int update_tftp(ulong addr, char *interface, char *devstring) /* get load address of downloaded update file */ env_addr = env_get("loadaddr"); if (env_addr) - addr = simple_strtoul(env_addr, NULL, 16); + addr = hextoul(env_addr, NULL); else addr = CONFIG_UPDATE_LOAD_ADDR; |