Commit 7e5f460e authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

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's avatarSimon Glass <sjg@chromium.org>
parent 031725f8
......@@ -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",
......@@ -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");
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
}
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......@@ -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);
......@@ -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);
......@@ -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,
......
......@@ -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;
......
......@@ -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:
......
......@@ -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;
......@@ -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",
......@@ -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);
......
......@@ -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;
}
}
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
......@@ -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;
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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)) {
......
......@@ -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,
......@@ -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++;
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment