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>
diff --git a/cmd/mmc.c b/cmd/mmc.c
index b942576..f722778 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -189,7 +189,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- key_addr = (void *)simple_strtoul(argv[1], NULL, 16);
+ key_addr = (void *)hextoul(argv[1], NULL);
if (!confirm_key_prog())
return CMD_RET_FAILURE;
if (mmc_rpmb_set_key(mmc, key_addr)) {
@@ -211,12 +211,12 @@
if (argc < 4)
return CMD_RET_USAGE;
- addr = (void *)simple_strtoul(argv[1], NULL, 16);
- blk = simple_strtoul(argv[2], NULL, 16);
- cnt = simple_strtoul(argv[3], NULL, 16);
+ addr = (void *)hextoul(argv[1], NULL);
+ blk = hextoul(argv[2], NULL);
+ cnt = hextoul(argv[3], NULL);
if (argc == 5)
- key_addr = (void *)simple_strtoul(argv[4], NULL, 16);
+ key_addr = (void *)hextoul(argv[4], NULL);
printf("\nMMC RPMB read: dev # %d, block # %d, count %d ... ",
curr_device, blk, cnt);
@@ -240,10 +240,10 @@
if (argc != 5)
return CMD_RET_USAGE;
- addr = (void *)simple_strtoul(argv[1], NULL, 16);
- blk = simple_strtoul(argv[2], NULL, 16);
- cnt = simple_strtoul(argv[3], NULL, 16);
- key_addr = (void *)simple_strtoul(argv[4], NULL, 16);
+ addr = (void *)hextoul(argv[1], NULL);
+ blk = hextoul(argv[2], NULL);
+ cnt = hextoul(argv[3], NULL);
+ key_addr = (void *)hextoul(argv[4], NULL);
printf("\nMMC RPMB write: dev # %d, block # %d, count %d ... ",
curr_device, blk, cnt);
@@ -334,9 +334,9 @@
if (argc != 4)
return CMD_RET_USAGE;
- addr = (void *)simple_strtoul(argv[1], NULL, 16);
- blk = simple_strtoul(argv[2], NULL, 16);
- cnt = simple_strtoul(argv[3], NULL, 16);
+ addr = (void *)hextoul(argv[1], NULL);
+ blk = hextoul(argv[2], NULL);
+ cnt = hextoul(argv[3], NULL);
mmc = init_mmc_device(curr_device, false);
if (!mmc)
@@ -379,8 +379,8 @@
if (argc != 3)
return CMD_RET_USAGE;
- addr = (void *)simple_strtoul(argv[1], NULL, 16);
- blk = simple_strtoul(argv[2], NULL, 16);
+ addr = (void *)hextoul(argv[1], NULL);
+ blk = hextoul(argv[2], NULL);
if (!is_sparse_image(addr)) {
printf("Not a sparse image\n");
@@ -427,9 +427,9 @@
if (argc != 4)
return CMD_RET_USAGE;
- addr = (void *)simple_strtoul(argv[1], NULL, 16);
- blk = simple_strtoul(argv[2], NULL, 16);
- cnt = simple_strtoul(argv[3], NULL, 16);
+ addr = (void *)hextoul(argv[1], NULL);
+ blk = hextoul(argv[2], NULL);
+ cnt = hextoul(argv[3], NULL);
mmc = init_mmc_device(curr_device, false);
if (!mmc)
@@ -457,8 +457,8 @@
if (argc != 3)
return CMD_RET_USAGE;
- blk = simple_strtoul(argv[1], NULL, 16);
- cnt = simple_strtoul(argv[2], NULL, 16);
+ blk = hextoul(argv[1], NULL);
+ cnt = hextoul(argv[2], NULL);
mmc = init_mmc_device(curr_device, false);
if (!mmc)
@@ -908,7 +908,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- val = simple_strtoul(argv[1], NULL, 16);
+ val = hextoul(argv[1], NULL);
mmc = find_mmc_device(curr_device);
if (!mmc) {