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/hash.c | |
parent | 031725f8cdf33e836d19f35d3fe82c5baa5a2976 (diff) | |
download | u-boot-7e5f460ec457fe310156e399198a41eb0ce1e98c.zip u-boot-7e5f460ec457fe310156e399198a41eb0ce1e98c.tar.gz u-boot-7e5f460ec457fe310156e399198a41eb0ce1e98c.tar.bz2 |
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/hash.c')
-rw-r--r-- | common/hash.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/common/hash.c b/common/hash.c index 059d381..dca2363 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; } } |