Skip to content

Commit

Permalink
global: Convert simple_strtoul() with hex to hextoul()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sjg20 authored and trini committed Aug 2, 2021
1 parent 031725f commit 7e5f460
Show file tree
Hide file tree
Showing 183 changed files with 692 additions and 659 deletions.
12 changes: 6 additions & 6 deletions arch/arm/cpu/armv8/fsl-layerscape/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,28 +565,28 @@ void fdt_fixup_pfe_firmware(void *blob)
if (!p)
return;

pclassfw = (void *)simple_strtoul(p, NULL, 16);
pclassfw = (void *)hextoul(p, NULL);
if (!pclassfw)
return;

p = env_get("class_elf_size");
if (!p)
return;
len_class = simple_strtoul(p, NULL, 16);
len_class = hextoul(p, NULL);

/* If the environment variable is not set, then exit silently */
p = env_get("tmu_elf_firmware");
if (!p)
return;

ptmufw = (void *)simple_strtoul(p, NULL, 16);
ptmufw = (void *)hextoul(p, NULL);
if (!ptmufw)
return;

p = env_get("tmu_elf_size");
if (!p)
return;
len_tmu = simple_strtoul(p, NULL, 16);
len_tmu = hextoul(p, NULL);

if (len_class == 0 || len_tmu == 0) {
printf("PFE FW corrupted. CLASS FW size %d, TMU FW size %d\n",
Expand All @@ -605,14 +605,14 @@ void fdt_fixup_pfe_firmware(void *blob)
if (!p)
return;

putilfw = (void *)simple_strtoul(p, NULL, 16);
putilfw = (void *)hextoul(p, NULL);
if (!putilfw)
return;

p = env_get("util_elf_size");
if (!p)
return;
len_util = simple_strtoul(p, NULL, 16);
len_util = hextoul(p, NULL);

if (len_util) {
printf("PFE Util PE firmware is not added to FDT.\n");
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/lib/semihosting.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int do_smhload(struct cmd_tbl *cmdtp, int flag, int argc,
int ret;
char end_str[64];

load_addr = simple_strtoul(argv[2], NULL, 16);
load_addr = hextoul(argv[2], NULL);
if (!load_addr)
return -1;

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-imx/cmd_dek.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ static int do_dek_blob(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc != 4)
return CMD_RET_USAGE;

src_addr = simple_strtoul(argv[1], NULL, 16);
dst_addr = simple_strtoul(argv[2], NULL, 16);
src_addr = hextoul(argv[1], NULL);
dst_addr = hextoul(argv[2], NULL);
len = simple_strtoul(argv[3], NULL, 10);

return blob_encap_dek(src_addr, dst_addr, len);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/cmd_mfgprot.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int do_mfgprot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (argc != 4)
return CMD_RET_USAGE;

m_addr = simple_strtoul(argv[2], NULL, 16);
m_addr = hextoul(argv[2], NULL);
m_size = simple_strtoul(argv[3], NULL, 10);
m_ptr = map_physmem(m_addr, m_size, MAP_NOCACHE);
if (!m_ptr)
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/mach-imx/cmd_nandbcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1083,13 +1083,13 @@ static int do_nandbcb_bcbonly(int argc, char *const argv[])

mtd = cfg.mtd;

cfg.boot_stream1_address = simple_strtoul(argv[2], NULL, 16);
cfg.boot_stream1_size = simple_strtoul(argv[3], NULL, 16);
cfg.boot_stream1_address = hextoul(argv[2], NULL);
cfg.boot_stream1_size = hextoul(argv[3], NULL);
cfg.boot_stream1_size = ALIGN(cfg.boot_stream1_size, mtd->writesize);

if (argc > 5) {
cfg.boot_stream2_address = simple_strtoul(argv[4], NULL, 16);
cfg.boot_stream2_size = simple_strtoul(argv[5], NULL, 16);
cfg.boot_stream2_address = hextoul(argv[4], NULL);
cfg.boot_stream2_size = hextoul(argv[5], NULL);
cfg.boot_stream2_size = ALIGN(cfg.boot_stream2_size,
mtd->writesize);
}
Expand Down Expand Up @@ -1450,7 +1450,7 @@ static int do_nandbcb_init(int argc, char * const argv[])
if (nandbcb_set_boot_config(argc, argv, &cfg))
return CMD_RET_FAILURE;

addr = simple_strtoul(argv[1], &endp, 16);
addr = hextoul(argv[1], &endp);
if (*argv[1] == 0 || *endp != 0)
return CMD_RET_FAILURE;

Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-imx/hab.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,12 @@ static int do_authenticate_image(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc < 3)
return CMD_RET_USAGE;

addr = simple_strtoul(argv[1], NULL, 16);
length = simple_strtoul(argv[2], NULL, 16);
addr = hextoul(argv[1], NULL);
length = hextoul(argv[2], NULL);
if (argc == 3)
ivt_offset = get_image_ivt_offset(addr);
else
ivt_offset = simple_strtoul(argv[3], NULL, 16);
ivt_offset = hextoul(argv[3], NULL);

rcode = imx_hab_authenticate_image(addr, length, ivt_offset);
if (rcode == 0)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/imx8/ahab.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int do_authenticate(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc < 2)
return CMD_RET_USAGE;

addr = simple_strtoul(argv[1], NULL, 16);
addr = hextoul(argv[1], NULL);

printf("Authenticate OS container at 0x%lx\n", addr);

Expand Down
54 changes: 27 additions & 27 deletions arch/arm/mach-imx/imx8/snvs_security_sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,24 +638,24 @@ static int do_snvs_cfg(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc != (NB_REGISTERS + 1))
return CMD_RET_USAGE;

conf.hp.lock = simple_strtoul(argv[++idx], NULL, 16);
conf.hp.secvio_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.lock = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.secvio_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.tamper_filt_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.tamper_det_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.tamper_det_cfg2 = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.tamper_filt1_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.tamper_filt2_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper1_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper2_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper3_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper4_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper5_cfg = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper_clk_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper_routing_ctl1 = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.act_tamper_routing_ctl2 = simple_strtoul(argv[++idx], NULL, 16);
conf.hp.lock = hextoul(argv[++idx], NULL);
conf.hp.secvio_ctl = hextoul(argv[++idx], NULL);
conf.lp.lock = hextoul(argv[++idx], NULL);
conf.lp.secvio_ctl = hextoul(argv[++idx], NULL);
conf.lp.tamper_filt_cfg = hextoul(argv[++idx], NULL);
conf.lp.tamper_det_cfg = hextoul(argv[++idx], NULL);
conf.lp.tamper_det_cfg2 = hextoul(argv[++idx], NULL);
conf.lp.tamper_filt1_cfg = hextoul(argv[++idx], NULL);
conf.lp.tamper_filt2_cfg = hextoul(argv[++idx], NULL);
conf.lp.act_tamper1_cfg = hextoul(argv[++idx], NULL);
conf.lp.act_tamper2_cfg = hextoul(argv[++idx], NULL);
conf.lp.act_tamper3_cfg = hextoul(argv[++idx], NULL);
conf.lp.act_tamper4_cfg = hextoul(argv[++idx], NULL);
conf.lp.act_tamper5_cfg = hextoul(argv[++idx], NULL);
conf.lp.act_tamper_ctl = hextoul(argv[++idx], NULL);
conf.lp.act_tamper_clk_ctl = hextoul(argv[++idx], NULL);
conf.lp.act_tamper_routing_ctl1 = hextoul(argv[++idx], NULL);
conf.lp.act_tamper_routing_ctl2 = hextoul(argv[++idx], NULL);

err = apply_snvs_config(&conf);

Expand Down Expand Up @@ -690,12 +690,12 @@ static int do_snvs_dgo_cfg(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc != (6 + 1))
return CMD_RET_USAGE;

conf.tamper_offset_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.tamper_pull_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.tamper_ana_test_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.tamper_sensor_trim_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.tamper_misc_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.tamper_core_volt_mon_ctl = simple_strtoul(argv[++idx], NULL, 16);
conf.tamper_offset_ctl = hextoul(argv[++idx], NULL);
conf.tamper_pull_ctl = hextoul(argv[++idx], NULL);
conf.tamper_ana_test_ctl = hextoul(argv[++idx], NULL);
conf.tamper_sensor_trim_ctl = hextoul(argv[++idx], NULL);
conf.tamper_misc_ctl = hextoul(argv[++idx], NULL);
conf.tamper_core_volt_mon_ctl = hextoul(argv[++idx], NULL);

err = apply_snvs_dgo_config(&conf);

Expand Down Expand Up @@ -727,7 +727,7 @@ static int do_tamper_pin_cfg(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_USAGE;

conf.pad = simple_strtoul(argv[++idx], NULL, 10);
conf.mux_conf = simple_strtoul(argv[++idx], NULL, 16);
conf.mux_conf = hextoul(argv[++idx], NULL);

err = apply_tamper_pin_list_config(&conf, 1);

Expand Down Expand Up @@ -761,8 +761,8 @@ static int do_snvs_clear_status(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc != (2 + 1))
return CMD_RET_USAGE;

conf.lp.status = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.tamper_det_status = simple_strtoul(argv[++idx], NULL, 16);
conf.lp.status = hextoul(argv[++idx], NULL);
conf.lp.tamper_det_status = hextoul(argv[++idx], NULL);

scierr = check_write_secvio_config(SC_CONF_OFFSET_OF(lp.status),
&conf.lp.status, NULL, NULL, NULL,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/imx_bootaux.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static int do_bootaux(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}

addr = simple_strtoul(argv[1], NULL, 16);
addr = hextoul(argv[1], NULL);

if (!addr)
return CMD_RET_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/mx6/mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int cpu_release(u32 nr, int argc, char *const argv[])
{
uint32_t boot_addr;

boot_addr = simple_strtoul(argv[0], NULL, 16);
boot_addr = hextoul(argv[0], NULL);

switch (nr) {
case 1:
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-keystone/cmd_mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,

freq = CONFIG_SYS_HZ_CLOCK;

addr = simple_strtoul(argv[1], NULL, 16);
addr = hextoul(argv[1], NULL);

header = (struct image_header *)addr;

Expand All @@ -40,7 +40,7 @@ static int do_mon_install(struct cmd_tbl *cmdtp, int flag, int argc,
size);

if (argc >= 3)
ecrypt_bm_addr = simple_strtoul(argv[2], NULL, 16);
ecrypt_bm_addr = hextoul(argv[2], NULL);

rcode = mon_install(load_addr, dpsc_base, freq, ecrypt_bm_addr);
printf("## installed monitor @ 0x%x, freq [%d], status %d\n",
Expand Down Expand Up @@ -76,8 +76,8 @@ int do_mon_power(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc < 3)
return CMD_RET_USAGE;

core_id = simple_strtoul(argv[1], NULL, 16);
on = simple_strtoul(argv[2], NULL, 16);
core_id = hextoul(argv[1], NULL);
on = hextoul(argv[2], NULL);

if (on)
rcode = mon_power_on(core_id, fn);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-snapdragon/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void msm_generate_mac_addr(u8 *mac)
mac[0] = 0x02;
mac[1] = 00;
for (i = 3; i >= 0; i--) {
mac[i + 2] = simple_strtoul(&sn[2 * i], NULL, 16);
mac[i + 2] = hextoul(&sn[2 * i], NULL);
sn[2 * i] = 0;
}
}
2 changes: 1 addition & 1 deletion arch/arm/mach-socfpga/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int do_bridge(struct cmd_tbl *cmdtp, int flag, int argc,
argv++;

if (argc == 3)
mask = simple_strtoul(argv[1], NULL, 16);
mask = hextoul(argv[1], NULL);

switch (*argv[0]) {
case 'e': /* Enable */
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-socfpga/vab.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ static int do_vab(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc < 3)
return CMD_RET_USAGE;

addr = simple_strtoul(argv[1], NULL, 16);
len = simple_strtoul(argv[2], NULL, 16);
addr = hextoul(argv[1], NULL);
len = hextoul(argv[2], NULL);

if (socfpga_vendor_authentication((void *)&addr, (size_t *)&len) != 0)
return CMD_RET_FAILURE;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-stm32mp/cmd_stm32key.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static int do_stm32key_read(struct cmd_tbl *cmdtp, int flag, int argc, char *con
return CMD_RET_SUCCESS;
}

addr = simple_strtoul(argv[1], NULL, 16);
addr = hextoul(argv[1], NULL);
if (!addr)
return CMD_RET_USAGE;

Expand All @@ -185,7 +185,7 @@ static int do_stm32key_fuse(struct cmd_tbl *cmdtp, int flag, int argc, char *con
yes = true;
}

addr = simple_strtoul(argv[argc - 1], NULL, 16);
addr = hextoul(argv[argc - 1], NULL);
if (!addr)
return CMD_RET_USAGE;

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
addr = STM32_DDR_BASE;
size = 0;
if (argc > 3) {
addr = simple_strtoul(argv[3], NULL, 16);
addr = hextoul(argv[3], NULL);
if (!addr)
return CMD_RET_FAILURE;
}
if (argc > 4)
size = simple_strtoul(argv[4], NULL, 16);
size = hextoul(argv[4], NULL);

/* check STM32IMAGE presence */
if (size == 0) {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-uniphier/board_late_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void uniphier_set_env_addr(const char *env, const char *offset_env)
if (!str)
goto fail;

offset = simple_strtoul(str, &end, 16);
offset = hextoul(str, &end);
if (*end)
goto fail;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-zynqmp/mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int cpu_release(u32 nr, int argc, char *const argv[])
return 1;
}

u32 boot_addr = simple_strtoul(argv[0], NULL, 16);
u32 boot_addr = hextoul(argv[0], NULL);
u32 boot_addr_uniq = 0;
if (!(boot_addr == ZYNQMP_R5_LOVEC_ADDR ||
boot_addr == ZYNQMP_R5_HIVEC_ADDR)) {
Expand Down
5 changes: 2 additions & 3 deletions arch/mips/mach-octeon/bootoctlinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ int octeon_parse_bootopts(int argc, char *const argv[],
} else if (!strncmp(argv[arg], "forceboot", 9)) {
boot_args->forceboot = true;
} else if (!strncmp(argv[arg], "nodemask=", 9)) {
boot_args->node_mask = simple_strtoul(argv[arg] + 9,
NULL, 16);
boot_args->node_mask = hextoul(argv[arg] + 9, NULL);
} else if (!strncmp(argv[arg], "numcores=", 9)) {
memset(node_values, 0, sizeof(node_values));
num_values = octeon_parse_nodes(node_values,
Expand Down Expand Up @@ -383,7 +382,7 @@ int do_bootoctlinux(struct cmd_tbl *cmdtp, int flag, int argc,
argv[1][1] == 'x' ||
argv[1][1] == 'X' ||
argv[1][1] == '\0'))) {
addr = simple_strtoul(argv[1], NULL, 16);
addr = hextoul(argv[1], NULL);
if (!addr)
addr = CONFIG_SYS_LOAD_ADDR;
arg_start++;
Expand Down
2 changes: 1 addition & 1 deletion arch/nds32/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)

s = env_get("machid");
if (s) {
machid = simple_strtoul(s, NULL, 16);
machid = hextoul(s, NULL);
printf("Using machid 0x%x from environment\n", machid);
}

Expand Down
2 changes: 1 addition & 1 deletion arch/nios2/lib/bootm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int do_bootm_linux(int flag, int argc, char *const argv[],
of_flat_tree = images->ft_addr;
#endif
if (!of_flat_tree && argc > 1)
of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
of_flat_tree = (char *)hextoul(argv[1], NULL);
if (of_flat_tree)
initrd_end = (ulong)of_flat_tree;

Expand Down
Loading

0 comments on commit 7e5f460

Please sign in to comment.