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 /cmd/avb.c | |
parent | 031725f8cdf33e836d19f35d3fe82c5baa5a2976 (diff) |
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 'cmd/avb.c')
-rw-r--r-- | cmd/avb.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -22,7 +22,7 @@ int do_avb_init(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc != 2) return CMD_RET_USAGE; - mmc_dev = simple_strtoul(argv[1], NULL, 16); + mmc_dev = hextoul(argv[1], NULL); if (avb_ops) avb_ops_free(avb_ops); @@ -53,9 +53,9 @@ int do_avb_read_part(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; part = argv[1]; - offset = simple_strtoul(argv[2], NULL, 16); - bytes = simple_strtoul(argv[3], NULL, 16); - buffer = (void *)simple_strtoul(argv[4], NULL, 16); + offset = hextoul(argv[2], NULL); + bytes = hextoul(argv[3], NULL); + buffer = (void *)hextoul(argv[4], NULL); if (avb_ops->read_from_partition(avb_ops, part, offset, bytes, buffer, &bytes_read) == @@ -86,8 +86,8 @@ int do_avb_read_part_hex(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; part = argv[1]; - offset = simple_strtoul(argv[2], NULL, 16); - bytes = simple_strtoul(argv[3], NULL, 16); + offset = hextoul(argv[2], NULL); + bytes = hextoul(argv[3], NULL); buffer = malloc(bytes); if (!buffer) { @@ -132,9 +132,9 @@ int do_avb_write_part(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; part = argv[1]; - offset = simple_strtoul(argv[2], NULL, 16); - bytes = simple_strtoul(argv[3], NULL, 16); - buffer = (void *)simple_strtoul(argv[4], NULL, 16); + offset = hextoul(argv[2], NULL); + bytes = hextoul(argv[3], NULL); + buffer = (void *)hextoul(argv[4], NULL); if (avb_ops->write_to_partition(avb_ops, part, offset, bytes, buffer) == AVB_IO_RESULT_OK) { @@ -161,7 +161,7 @@ int do_avb_read_rb(struct cmd_tbl *cmdtp, int flag, int argc, if (argc != 2) return CMD_RET_USAGE; - index = (size_t)simple_strtoul(argv[1], NULL, 16); + index = (size_t)hextoul(argv[1], NULL); if (avb_ops->read_rollback_index(avb_ops, index, &rb_idx) == AVB_IO_RESULT_OK) { @@ -188,8 +188,8 @@ int do_avb_write_rb(struct cmd_tbl *cmdtp, int flag, int argc, if (argc != 3) return CMD_RET_USAGE; - index = (size_t)simple_strtoul(argv[1], NULL, 16); - rb_idx = simple_strtoul(argv[2], NULL, 16); + index = (size_t)hextoul(argv[1], NULL); + rb_idx = hextoul(argv[2], NULL); if (avb_ops->write_rollback_index(avb_ops, index, rb_idx) == AVB_IO_RESULT_OK) |