Merge branch '2021-08-02-numeric-input-cleanups'
- Merge in a series that cleans up and makes more consistent how we deal
with numeric input on the CLI. This saves a few bytes in a lot of
places.
diff --git a/README b/README
index 4fdc49f..1c1db98 100644
--- a/README
+++ b/README
@@ -3510,47 +3510,6 @@
The return value is 0 if the variable change is accepted and 1 otherwise.
-Command Line Parsing:
-=====================
-
-There are two different command line parsers available with U-Boot:
-the old "simple" one, and the much more powerful "hush" shell:
-
-Old, simple command line parser:
---------------------------------
-
-- supports environment variables (through setenv / saveenv commands)
-- several commands on one line, separated by ';'
-- variable substitution using "... ${name} ..." syntax
-- special characters ('$', ';') can be escaped by prefixing with '\',
- for example:
- setenv bootcmd bootm \${address}
-- You can also escape text by enclosing in single apostrophes, for example:
- setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off'
-
-Hush shell:
------------
-
-- similar to Bourne shell, with control structures like
- if...then...else...fi, for...do...done; while...do...done,
- until...do...done, ...
-- supports environment ("global") variables (through setenv / saveenv
- commands) and local shell variables (through standard shell syntax
- "name=value"); only environment variables can be used with "run"
- command
-
-General rules:
---------------
-
-(1) If a command line (or an environment variable executed by a "run"
- command) contains several commands separated by semicolon, and
- one of these commands fails, then the remaining commands will be
- executed anyway.
-
-(2) If you execute several variables with one call to run (i. e.
- calling run with a list of variables as arguments), any failing
- command will cause "run" to terminate, i. e. the remaining
- variables are not executed.
Note for Redundant Ethernet Interfaces:
=======================================
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index f1624ff..6eb7f9c 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -565,28 +565,28 @@
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 @@
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");
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 0562d28..1641b65 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -277,7 +277,7 @@
ulong interval_mhz = get_bus_freq(0) / (1000 * 1000);
if (interval)
- interval_mhz = simple_strtoul(interval, NULL, 10);
+ interval_mhz = dectoul(interval, NULL);
return interval_mhz;
}
diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c
index 904fddd..9fd8245 100644
--- a/arch/arm/lib/semihosting.c
+++ b/arch/arm/lib/semihosting.c
@@ -191,7 +191,7 @@
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;
diff --git a/arch/arm/mach-imx/cmd_dek.c b/arch/arm/mach-imx/cmd_dek.c
index b10ead1..1e3cfee 100644
--- a/arch/arm/mach-imx/cmd_dek.c
+++ b/arch/arm/mach-imx/cmd_dek.c
@@ -300,9 +300,9 @@
if (argc != 4)
return CMD_RET_USAGE;
- src_addr = simple_strtoul(argv[1], NULL, 16);
- dst_addr = simple_strtoul(argv[2], NULL, 16);
- len = simple_strtoul(argv[3], NULL, 10);
+ src_addr = hextoul(argv[1], NULL);
+ dst_addr = hextoul(argv[2], NULL);
+ len = dectoul(argv[3], NULL);
return blob_encap_dek(src_addr, dst_addr, len);
}
diff --git a/arch/arm/mach-imx/cmd_mfgprot.c b/arch/arm/mach-imx/cmd_mfgprot.c
index 1430f61..1e866b7 100644
--- a/arch/arm/mach-imx/cmd_mfgprot.c
+++ b/arch/arm/mach-imx/cmd_mfgprot.c
@@ -71,8 +71,8 @@
if (argc != 4)
return CMD_RET_USAGE;
- m_addr = simple_strtoul(argv[2], NULL, 16);
- m_size = simple_strtoul(argv[3], NULL, 10);
+ m_addr = hextoul(argv[2], NULL);
+ m_size = dectoul(argv[3], NULL);
m_ptr = map_physmem(m_addr, m_size, MAP_NOCACHE);
if (!m_ptr)
return -ENOMEM;
diff --git a/arch/arm/mach-imx/cmd_nandbcb.c b/arch/arm/mach-imx/cmd_nandbcb.c
index 7157c9e..cd51344 100644
--- a/arch/arm/mach-imx/cmd_nandbcb.c
+++ b/arch/arm/mach-imx/cmd_nandbcb.c
@@ -1083,13 +1083,13 @@
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 @@
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;
diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index 00bd157..cc39e6b 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -609,12 +609,12 @@
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)
diff --git a/arch/arm/mach-imx/imx8/ahab.c b/arch/arm/mach-imx/imx8/ahab.c
index 6392fe2..015267c 100644
--- a/arch/arm/mach-imx/imx8/ahab.c
+++ b/arch/arm/mach-imx/imx8/ahab.c
@@ -161,7 +161,7 @@
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);
diff --git a/arch/arm/mach-imx/imx8/snvs_security_sc.c b/arch/arm/mach-imx/imx8/snvs_security_sc.c
index 6f9b1c9..507b5b4 100644
--- a/arch/arm/mach-imx/imx8/snvs_security_sc.c
+++ b/arch/arm/mach-imx/imx8/snvs_security_sc.c
@@ -638,24 +638,24 @@
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 @@
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);
@@ -726,8 +726,8 @@
if (argc != (2 + 1))
return CMD_RET_USAGE;
- conf.pad = simple_strtoul(argv[++idx], NULL, 10);
- conf.mux_conf = simple_strtoul(argv[++idx], NULL, 16);
+ conf.pad = dectoul(argv[++idx], NULL);
+ conf.mux_conf = hextoul(argv[++idx], NULL);
err = apply_tamper_pin_list_config(&conf, 1);
@@ -761,8 +761,8 @@
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,
diff --git a/arch/arm/mach-imx/imx_bootaux.c b/arch/arm/mach-imx/imx_bootaux.c
index 30fb45d..9ffe5ac 100644
--- a/arch/arm/mach-imx/imx_bootaux.c
+++ b/arch/arm/mach-imx/imx_bootaux.c
@@ -180,7 +180,7 @@
return CMD_RET_SUCCESS;
}
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
if (!addr)
return CMD_RET_FAILURE;
diff --git a/arch/arm/mach-imx/mx6/mp.c b/arch/arm/mach-imx/mx6/mp.c
index 2fdf070..de9ace0 100644
--- a/arch/arm/mach-imx/mx6/mp.c
+++ b/arch/arm/mach-imx/mx6/mp.c
@@ -47,7 +47,7 @@
{
uint32_t boot_addr;
- boot_addr = simple_strtoul(argv[0], NULL, 16);
+ boot_addr = hextoul(argv[0], NULL);
switch (nr) {
case 1:
diff --git a/arch/arm/mach-keystone/cmd_clock.c b/arch/arm/mach-keystone/cmd_clock.c
index 7165d66..72dc394 100644
--- a/arch/arm/mach-keystone/cmd_clock.c
+++ b/arch/arm/mach-keystone/cmd_clock.c
@@ -42,9 +42,9 @@
else
goto pll_cmd_usage;
- cmd_pll_data.pll_m = simple_strtoul(argv[2], NULL, 10);
- cmd_pll_data.pll_d = simple_strtoul(argv[3], NULL, 10);
- cmd_pll_data.pll_od = simple_strtoul(argv[4], NULL, 10);
+ cmd_pll_data.pll_m = dectoul(argv[2], NULL);
+ cmd_pll_data.pll_d = dectoul(argv[3], NULL);
+ cmd_pll_data.pll_od = dectoul(argv[4], NULL);
printf("Trying to set pll %d; mult %d; div %d; OD %d\n",
cmd_pll_data.pll, cmd_pll_data.pll_m,
@@ -72,7 +72,7 @@
if (argc != 2)
goto getclk_cmd_usage;
- clk = simple_strtoul(argv[1], NULL, 10);
+ clk = dectoul(argv[1], NULL);
freq = ks_clk_get_rate(clk);
if (freq)
@@ -101,7 +101,7 @@
if (argc != 3)
goto psc_cmd_usage;
- psc_module = simple_strtoul(argv[1], NULL, 10);
+ psc_module = dectoul(argv[1], NULL);
if (strcmp(argv[2], "en") == 0) {
res = psc_enable_module(psc_module);
printf("psc_enable_module(%d) - %s\n", psc_module,
diff --git a/arch/arm/mach-keystone/cmd_mon.c b/arch/arm/mach-keystone/cmd_mon.c
index 049d573..e26296b 100644
--- a/arch/arm/mach-keystone/cmd_mon.c
+++ b/arch/arm/mach-keystone/cmd_mon.c
@@ -25,7 +25,7 @@
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 @@
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 @@
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);
diff --git a/arch/arm/mach-kirkwood/cpu.c b/arch/arm/mach-kirkwood/cpu.c
index 339ae7f..3953aa9 100644
--- a/arch/arm/mach-kirkwood/cpu.c
+++ b/arch/arm/mach-kirkwood/cpu.c
@@ -125,7 +125,7 @@
return;
/* read sysrstdelay value */
- sysrst_dly = (u32) simple_strtoul(s, NULL, 10);
+ sysrst_dly = (u32)dectoul(s, NULL);
/* read SysRst Length counter register (bits 28:0) */
sysrst_cnt = (0x1fffffff & readl(KW_REG_SYSRST_CNT));
diff --git a/arch/arm/mach-nexell/clock.c b/arch/arm/mach-nexell/clock.c
index d5b46a8..24fa204 100644
--- a/arch/arm/mach-nexell/clock.c
+++ b/arch/arm/mach-nexell/clock.c
@@ -592,7 +592,7 @@
c = strrchr((const char *)str, (int)'.');
if (!c || !cdev->peri)
break;
- devid = simple_strtoul(++c, NULL, 10);
+ devid = dectoul(++c, NULL);
if (cdev->peri->dev_id == devid)
break;
}
diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
index aaa561c..985625a 100644
--- a/arch/arm/mach-snapdragon/misc.c
+++ b/arch/arm/mach-snapdragon/misc.c
@@ -47,7 +47,7 @@
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;
}
}
diff --git a/arch/arm/mach-socfpga/misc.c b/arch/arm/mach-socfpga/misc.c
index 64a7c9d..f8d3d48 100644
--- a/arch/arm/mach-socfpga/misc.c
+++ b/arch/arm/mach-socfpga/misc.c
@@ -191,7 +191,7 @@
argv++;
if (argc == 3)
- mask = simple_strtoul(argv[1], NULL, 16);
+ mask = hextoul(argv[1], NULL);
switch (*argv[0]) {
case 'e': /* Enable */
diff --git a/arch/arm/mach-socfpga/vab.c b/arch/arm/mach-socfpga/vab.c
index 85b3f30..e146f2c 100644
--- a/arch/arm/mach-socfpga/vab.c
+++ b/arch/arm/mach-socfpga/vab.c
@@ -17,8 +17,8 @@
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;
diff --git a/arch/arm/mach-stm32mp/cmd_stm32key.c b/arch/arm/mach-stm32mp/cmd_stm32key.c
index 50840b0..68f2892 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32key.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32key.c
@@ -162,7 +162,7 @@
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 @@
yes = true;
}
- addr = simple_strtoul(argv[argc - 1], NULL, 16);
+ addr = hextoul(argv[argc - 1], NULL);
if (!addr)
return CMD_RET_USAGE;
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index 064f51b..be53a52 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -59,17 +59,17 @@
return CMD_RET_USAGE;
}
- dev = (int)simple_strtoul(argv[2], NULL, 10);
+ dev = (int)dectoul(argv[2], NULL);
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) {
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 96ebc6d..26fe8b6 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -253,7 +253,7 @@
result = -EINVAL;
else
part->bin_nb =
- simple_strtoul(&p[7], NULL, 10);
+ dectoul(&p[7], NULL);
}
} else if (!strcmp(p, "System")) {
part->part_type = PART_SYSTEM;
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c
index b33c4b1..b5356ed 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -66,7 +66,7 @@
if (!str)
goto fail;
- offset = simple_strtoul(str, &end, 16);
+ offset = hextoul(str, &end);
if (*end)
goto fail;
}
diff --git a/arch/arm/mach-zynqmp/mp.c b/arch/arm/mach-zynqmp/mp.c
index 74783ae..704520e 100644
--- a/arch/arm/mach-zynqmp/mp.c
+++ b/arch/arm/mach-zynqmp/mp.c
@@ -252,7 +252,7 @@
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)) {
diff --git a/arch/mips/mach-octeon/bootoctlinux.c b/arch/mips/mach-octeon/bootoctlinux.c
index c195dc2..349da08 100644
--- a/arch/mips/mach-octeon/bootoctlinux.c
+++ b/arch/mips/mach-octeon/bootoctlinux.c
@@ -281,8 +281,7 @@
} 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 @@
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++;
diff --git a/arch/nds32/lib/bootm.c b/arch/nds32/lib/bootm.c
index b3b8bc2..4cb0f53 100644
--- a/arch/nds32/lib/bootm.c
+++ b/arch/nds32/lib/bootm.c
@@ -64,7 +64,7 @@
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);
}
diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c
index 2c8f973..5037467 100644
--- a/arch/nios2/lib/bootm.c
+++ b/arch/nios2/lib/bootm.c
@@ -27,7 +27,7 @@
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;
diff --git a/arch/powerpc/cpu/mpc83xx/ecc.c b/arch/powerpc/cpu/mpc83xx/ecc.c
index 1343dd3..7a8ec7f 100644
--- a/arch/powerpc/cpu/mpc83xx/ecc.c
+++ b/arch/powerpc/cpu/mpc83xx/ecc.c
@@ -138,7 +138,7 @@
}
if (argc == 3) {
if (strcmp(argv[1], "sbecnt") == 0) {
- val = simple_strtoul(argv[2], NULL, 10);
+ val = dectoul(argv[2], NULL);
if (val > 255) {
printf("Incorrect Counter value, "
"should be 0..255\n");
@@ -151,7 +151,7 @@
ddr->err_sbe = val;
return 0;
} else if (strcmp(argv[1], "sbethr") == 0) {
- val = simple_strtoul(argv[2], NULL, 10);
+ val = dectoul(argv[2], NULL);
if (val > 255) {
printf("Incorrect Counter value, "
"should be 0..255\n");
@@ -219,17 +219,17 @@
ddr->err_detect = val;
return 0;
} else if (strcmp(argv[1], "injectdatahi") == 0) {
- val = simple_strtoul(argv[2], NULL, 16);
+ val = hextoul(argv[2], NULL);
ddr->data_err_inject_hi = val;
return 0;
} else if (strcmp(argv[1], "injectdatalo") == 0) {
- val = simple_strtoul(argv[2], NULL, 16);
+ val = hextoul(argv[2], NULL);
ddr->data_err_inject_lo = val;
return 0;
} else if (strcmp(argv[1], "injectecc") == 0) {
- val = simple_strtoul(argv[2], NULL, 16);
+ val = hextoul(argv[2], NULL);
if (val > 0xff) {
printf("Incorrect ECC inject mask, "
"should be 0x00..0xff\n");
@@ -269,8 +269,8 @@
}
if (argc == 4) {
if (strcmp(argv[1], "testdw") == 0) {
- addr = (u64 *) simple_strtoul(argv[2], NULL, 16);
- count = simple_strtoul(argv[3], NULL, 16);
+ addr = (u64 *)hextoul(argv[2], NULL);
+ count = hextoul(argv[3], NULL);
if ((u32) addr % 8) {
printf("Address not aligned on "
@@ -308,8 +308,8 @@
return 0;
}
if (strcmp(argv[1], "testword") == 0) {
- addr = (u64 *) simple_strtoul(argv[2], NULL, 16);
- count = simple_strtoul(argv[3], NULL, 16);
+ addr = (u64 *)hextoul(argv[2], NULL);
+ count = hextoul(argv[3], NULL);
if ((u32) addr % 8) {
printf("Address not aligned on "
diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c
index 653efe0..b1b002c 100644
--- a/arch/powerpc/cpu/mpc85xx/mp.c
+++ b/arch/powerpc/cpu/mpc85xx/mp.c
@@ -167,7 +167,7 @@
for (i = 1; i < 3; i++) {
if (argv[i][0] != '-') {
u8 entry = boot_entry_map[i];
- val = simple_strtoul(argv[i], NULL, 16);
+ val = hextoul(argv[i], NULL);
table[entry] = val;
}
}
diff --git a/arch/sh/lib/zimageboot.c b/arch/sh/lib/zimageboot.c
index c38f093..c2e285f 100644
--- a/arch/sh/lib/zimageboot.c
+++ b/arch/sh/lib/zimageboot.c
@@ -37,11 +37,12 @@
}
if (s0)
- zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);
+ zboot_entry = (ulong (*)(int, char * const []))hextoul(s0,
+ NULL);
/* empty_zero_page */
if (s1)
- param = (unsigned char*)simple_strtoul(s1, NULL, 16);
+ param = (unsigned char *)hextoul(s1, NULL);
/* Linux kernel command line */
cmdline = (char *)param + COMMAND_LINE;
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index cf4210c..9938c80 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -405,17 +405,17 @@
}
if (s)
- state.bzimage_addr = simple_strtoul(s, NULL, 16);
+ state.bzimage_addr = hextoul(s, NULL);
if (argc >= 3) {
/* argv[2] holds the size of the bzImage */
- state.bzimage_size = simple_strtoul(argv[2], NULL, 16);
+ state.bzimage_size = hextoul(argv[2], NULL);
}
if (argc >= 4)
- state.initrd_addr = simple_strtoul(argv[3], NULL, 16);
+ state.initrd_addr = hextoul(argv[3], NULL);
if (argc >= 5)
- state.initrd_size = simple_strtoul(argv[4], NULL, 16);
+ state.initrd_size = hextoul(argv[4], NULL);
if (argc >= 6) {
/*
* When the base_ptr is passed in, we assume that the image is
@@ -428,7 +428,7 @@
* load address and set bzimage_addr to 0 so we know that it
* cannot be proceesed (or processed again).
*/
- state.base_ptr = (void *)simple_strtoul(argv[5], NULL, 16);
+ state.base_ptr = (void *)hextoul(argv[5], NULL);
state.load_address = state.bzimage_addr;
state.bzimage_addr = 0;
}
@@ -702,7 +702,7 @@
struct boot_params *base_ptr = state.base_ptr;
if (argc > 1)
- base_ptr = (void *)simple_strtoul(argv[1], NULL, 16);
+ base_ptr = (void *)hextoul(argv[1], NULL);
if (!base_ptr) {
printf("No zboot setup_base\n");
return CMD_RET_FAILURE;
@@ -749,7 +749,7 @@
if (argc > 1) {
char *endp;
- simple_strtoul(argv[1], &endp, 16);
+ hextoul(argv[1], &endp);
/*
* endp pointing to nul means that argv[1] was just a valid
* number, so pass it along to the normal processing
diff --git a/board/Arcturus/ucp1020/ucp1020.c b/board/Arcturus/ucp1020/ucp1020.c
index 24d1d57..ee8a9e0 100644
--- a/board/Arcturus/ucp1020/ucp1020.c
+++ b/board/Arcturus/ucp1020/ucp1020.c
@@ -52,7 +52,7 @@
*/
int name_to_gpio(const char *name)
{
- int gpio = 31 - simple_strtoul(name, NULL, 10);
+ int gpio = 31 - dectoul(name, NULL);
if (gpio < 16)
gpio = -1;
diff --git a/board/BuS/eb_cpu5282/eb_cpu5282.c b/board/BuS/eb_cpu5282/eb_cpu5282.c
index 144a089..b739bc3 100644
--- a/board/BuS/eb_cpu5282/eb_cpu5282.c
+++ b/board/BuS/eb_cpu5282/eb_cpu5282.c
@@ -194,13 +194,13 @@
printf("Init Video as ");
s = env_get("displaywidth");
if (s != NULL)
- display_width = simple_strtoul(s, NULL, 10);
+ display_width = dectoul(s, NULL);
else
display_width = 256;
s = env_get("displayheight");
if (s != NULL)
- display_height = simple_strtoul(s, NULL, 10);
+ display_height = dectoul(s, NULL);
else
display_height = 256;
@@ -214,7 +214,7 @@
#ifdef CONFIG_SPLASH_SCREEN
s = env_get("splashimage");
if (s != NULL) {
- splash = simple_strtoul(s, NULL, 16);
+ splash = hextoul(s, NULL);
vcxk_acknowledge_wait();
video_display_bitmap(splash, 0, 0);
}
@@ -234,8 +234,8 @@
switch (argc) {
case 3:
- side = simple_strtoul(argv[1], NULL, 10);
- bright = simple_strtoul(argv[2], NULL, 10);
+ side = dectoul(argv[1], NULL);
+ bright = dectoul(argv[2], NULL);
if ((side >= 0) && (side <= 3) &&
(bright >= 0) && (bright <= 1000)) {
vcxk_setbrightness(side, bright);
diff --git a/board/Marvell/octeontx2/board.c b/board/Marvell/octeontx2/board.c
index 9b973a4..4e8cb83 100644
--- a/board/Marvell/octeontx2/board.c
+++ b/board/Marvell/octeontx2/board.c
@@ -230,7 +230,7 @@
if (argc < 2)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
fdt = board_fdt_blob_setup();
entry = (uboot_entry_t)addr;
flush_cache((ulong)addr, 1 << 20); /* 1MiB should be enough */
diff --git a/board/amlogic/beelink-s922x/beelink-s922x.c b/board/amlogic/beelink-s922x/beelink-s922x.c
index bb74426..adae27f 100644
--- a/board/amlogic/beelink-s922x/beelink-s922x.c
+++ b/board/amlogic/beelink-s922x/beelink-s922x.c
@@ -39,7 +39,7 @@
tmp[0] = efuse_mac_addr[i * 2];
tmp[1] = efuse_mac_addr[i * 2 + 1];
tmp[2] = '\0';
- mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+ mac_addr[i] = hextoul(tmp, NULL);
}
if (is_valid_ethaddr(mac_addr))
diff --git a/board/amlogic/odroid-n2/odroid-n2.c b/board/amlogic/odroid-n2/odroid-n2.c
index 88a60f3..c37ea65 100644
--- a/board/amlogic/odroid-n2/odroid-n2.c
+++ b/board/amlogic/odroid-n2/odroid-n2.c
@@ -126,7 +126,7 @@
tmp[0] = efuse_mac_addr[i * 2];
tmp[1] = efuse_mac_addr[i * 2 + 1];
tmp[2] = '\0';
- mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+ mac_addr[i] = hextoul(tmp, NULL);
}
if (is_valid_ethaddr(mac_addr))
diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 18ef146..5d9ac64 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -166,7 +166,7 @@
tmp[0] = efuse_mac_addr[i * 2];
tmp[1] = efuse_mac_addr[i * 2 + 1];
tmp[2] = '\0';
- mac_addr[i] = simple_strtoul(tmp, NULL, 16);
+ mac_addr[i] = hextoul(tmp, NULL);
}
if (is_valid_ethaddr(mac_addr))
diff --git a/board/atmel/common/board.c b/board/atmel/common/board.c
index eee5c35..c93c0e5 100644
--- a/board/atmel/common/board.c
+++ b/board/atmel/common/board.c
@@ -47,7 +47,7 @@
break;
}
}
- pda = simple_strtoul((const char *)buf, NULL, 10);
+ pda = dectoul((const char *)buf, NULL);
switch (pda) {
case 7000:
diff --git a/board/bluewater/gurnard/gurnard.c b/board/bluewater/gurnard/gurnard.c
index e217b95..35c8985 100644
--- a/board/bluewater/gurnard/gurnard.c
+++ b/board/bluewater/gurnard/gurnard.c
@@ -376,7 +376,7 @@
/* Parse MAC address */
for (i = 0; i < 6; i++) {
env_enetaddr[i] = env_str ?
- simple_strtoul(env_str, &end, 16) : 0;
+ hextoul(env_str, &end) : 0;
if (env_str)
env_str = (*end) ? end+1 : end;
}
diff --git a/board/cavium/thunderx/atf.c b/board/cavium/thunderx/atf.c
index 64aa198..1a039c5 100644
--- a/board/cavium/thunderx/atf.c
+++ b/board/cavium/thunderx/atf.c
@@ -235,48 +235,48 @@
char str[4 * sizeof(uint64_t)];
if ((argc == 5) && !strcmp(argv[1], "readmmc")) {
- buffer = (void *)simple_strtoul(argv[2], NULL, 16);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ buffer = (void *)hextoul(argv[2], NULL);
+ offset = dectoul(argv[3], NULL);
+ size = dectoul(argv[4], NULL);
ret = atf_read_mmc(offset, buffer, size);
} else if ((argc == 5) && !strcmp(argv[1], "readnor")) {
- buffer = (void *)simple_strtoul(argv[2], NULL, 16);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ buffer = (void *)hextoul(argv[2], NULL);
+ offset = dectoul(argv[3], NULL);
+ size = dectoul(argv[4], NULL);
ret = atf_read_nor(offset, buffer, size);
} else if ((argc == 5) && !strcmp(argv[1], "writemmc")) {
- buffer = (void *)simple_strtoul(argv[2], NULL, 16);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ buffer = (void *)hextoul(argv[2], NULL);
+ offset = dectoul(argv[3], NULL);
+ size = dectoul(argv[4], NULL);
ret = atf_write_mmc(offset, buffer, size);
} else if ((argc == 5) && !strcmp(argv[1], "writenor")) {
- buffer = (void *)simple_strtoul(argv[2], NULL, 16);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ buffer = (void *)hextoul(argv[2], NULL);
+ offset = dectoul(argv[3], NULL);
+ size = dectoul(argv[4], NULL);
ret = atf_write_nor(offset, buffer, size);
} else if ((argc == 2) && !strcmp(argv[1], "part")) {
atf_print_part_table();
} else if ((argc == 4) && !strcmp(argv[1], "erasenor")) {
- offset = simple_strtoul(argv[2], NULL, 10);
- size = simple_strtoul(argv[3], NULL, 10);
+ offset = dectoul(argv[2], NULL);
+ size = dectoul(argv[3], NULL);
ret = atf_erase_nor(offset, size);
} else if ((argc == 2) && !strcmp(argv[1], "envcount")) {
ret = atf_env_count();
printf("Number of environment strings: %zd\n", ret);
} else if ((argc == 3) && !strcmp(argv[1], "envstring")) {
- index = simple_strtoul(argv[2], NULL, 10);
+ index = dectoul(argv[2], NULL);
ret = atf_env_string(index, str);
if (ret > 0)
printf("Environment string %d: %s\n", index, str);
else
printf("Return code: %zd\n", ret);
} else if ((argc == 3) && !strcmp(argv[1], "dramsize")) {
- node = simple_strtoul(argv[2], NULL, 10);
+ node = dectoul(argv[2], NULL);
ret = atf_dram_size(node);
printf("DRAM size: %zd Mbytes\n", ret >> 20);
} else if ((argc == 2) && !strcmp(argv[1], "nodes")) {
diff --git a/board/compulab/common/eeprom.c b/board/compulab/common/eeprom.c
index 5206cf5..b41c64d 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -153,7 +153,7 @@
*/
if (cl_eeprom_layout == LAYOUT_LEGACY) {
sprintf(str, "%x", board_rev);
- board_rev = simple_strtoul(str, NULL, 10);
+ board_rev = dectoul(str, NULL);
}
return board_rev;
diff --git a/board/compulab/common/omap3_display.c b/board/compulab/common/omap3_display.c
index cb9ebae..4ed3b9c 100644
--- a/board/compulab/common/omap3_display.c
+++ b/board/compulab/common/omap3_display.c
@@ -244,7 +244,7 @@
int divisor, pixclock_val;
char *pixclk_start = pixclock;
- pixclock_val = simple_strtoul(pixclock, &pixclock, 10);
+ pixclock_val = dectoul(pixclock, &pixclock);
divisor = DIV_ROUND_UP(PIXEL_CLK_NUMERATOR, pixclock_val);
/* 0 and 1 are illegal values for PCD */
if (divisor <= 1)
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
index 383a861..6c75231 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -284,7 +284,7 @@
s = env_get("maxcpuclk");
if (s)
- maxcpuclk = simple_strtoul(s, NULL, 10);
+ maxcpuclk = dectoul(s, NULL);
if (maxcpuclk >= 456000000)
rev = 3;
diff --git a/board/esd/meesc/meesc.c b/board/esd/meesc/meesc.c
index eaa525e..a3eee63 100644
--- a/board/esd/meesc/meesc.c
+++ b/board/esd/meesc/meesc.c
@@ -208,7 +208,7 @@
str = strchr(serial, '_');
if (str && (strlen(str) >= 4)) {
serialnr->high = (*(str + 1) << 8) | *(str + 2);
- serialnr->low = simple_strtoul(str + 3, NULL, 16);
+ serialnr->low = hextoul(str + 3, NULL);
}
} else {
serialnr->high = 0;
diff --git a/board/freescale/common/cmd_esbc_validate.c b/board/freescale/common/cmd_esbc_validate.c
index 638aa3c..6c09626 100644
--- a/board/freescale/common/cmd_esbc_validate.c
+++ b/board/freescale/common/cmd_esbc_validate.c
@@ -40,7 +40,7 @@
hash_str = argv[2];
/* First argument - header address -32/64bit */
- haddr = (uintptr_t)simple_strtoul(argv[1], NULL, 16);
+ haddr = (uintptr_t)hextoul(argv[1], NULL);
/* With esbc_validate command, Image address must be
* part of header. So, the function is called
diff --git a/board/freescale/common/fsl_validate.c b/board/freescale/common/fsl_validate.c
index 564a8b3..066aa9a 100644
--- a/board/freescale/common/fsl_validate.c
+++ b/board/freescale/common/fsl_validate.c
@@ -767,7 +767,7 @@
if (!p) {
return 0;
} else {
- tmp = simple_strtoul(p, &endptr, 16);
+ tmp = hextoul(p, &endptr);
if (sizeof(ulong) == 4)
*num = cpu_to_be32(tmp);
else
diff --git a/board/freescale/common/pixis.c b/board/freescale/common/pixis.c
index 4127fbc..6fdb110 100644
--- a/board/freescale/common/pixis.c
+++ b/board/freescale/common/pixis.c
@@ -403,10 +403,10 @@
mulconst = 1;
for (i = 0; i < j; i++)
mulconst *= 10;
- decval = simple_strtoul(decarr, NULL, 10);
+ decval = dectoul(decarr, NULL);
}
- intval = simple_strtoul(intarr, NULL, 10);
+ intval = dectoul(intarr, NULL);
intval = intval * mulconst;
return intval + decval;
@@ -489,9 +489,9 @@
unsigned long corepll;
unsigned long mpxpll;
- sysclk = simple_strtoul(p_cf_sysclk, NULL, 10);
+ sysclk = dectoul(p_cf_sysclk, NULL);
corepll = strfractoint(p_cf_corepll);
- mpxpll = simple_strtoul(p_cf_mpxpll, NULL, 10);
+ mpxpll = dectoul(p_cf_mpxpll, NULL);
if (!(set_px_sysclk(sysclk)
&& set_px_corepll(corepll)
diff --git a/board/freescale/common/sys_eeprom.c b/board/freescale/common/sys_eeprom.c
index be0fda0..35df8ba 100644
--- a/board/freescale/common/sys_eeprom.c
+++ b/board/freescale/common/sys_eeprom.c
@@ -378,7 +378,7 @@
}
for (i = 0; *p && (i < 6); i++) {
- e.mac[index][i] = simple_strtoul(p, &p, 16);
+ e.mac[index][i] = hextoul(p, &p);
if (*p == ':')
p++;
}
@@ -452,11 +452,11 @@
set_date(argv[2]);
break;
case 'p': /* MAC table size */
- e.mac_count = simple_strtoul(argv[2], NULL, 16);
+ e.mac_count = hextoul(argv[2], NULL);
update_crc();
break;
case '0' ... '9': /* "mac 0" through "mac 22" */
- set_mac_address(simple_strtoul(argv[1], NULL, 10), argv[2]);
+ set_mac_address(dectoul(argv[1], NULL), argv[2]);
break;
case 'h': /* help */
default:
diff --git a/board/freescale/lx2160a/eth_lx2160aqds.c b/board/freescale/lx2160a/eth_lx2160aqds.c
index 437f0bc..a2b6442 100644
--- a/board/freescale/lx2160a/eth_lx2160aqds.c
+++ b/board/freescale/lx2160a/eth_lx2160aqds.c
@@ -416,7 +416,7 @@
env_dpmac, phy_num + 1, arg_dpmacid);
else
wriop_set_phy_address(dpmac, phy_num,
- simple_strtoul(ret, NULL, 16));
+ hextoul(ret, NULL));
}
/*search mdio in dpmac arg*/
diff --git a/board/freescale/lx2160a/eth_lx2162aqds.c b/board/freescale/lx2160a/eth_lx2162aqds.c
index b742c1f..3b04dea 100644
--- a/board/freescale/lx2160a/eth_lx2162aqds.c
+++ b/board/freescale/lx2160a/eth_lx2162aqds.c
@@ -437,7 +437,7 @@
env_dpmac, phy_num + 1, arg_dpmacid);
else
wriop_set_phy_address(dpmac, phy_num,
- simple_strtoul(ret, NULL, 16));
+ hextoul(ret, NULL));
}
/*search mdio in dpmac arg*/
diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index 8273384..cf4d9c1 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -281,7 +281,7 @@
/* If a VSC7385 microcode image is present, then upload it. */
tmp = env_get("vscfw_addr");
if (tmp) {
- vscfw_addr = simple_strtoul(tmp, NULL, 16);
+ vscfw_addr = hextoul(tmp, NULL);
printf("uploading VSC7385 microcode from %x\n", vscfw_addr);
if (vsc7385_upload_firmware((void *)vscfw_addr,
CONFIG_VSC7385_IMAGE_SIZE))
diff --git a/board/freescale/p2041rdb/cpld.c b/board/freescale/p2041rdb/cpld.c
index b042fe3..a1908b8 100644
--- a/board/freescale/p2041rdb/cpld.c
+++ b/board/freescale/p2041rdb/cpld.c
@@ -100,8 +100,8 @@
else
cpld_set_defbank();
} else if (strcmp(argv[1], "lane_mux") == 0) {
- u32 lane = simple_strtoul(argv[2], NULL, 16);
- u8 val = (u8)simple_strtoul(argv[3], NULL, 16);
+ u32 lane = hextoul(argv[2], NULL);
+ u8 val = (u8)hextoul(argv[3], NULL);
u8 reg = CPLD_READ(serdes_mux);
switch (lane) {
diff --git a/board/gateworks/gw_ventana/common.c b/board/gateworks/gw_ventana/common.c
index c07eb62..4a15837 100644
--- a/board/gateworks/gw_ventana/common.c
+++ b/board/gateworks/gw_ventana/common.c
@@ -1502,7 +1502,7 @@
continue;
s = hwconfig_subarg(arg, "padctrl", &len);
if (s) {
- ctrl = MUX_PAD_CTRL(simple_strtoul(s, NULL, 16)
+ ctrl = MUX_PAD_CTRL(hextoul(s, NULL)
& 0x1ffff) | MUX_MODE_SION;
}
if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
diff --git a/board/gateworks/gw_ventana/gsc.c b/board/gateworks/gw_ventana/gsc.c
index ffed6b5..59fd1b6 100644
--- a/board/gateworks/gw_ventana/gsc.c
+++ b/board/gateworks/gw_ventana/gsc.c
@@ -277,7 +277,7 @@
if (argc < 2)
return CMD_RET_USAGE;
- secs = simple_strtoul(argv[1], NULL, 10);
+ secs = dectoul(argv[1], NULL);
printf("GSC Sleeping for %ld seconds\n", secs);
i2c_set_bus_num(0);
@@ -322,7 +322,7 @@
int timeout = 0;
if (argc > 2)
- timeout = simple_strtoul(argv[2], NULL, 10);
+ timeout = dectoul(argv[2], NULL);
i2c_set_bus_num(0);
if (gsc_i2c_read(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
return CMD_RET_FAILURE;
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c
index 468fb09..912075d 100644
--- a/board/gateworks/gw_ventana/gw_ventana.c
+++ b/board/gateworks/gw_ventana/gw_ventana.c
@@ -471,7 +471,7 @@
if (serial) {
serialnr->high = 0;
- serialnr->low = simple_strtoul(serial, NULL, 10);
+ serialnr->low = dectoul(serial, NULL);
} else if (ventana_info.model[0]) {
serialnr->high = 0;
serialnr->low = ventana_info.serial;
@@ -915,7 +915,7 @@
if (tmp) {
for (j = 0; j < 6; j++) {
mac_addr[j] = tmp ?
- simple_strtoul(tmp, &end,16) : 0;
+ hextoul(tmp, &end) : 0;
if (tmp)
tmp = (*end) ? end+1 : end;
}
diff --git a/board/gateworks/venice/gsc.c b/board/gateworks/venice/gsc.c
index c75bc6f..271bc8c 100644
--- a/board/gateworks/venice/gsc.c
+++ b/board/gateworks/venice/gsc.c
@@ -660,7 +660,7 @@
if (strcasecmp(argv[1], "sleep") == 0) {
if (argc < 3)
return CMD_RET_USAGE;
- if (!gsc_sleep(simple_strtoul(argv[2], NULL, 10)))
+ if (!gsc_sleep(dectoul(argv[2], NULL)))
return CMD_RET_SUCCESS;
} else if (strcasecmp(argv[1], "hwmon") == 0) {
if (!gsc_hwmon())
diff --git a/board/gdsys/common/cmd_ioloop.c b/board/gdsys/common/cmd_ioloop.c
index 658756d..1412421 100644
--- a/board/gdsys/common/cmd_ioloop.c
+++ b/board/gdsys/common/cmd_ioloop.c
@@ -275,13 +275,13 @@
if (argc < 2)
return CMD_RET_USAGE;
- fpga = simple_strtoul(argv[1], NULL, 10);
+ fpga = dectoul(argv[1], NULL);
/*
* If another parameter, it is the report rate in packets.
*/
if (argc > 2)
- rate = simple_strtoul(argv[2], NULL, 10);
+ rate = dectoul(argv[2], NULL);
/* Enable receive path */
FPGA_SET_REG(fpga, ep.rx_tx_control, CTRL_PROC_RECEIVE_ENABLE);
@@ -388,18 +388,18 @@
/*
* FPGA is specified since argc > 2
*/
- fpga = simple_strtoul(argv[1], NULL, 10);
+ fpga = dectoul(argv[1], NULL);
/*
* packet size is specified since argc > 2
*/
- size = simple_strtoul(argv[2], NULL, 10);
+ size = dectoul(argv[2], NULL);
/*
* If another parameter, it is the test rate in packets per second.
*/
if (argc > 3)
- rate = simple_strtoul(argv[3], NULL, 10);
+ rate = dectoul(argv[3], NULL);
/* enable receive path */
FPGA_SET_REG(fpga, ep.rx_tx_control, CTRL_PROC_RECEIVE_ENABLE);
@@ -463,13 +463,13 @@
/*
* packet size is specified since argc > 1
*/
- size = simple_strtoul(argv[2], NULL, 10);
+ size = dectoul(argv[2], NULL);
/*
* If another parameter, it is the test rate in packets per second.
*/
if (argc > 2)
- rate = simple_strtoul(argv[3], NULL, 10);
+ rate = dectoul(argv[3], NULL);
/* Enable receive path */
misc_set_enabled(dev, true);
@@ -514,7 +514,7 @@
return CMD_RET_FAILURE;
if (argc > 1) {
- int i = simple_strtoul(argv[1], NULL, 10);
+ int i = dectoul(argv[1], NULL);
snprintf(name, sizeof(name), "ioep%d", i);
diff --git a/board/gdsys/common/osd.c b/board/gdsys/common/osd.c
index 679f8f3..dc548ef 100644
--- a/board/gdsys/common/osd.c
+++ b/board/gdsys/common/osd.c
@@ -284,9 +284,9 @@
if (!(osd_screen_mask & (1 << screen)))
continue;
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
- color = simple_strtoul(argv[3], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
+ color = hextoul(argv[3], NULL);
text = argv[4];
charcount = strlen(text);
len = (charcount > bufsize) ? bufsize : charcount;
@@ -416,13 +416,13 @@
char *rp;
u16 *wp = buffer;
unsigned count = (argc > 4) ?
- simple_strtoul(argv[4], NULL, 16) : 1;
+ hextoul(argv[4], NULL) : 1;
if (!(osd_screen_mask & (1 << screen)))
continue;
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
rp = argv[3];
@@ -431,7 +431,7 @@
memcpy(substr, rp, 4);
substr[4] = 0;
- *wp = simple_strtoul(substr, NULL, 16);
+ *wp = hextoul(substr, NULL);
rp += 4;
wp++;
@@ -463,8 +463,8 @@
return 1;
}
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
if (!x || (x > 64) || (x > MAX_X_CHARS) ||
!y || (y > 32) || (y > MAX_Y_CHARS)) {
diff --git a/board/gdsys/common/osd_cmd.c b/board/gdsys/common/osd_cmd.c
index fe62497..6a9c0b4 100644
--- a/board/gdsys/common/osd_cmd.c
+++ b/board/gdsys/common/osd_cmd.c
@@ -30,10 +30,10 @@
if (argc < 4 || (strlen(argv[3])) % 2)
return CMD_RET_USAGE;
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
hexstr = argv[3];
- count = (argc > 4) ? simple_strtoul(argv[4], NULL, 16) : 1;
+ count = (argc > 4) ? hextoul(argv[4], NULL) : 1;
buflen = strlen(hexstr) / 2;
@@ -80,9 +80,9 @@
if (argc < 5)
return CMD_RET_USAGE;
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
- color = simple_strtoul(argv[3], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
+ color = hextoul(argv[3], NULL);
text = argv[4];
for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
@@ -109,8 +109,8 @@
if (argc < 3)
return CMD_RET_USAGE;
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
for (uclass_first_device(UCLASS_VIDEO_OSD, &dev);
dev;
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 016806a..ff07260 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -278,7 +278,7 @@
* use simple_strtoul because we need &end and
* we know we got non numeric char at the end
*/
- bid = simple_strtoul(rest, &endp, 16);
+ bid = hextoul(rest, &endp);
/* BoardId and HWkey are separated with a "_" */
if (*endp == '_') {
rest = endp + 1;
@@ -286,7 +286,7 @@
* use simple_strtoul because we need
* &end
*/
- hwkey = simple_strtoul(rest, &endp, 16);
+ hwkey = hextoul(rest, &endp);
rest = endp;
while (*rest && !isxdigit(*rest))
rest++;
diff --git a/board/kontron/sl28/cmds.c b/board/kontron/sl28/cmds.c
index 046d3b4..08a22b5 100644
--- a/board/kontron/sl28/cmds.c
+++ b/board/kontron/sl28/cmds.c
@@ -138,7 +138,7 @@
return CMD_RET_FAILURE;
if (argc > 1) {
- nvm = simple_strtoul(argv[1], &endp, 16);
+ nvm = hextoul(argv[1], &endp);
if (*endp != '\0') {
printf("ERROR: argument is not a valid number\n");
ret = -EINVAL;
diff --git a/board/menlo/m53menlo/m53menlo.c b/board/menlo/m53menlo/m53menlo.c
index c34baca..2b331b3 100644
--- a/board/menlo/m53menlo/m53menlo.c
+++ b/board/menlo/m53menlo/m53menlo.c
@@ -347,7 +347,7 @@
if (!s)
return 0;
- addr = simple_strtoul(s, NULL, 16);
+ addr = hextoul(s, NULL);
dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
if (!dst)
return -ENOMEM;
diff --git a/board/renesas/stout/cpld.c b/board/renesas/stout/cpld.c
index ac8048c..b7c75f5 100644
--- a/board/renesas/stout/cpld.c
+++ b/board/renesas/stout/cpld.c
@@ -133,7 +133,7 @@
if (argc < 3)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
if (!(addr == CPLD_ADDR_VERSION || addr == CPLD_ADDR_MODE ||
addr == CPLD_ADDR_MUX || addr == CPLD_ADDR_HDMI ||
addr == CPLD_ADDR_DIPSW || addr == CPLD_ADDR_RESET)) {
@@ -144,7 +144,7 @@
if (argc == 3 && strcmp(argv[1], "read") == 0) {
printf("0x%x\n", cpld_read(addr));
} else if (argc == 4 && strcmp(argv[1], "write") == 0) {
- val = simple_strtoul(argv[3], NULL, 16);
+ val = hextoul(argv[3], NULL);
if (addr == CPLD_ADDR_MUX) {
/* never mask SCIFA0 console */
val &= ~MUX_MSK_SCIFA0_USB;
diff --git a/board/renesas/ulcb/cpld.c b/board/renesas/ulcb/cpld.c
index ebb2d6f..0c060a5 100644
--- a/board/renesas/ulcb/cpld.c
+++ b/board/renesas/ulcb/cpld.c
@@ -111,7 +111,7 @@
if (argc < 3)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
if (!(addr == CPLD_ADDR_VERSION || addr == CPLD_ADDR_MODE ||
addr == CPLD_ADDR_MUX || addr == CPLD_ADDR_DIPSW6 ||
addr == CPLD_ADDR_RESET)) {
@@ -122,7 +122,7 @@
if (argc == 3 && strcmp(argv[1], "read") == 0) {
printf("0x%x\n", cpld_read(dev, addr));
} else if (argc == 4 && strcmp(argv[1], "write") == 0) {
- val = simple_strtoul(argv[3], NULL, 16);
+ val = hextoul(argv[3], NULL);
cpld_write(dev, addr, val);
}
diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
index 1318ea7..0d77a57f 100644
--- a/board/samsung/common/exynos5-dt.c
+++ b/board/samsung/common/exynos5-dt.c
@@ -169,7 +169,7 @@
if (board_is_odroidxu4() || board_is_odroidhc1() || board_is_odroidhc2())
return info;
- dev_num = simple_strtoul(devstr, NULL, 10);
+ dev_num = dectoul(devstr, NULL);
mmc = find_mmc_device(dev_num);
if (!mmc)
diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index 90aab62..35e4cee 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -85,7 +85,7 @@
char *alt_boot;
int dev_num;
- dev_num = simple_strtoul(devstr, NULL, 10);
+ dev_num = dectoul(devstr, NULL);
mmc = find_mmc_device(dev_num);
if (!mmc)
diff --git a/board/siemens/common/factoryset.c b/board/siemens/common/factoryset.c
index 2e3ae1a..fba678b 100644
--- a/board/siemens/common/factoryset.c
+++ b/board/siemens/common/factoryset.c
@@ -243,7 +243,7 @@
buf, MAX_STRING_LENGTH);
cp1 = buf;
for (i = 0; i < 6; i++) {
- factory_dat.mac[i] = simple_strtoul((char *)cp1, NULL, 16);
+ factory_dat.mac[i] = hextoul((char *)cp1, NULL);
cp1 += 3;
}
@@ -254,8 +254,7 @@
if (ret > 0) {
cp1 = buf;
for (i = 0; i < 6; i++) {
- factory_dat.mac_wlan[i] = simple_strtoul((char *)cp1,
- NULL, 16);
+ factory_dat.mac_wlan[i] = hextoul((char *)cp1, NULL);
cp1 += 3;
}
}
@@ -266,15 +265,13 @@
if (0 <= get_factory_record_val(cp, size, (uchar *)"USBD1",
(uchar *)"vid", buf,
MAX_STRING_LENGTH)) {
- factory_dat.usb_vendor_id = simple_strtoul((char *)buf,
- NULL, 16);
+ factory_dat.usb_vendor_id = hextoul((char *)buf, NULL);
}
if (0 <= get_factory_record_val(cp, size, (uchar *)"USBD1",
(uchar *)"pid", buf,
MAX_STRING_LENGTH)) {
- factory_dat.usb_product_id = simple_strtoul((char *)buf,
- NULL, 16);
+ factory_dat.usb_product_id = hextoul((char *)buf, NULL);
}
printf("DFU USB: VID = 0x%4x, PID = 0x%4x\n", factory_dat.usb_vendor_id,
factory_dat.usb_product_id);
@@ -294,8 +291,7 @@
if (0 <= get_factory_record_val(cp, size, (uchar *)"DEV",
(uchar *)"ver", buf,
MAX_STRING_LENGTH)) {
- factory_dat.version = simple_strtoul((char *)buf,
- NULL, 16);
+ factory_dat.version = hextoul((char *)buf, NULL);
debug("version number: %d\n", factory_dat.version);
}
/* Get ASN from factory set if available */
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
index cad16f9..dae064d 100644
--- a/board/siemens/taurus/taurus.c
+++ b/board/siemens/taurus/taurus.c
@@ -394,10 +394,9 @@
unsigned long boot_retry = 0;
char boot_buf[10];
- upgrade_available = simple_strtoul(env_get("upgrade_available"), NULL,
- 10);
+ upgrade_available = dectoul(env_get("upgrade_available"), NULL);
if (upgrade_available) {
- boot_retry = simple_strtoul(env_get("boot_retries"), NULL, 10);
+ boot_retry = dectoul(env_get("boot_retries"), NULL);
boot_retry++;
sprintf(boot_buf, "%lx", boot_retry);
env_set("boot_retries", boot_buf);
diff --git a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
index ad2f315..2b985b9 100644
--- a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
+++ b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
@@ -281,7 +281,7 @@
}
for (i = 0; *string && (i < MAC_ADDR_BYTES); i++) {
- e.mac_addr[i] = simple_strtoul(string, &string, 16);
+ e.mac_addr[i] = hextoul(string, &string);
if (*string == ':')
string++;
}
@@ -324,7 +324,7 @@
{
unsigned long p;
- p = simple_strtoul(string, &string, 10);
+ p = dectoul(string, &string);
if (p > U8_MAX) {
printf("%s must not be greater than %d\n", "PCB revision",
U8_MAX);
@@ -366,7 +366,7 @@
{
unsigned long p;
- p = simple_strtoul(string, &string, 10);
+ p = dectoul(string, &string);
if (p > U8_MAX) {
printf("%s must not be greater than %d\n", "BOM variant",
U8_MAX);
@@ -389,7 +389,7 @@
{
unsigned long p;
- p = simple_strtoul(string, &string, 10);
+ p = dectoul(string, &string);
if (p > U16_MAX) {
printf("%s must not be greater than %d\n", "Product ID",
U16_MAX);
diff --git a/board/synopsys/hsdk/env-lib.c b/board/synopsys/hsdk/env-lib.c
index 235f295..fd54ac7 100644
--- a/board/synopsys/hsdk/env-lib.c
+++ b/board/synopsys/hsdk/env-lib.c
@@ -252,9 +252,9 @@
char *endp = argv[1];
if (map[i].type == ENV_HEX)
- map[i].val->val = simple_strtoul(argv[1], &endp, 16);
+ map[i].val->val = hextoul(argv[1], &endp);
else
- map[i].val->val = simple_strtoul(argv[1], &endp, 10);
+ map[i].val->val = dectoul(argv[1], &endp);
map[i].val->set = true;
diff --git a/board/ti/am64x/evm.c b/board/ti/am64x/evm.c
index cdbb9a8..21c58c7 100644
--- a/board/ti/am64x/evm.c
+++ b/board/ti/am64x/evm.c
@@ -120,7 +120,7 @@
if (env_get("serial#"))
return;
- board_serial = simple_strtoul(ep->serial, &endp, 16);
+ board_serial = hextoul(ep->serial, &endp);
if (*endp != '\0') {
pr_err("Error: Can't set serial# to %s\n", ep->serial);
return;
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index 580f13c..077d834 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -201,7 +201,7 @@
if (env_get("serial#"))
return;
- board_serial = simple_strtoul(ep->serial, &endp, 16);
+ board_serial = hextoul(ep->serial, &endp);
if (*endp != '\0') {
pr_err("Error: Can't set serial# to %s\n", ep->serial);
return;
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 93eb20c..e4f9a0d 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -548,7 +548,7 @@
len = cli_readline(message);
}
- tdx_serial = simple_strtoul(console_buffer, NULL, 10);
+ tdx_serial = dectoul(console_buffer, NULL);
return 0;
}
@@ -566,14 +566,14 @@
/* Get hardware information from the first 8 digits */
tag->ver_major = barcode[4] - '0';
tag->ver_minor = barcode[5] - '0';
- tag->ver_assembly = simple_strtoul(revision, NULL, 10);
+ tag->ver_assembly = dectoul(revision, NULL);
barcode[4] = '\0';
- tag->prodid = simple_strtoul(barcode, NULL, 10);
+ tag->prodid = dectoul(barcode, NULL);
/* Parse second part of the barcode (serial number */
barcode += 8;
- *serial = simple_strtoul(barcode, NULL, 10);
+ *serial = dectoul(barcode, NULL);
return 0;
}
@@ -710,7 +710,7 @@
tdx_car_hw_tag.ver_assembly = pid8[7] - '0';
pid8[4] = '\0';
- tdx_car_hw_tag.prodid = simple_strtoul(pid8, NULL, 10);
+ tdx_car_hw_tag.prodid = dectoul(pid8, NULL);
/* Valid Tag */
write_tag(config_block, &offset, TAG_VALID, NULL, 0);
@@ -754,7 +754,7 @@
sprintf(message, "Choose your carrier board (provide ID): ");
len = cli_readline(message);
- tdx_car_hw_tag.prodid = simple_strtoul(console_buffer, NULL, 10);
+ tdx_car_hw_tag.prodid = dectoul(console_buffer, NULL);
do {
sprintf(message, "Enter carrier board version (e.g. V1.1B): V");
@@ -770,7 +770,7 @@
len = cli_readline(message);
}
- tdx_car_serial = simple_strtoul(console_buffer, NULL, 10);
+ tdx_car_serial = dectoul(console_buffer, NULL);
return 0;
}
diff --git a/board/varisys/common/sys_eeprom.c b/board/varisys/common/sys_eeprom.c
index 251d9fd..8f624e5 100644
--- a/board/varisys/common/sys_eeprom.c
+++ b/board/varisys/common/sys_eeprom.c
@@ -299,7 +299,7 @@
}
for (i = 0; *p && (i < 6); i++) {
- e.mac[index][i] = simple_strtoul(p, &p, 16);
+ e.mac[index][i] = hextoul(p, &p);
if (*p == ':')
p++;
}
@@ -364,11 +364,11 @@
set_date(argv[2]);
break;
case 'p': /* MAC table size */
- e.mac_count = simple_strtoul(argv[2], NULL, 16);
+ e.mac_count = hextoul(argv[2], NULL);
update_crc();
break;
case '0' ... '9': /* "mac 0" through "mac 22" */
- set_mac_address(simple_strtoul(argv[1], NULL, 10), argv[2]);
+ set_mac_address(dectoul(argv[1], NULL), argv[2]);
break;
case 'h': /* help */
default:
diff --git a/board/work-microwave/work_92105/work_92105_display.c b/board/work-microwave/work_92105/work_92105_display.c
index fecbbbd..e8e559c 100644
--- a/board/work-microwave/work_92105/work_92105_display.c
+++ b/board/work-microwave/work_92105/work_92105_display.c
@@ -233,8 +233,7 @@
/* set display contrast */
display_contrast_str = env_get("fwopt_dispcontrast");
if (display_contrast_str)
- display_contrast = simple_strtoul(display_contrast_str,
- NULL, 10);
+ display_contrast = dectoul(display_contrast_str, NULL);
i2c_write(0x2c, 0x00, 1, &display_contrast, 1);
/* request GPO_15 as an output initially set to 1 */
diff --git a/board/xilinx/common/fru.c b/board/xilinx/common/fru.c
index ccf4872..f6ca46c 100644
--- a/board/xilinx/common/fru.c
+++ b/board/xilinx/common/fru.c
@@ -19,7 +19,7 @@
if (argc < cmdtp->maxargs)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], &endp, 16);
+ addr = hextoul(argv[2], &endp);
if (*argv[1] == 0 || *endp != 0)
return -1;
@@ -41,7 +41,7 @@
if (argc < cmdtp->maxargs)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
return fru_generate(addr, argv[3], argv[4], argv[5], argv[6], argv[7]);
}
diff --git a/board/xilinx/versal/cmds.c b/board/xilinx/versal/cmds.c
index f5735d0..04d4cdb 100644
--- a/board/xilinx/versal/cmds.c
+++ b/board/xilinx/versal/cmds.c
@@ -32,7 +32,7 @@
return CMD_RET_USAGE;
}
- len = simple_strtoul(argv[3], NULL, 16);
+ len = hextoul(argv[3], NULL);
if (!len) {
debug("pdi_load: zero size\n");
return CMD_RET_USAGE;
diff --git a/board/xilinx/zynq/cmds.c b/board/xilinx/zynq/cmds.c
index 6c697ca..024fac6 100644
--- a/board/xilinx/zynq/cmds.c
+++ b/board/xilinx/zynq/cmds.c
@@ -422,7 +422,7 @@
if (argc != cmdtp->maxargs)
return CMD_RET_FAILURE;
- src_ptr = simple_strtoul(argv[2], &endp, 16);
+ src_ptr = hextoul(argv[2], &endp);
if (*argv[2] == 0 || *endp != 0)
return CMD_RET_USAGE;
@@ -453,26 +453,26 @@
else
return CMD_RET_USAGE;
- srcaddr = simple_strtoul(argv[3], &endp, 16);
+ srcaddr = hextoul(argv[3], &endp);
if (*argv[3] == 0 || *endp != 0)
return CMD_RET_USAGE;
- srclen = simple_strtoul(argv[4], &endp, 16);
+ srclen = hextoul(argv[4], &endp);
if (*argv[4] == 0 || *endp != 0)
return CMD_RET_USAGE;
dstaddr = 0xFFFFFFFF;
dstlen = srclen;
} else {
- srcaddr = simple_strtoul(argv[2], &endp, 16);
+ srcaddr = hextoul(argv[2], &endp);
if (*argv[2] == 0 || *endp != 0)
return CMD_RET_USAGE;
- srclen = simple_strtoul(argv[3], &endp, 16);
+ srclen = hextoul(argv[3], &endp);
if (*argv[3] == 0 || *endp != 0)
return CMD_RET_USAGE;
- dstaddr = simple_strtoul(argv[4], &endp, 16);
+ dstaddr = hextoul(argv[4], &endp);
if (*argv[4] == 0 || *endp != 0)
return CMD_RET_USAGE;
- dstlen = simple_strtoul(argv[5], &endp, 16);
+ dstlen = hextoul(argv[5], &endp);
if (*argv[5] == 0 || *endp != 0)
return CMD_RET_USAGE;
}
diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index cf63ad9..b15c0f5 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -40,7 +40,7 @@
return CMD_RET_USAGE;
src_addr = simple_strtoull(argv[2], NULL, 16);
- len = simple_strtoul(argv[3], NULL, 16);
+ len = hextoul(argv[3], NULL);
if (argc == 5)
key_ptr = (uint8_t *)(uintptr_t)simple_strtoull(argv[4],
@@ -86,7 +86,7 @@
if (argc != cmdtp->maxargs)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
ret = zynqmp_mmio_read(addr, &read_val);
if (!ret)
@@ -107,9 +107,9 @@
if (argc != cmdtp->maxargs)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], NULL, 16);
- mask = simple_strtoul(argv[3], NULL, 16);
- val = simple_strtoul(argv[4], NULL, 16);
+ addr = hextoul(argv[2], NULL);
+ mask = hextoul(argv[3], NULL);
+ val = hextoul(argv[4], NULL);
ret = zynqmp_mmio_write(addr, mask, val);
if (ret != 0)
@@ -135,12 +135,12 @@
if (argc < cmdtp->maxargs - 1)
return CMD_RET_USAGE;
- aes->srcaddr = simple_strtoul(argv[2], NULL, 16);
- aes->ivaddr = simple_strtoul(argv[3], NULL, 16);
- aes->len = simple_strtoul(argv[4], NULL, 16);
- aes->op = simple_strtoul(argv[5], NULL, 16);
- aes->keysrc = simple_strtoul(argv[6], NULL, 16);
- aes->dstaddr = simple_strtoul(argv[7], NULL, 16);
+ aes->srcaddr = hextoul(argv[2], NULL);
+ aes->ivaddr = hextoul(argv[3], NULL);
+ aes->len = hextoul(argv[4], NULL);
+ aes->op = hextoul(argv[5], NULL);
+ aes->keysrc = hextoul(argv[6], NULL);
+ aes->dstaddr = hextoul(argv[7], NULL);
flush_dcache_range((ulong)aes, (ulong)(aes) +
roundup(sizeof(struct aes), ARCH_DMA_MINALIGN));
@@ -161,7 +161,7 @@
if (argc < cmdtp->maxargs)
return CMD_RET_USAGE;
- aes->keyaddr = simple_strtoul(argv[8], NULL, 16);
+ aes->keyaddr = hextoul(argv[8], NULL);
if (aes->keyaddr)
flush_dcache_range(aes->keyaddr,
(aes->keyaddr +
@@ -187,7 +187,7 @@
if (argc != cmdtp->maxargs)
return CMD_RET_USAGE;
- mode = simple_strtoul(argv[2], NULL, 16);
+ mode = hextoul(argv[2], NULL);
if (mode != TCM_LOCK && mode != TCM_SPLIT) {
printf("Mode should be either 0(lock)/1(split)\n");
return CMD_RET_FAILURE;
@@ -209,8 +209,8 @@
if (argc != cmdtp->maxargs)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[2], NULL, 16);
- size = simple_strtoul(argv[3], NULL, 16);
+ addr = hextoul(argv[2], NULL);
+ size = hextoul(argv[3], NULL);
flush_dcache_range((ulong)addr, (ulong)(addr + size));
zynqmp_pmufw_load_config_object((const void *)(uintptr_t)addr,
@@ -236,16 +236,16 @@
return CMD_RET_FAILURE;
}
- srcaddr = simple_strtoul(argv[2], NULL, 16);
- srclen = simple_strtoul(argv[3], NULL, 16);
+ srcaddr = hextoul(argv[2], NULL);
+ srclen = hextoul(argv[3], NULL);
if (srclen != RSA_KEY_SIZE) {
puts("ERR: srclen should be equal to 0x200(512 bytes)\n");
return CMD_RET_USAGE;
}
- mod = simple_strtoul(argv[4], NULL, 16);
- exp = simple_strtoul(argv[5], NULL, 16);
- rsaop = simple_strtoul(argv[6], NULL, 16);
+ mod = hextoul(argv[4], NULL);
+ exp = hextoul(argv[5], NULL);
+ rsaop = hextoul(argv[6], NULL);
if (!(rsaop == 0 || rsaop == 1)) {
puts("ERR: rsaop should be either 0 or 1\n");
return CMD_RET_USAGE;
@@ -299,11 +299,11 @@
return CMD_RET_FAILURE;
}
- srcaddr = simple_strtoul(argv[2], NULL, 16);
- srclen = simple_strtoul(argv[3], NULL, 16);
+ srcaddr = hextoul(argv[2], NULL);
+ srclen = hextoul(argv[3], NULL);
if (argc == 5) {
- hashaddr = simple_strtoul(argv[4], NULL, 16);
+ hashaddr = hextoul(argv[4], NULL);
flush_dcache_range(hashaddr,
hashaddr + roundup(ZYNQMP_SHA3_SIZE,
ARCH_DMA_MINALIGN));
diff --git a/cmd/abootimg.c b/cmd/abootimg.c
index 40e8978..f48a9dc 100644
--- a/cmd/abootimg.c
+++ b/cmd/abootimg.c
@@ -161,7 +161,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- img_addr = simple_strtoul(argv[1], &endp, 16);
+ img_addr = hextoul(argv[1], &endp);
if (*endp != '\0') {
printf("Error: Wrong image address\n");
return CMD_RET_FAILURE;
diff --git a/cmd/adtimg.c b/cmd/adtimg.c
index aa94300..f4b5cbf 100644
--- a/cmd/adtimg.c
+++ b/cmd/adtimg.c
@@ -27,7 +27,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- hdr_addr = simple_strtoul(argv[1], &endp, 16);
+ hdr_addr = hextoul(argv[1], &endp);
if (*endp != '\0') {
printf("Error: Wrong image address '%s'\n", argv[1]);
return CMD_RET_FAILURE;
diff --git a/cmd/aes.c b/cmd/aes.c
index 4c0dad9..1936518 100644
--- a/cmd/aes.c
+++ b/cmd/aes.c
@@ -55,11 +55,11 @@
else
return CMD_RET_USAGE;
- key_addr = simple_strtoul(argv[2], NULL, 16);
- iv_addr = simple_strtoul(argv[3], NULL, 16);
- src_addr = simple_strtoul(argv[4], NULL, 16);
- dst_addr = simple_strtoul(argv[5], NULL, 16);
- len = simple_strtoul(argv[6], NULL, 16);
+ key_addr = hextoul(argv[2], NULL);
+ iv_addr = hextoul(argv[3], NULL);
+ src_addr = hextoul(argv[4], NULL);
+ dst_addr = hextoul(argv[5], NULL);
+ len = hextoul(argv[6], NULL);
key_ptr = (uint8_t *)map_sysmem(key_addr, key_len);
iv_ptr = (uint8_t *)map_sysmem(iv_addr, 128 / 8);
diff --git a/cmd/armflash.c b/cmd/armflash.c
index 5e7315e..d1466f7 100644
--- a/cmd/armflash.c
+++ b/cmd/armflash.c
@@ -280,7 +280,7 @@
} else if (argc == 4 && !strcmp(argv[1], "load")) {
ulong load_addr;
- load_addr = simple_strtoul(argv[3], NULL, 16);
+ load_addr = hextoul(argv[3], NULL);
ret = load_image(argv[2], load_addr);
} else {
return CMD_RET_USAGE;
diff --git a/cmd/avb.c b/cmd/avb.c
index 88172a9..783f51b 100644
--- a/cmd/avb.c
+++ b/cmd/avb.c
@@ -22,7 +22,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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)
@@ -366,7 +366,7 @@
return CMD_RET_USAGE;
name = argv[1];
- bytes = simple_strtoul(argv[2], &endp, 10);
+ bytes = dectoul(argv[2], &endp);
if (*endp && *endp != '\n')
return CMD_RET_USAGE;
diff --git a/cmd/axi.c b/cmd/axi.c
index c72197e..0c80fef 100644
--- a/cmd/axi.c
+++ b/cmd/axi.c
@@ -120,7 +120,7 @@
int i;
/* show specific bus */
- i = simple_strtoul(argv[1], NULL, 10);
+ i = dectoul(argv[1], NULL);
struct udevice *bus;
int ret;
@@ -153,7 +153,7 @@
printf("Current bus is %d\n", bus_no);
} else {
- bus_no = simple_strtoul(argv[1], NULL, 10);
+ bus_no = dectoul(argv[1], NULL);
printf("Setting bus to %d\n", bus_no);
ret = axi_set_cur_bus(bus_no);
@@ -193,19 +193,19 @@
}
if ((flag & CMD_FLAG_REPEAT) == 0) {
- size = simple_strtoul(argv[1], NULL, 10);
+ size = dectoul(argv[1], NULL);
/*
* Address is specified since argc >= 3
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
/*
* If there's another parameter, it is the length to display;
* length is the number of objects, not number of bytes
*/
if (argc > 3)
- length = simple_strtoul(argv[3], NULL, 16);
+ length = hextoul(argv[3], NULL);
}
switch (size) {
@@ -273,7 +273,7 @@
if (argc <= 3 || argc >= 6)
return CMD_RET_USAGE;
- size = simple_strtoul(argv[1], NULL, 10);
+ size = dectoul(argv[1], NULL);
switch (size) {
case 8:
@@ -291,14 +291,14 @@
};
/* Address is specified since argc > 4 */
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
/* Get the value to write */
- writeval = simple_strtoul(argv[3], NULL, 16);
+ writeval = hextoul(argv[3], NULL);
/* Count ? */
if (argc == 5)
- count = simple_strtoul(argv[4], NULL, 16);
+ count = hextoul(argv[4], NULL);
else
count = 1;
diff --git a/cmd/bedbug.c b/cmd/bedbug.c
index bef617b..549c905 100644
--- a/cmd/bedbug.c
+++ b/cmd/bedbug.c
@@ -75,11 +75,11 @@
if ((flag & CMD_FLAG_REPEAT) == 0) {
/* New command */
- addr = simple_strtoul (argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
/* If an extra param is given then it is the length */
if (argc > 2)
- len = simple_strtoul (argv[2], NULL, 16);
+ len = hextoul(argv[2], NULL);
}
/* Run the disassembler */
@@ -114,7 +114,7 @@
return CMD_RET_USAGE;
printf ("\nEnter '.' when done\n");
- mem_addr = simple_strtoul (argv[1], NULL, 16);
+ mem_addr = hextoul(argv[1], NULL);
while (1) {
putc ('\n');
diff --git a/cmd/bind.c b/cmd/bind.c
index af2f22c..07c629e 100644
--- a/cmd/bind.c
+++ b/cmd/bind.c
@@ -218,13 +218,13 @@
return CMD_RET_USAGE;
ret = unbind_by_node_path(argv[1]);
} else if (!by_node && bind) {
- int index = (argc > 2) ? simple_strtoul(argv[2], NULL, 10) : 0;
+ int index = (argc > 2) ? dectoul(argv[2], NULL) : 0;
if (argc != 4)
return CMD_RET_USAGE;
ret = bind_by_class_index(argv[1], index, argv[3]);
} else if (!by_node && !bind) {
- int index = (argc > 2) ? simple_strtoul(argv[2], NULL, 10) : 0;
+ int index = (argc > 2) ? dectoul(argv[2], NULL) : 0;
if (argc == 3)
ret = unbind_by_class_index(argv[1], index);
diff --git a/cmd/binop.c b/cmd/binop.c
index c85cb51..592e914 100644
--- a/cmd/binop.c
+++ b/cmd/binop.c
@@ -58,7 +58,7 @@
ulong addr;
u8 *buf;
- addr = simple_strtoul(varname, NULL, 16);
+ addr = hextoul(varname, NULL);
buf = map_sysmem(addr, len);
memcpy(buf, result, len);
unmap_sysmem(buf);
@@ -89,18 +89,18 @@
else
return CMD_RET_USAGE;
- len = simple_strtoul(lenarg, NULL, 10);
+ len = dectoul(lenarg, NULL);
src1 = malloc(len);
src2 = malloc(len);
if (*src1arg == '*')
- read_from_mem(simple_strtoul(src1arg + 1, NULL, 16), src1, len);
+ read_from_mem(hextoul(src1arg + 1, NULL), src1, len);
else
read_from_env_var(src1arg, src1);
if (*src2arg == '*')
- read_from_mem(simple_strtoul(src2arg + 1, NULL, 16), src2, len);
+ read_from_mem(hextoul(src2arg + 1, NULL), src2, len);
else
read_from_env_var(src2arg, src2);
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 87f94b5..4e442f2 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -40,7 +40,7 @@
return CMD_RET_USAGE;
case 3:
if (strncmp(argv[1], "dev", 3) == 0) {
- int dev = (int)simple_strtoul(argv[2], NULL, 10);
+ int dev = (int)dectoul(argv[2], NULL);
if (!blk_show_device(if_type, dev)) {
*cur_devnump = dev;
@@ -50,7 +50,7 @@
}
return 0;
} else if (strncmp(argv[1], "part", 4) == 0) {
- int dev = (int)simple_strtoul(argv[2], NULL, 10);
+ int dev = (int)dectoul(argv[2], NULL);
if (blk_print_part_devnum(if_type, dev)) {
printf("\n%s device %d not available\n",
@@ -63,9 +63,9 @@
default: /* at least 4 args */
if (strcmp(argv[1], "read") == 0) {
- ulong addr = simple_strtoul(argv[2], NULL, 16);
- lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
- ulong cnt = simple_strtoul(argv[4], NULL, 16);
+ ulong addr = hextoul(argv[2], NULL);
+ lbaint_t blk = hextoul(argv[3], NULL);
+ ulong cnt = hextoul(argv[4], NULL);
ulong n;
printf("\n%s read: device %d block # "LBAFU", count %lu ... ",
@@ -78,9 +78,9 @@
n == cnt ? "OK" : "ERROR");
return n == cnt ? 0 : 1;
} else if (strcmp(argv[1], "write") == 0) {
- ulong addr = simple_strtoul(argv[2], NULL, 16);
- lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
- ulong cnt = simple_strtoul(argv[4], NULL, 16);
+ ulong addr = hextoul(argv[2], NULL);
+ lbaint_t blk = hextoul(argv[3], NULL);
+ ulong cnt = hextoul(argv[4], NULL);
ulong n;
printf("\n%s write: device %d block # "LBAFU", count %lu ... ",
diff --git a/cmd/blob.c b/cmd/blob.c
index 887219c..e2efae7 100644
--- a/cmd/blob.c
+++ b/cmd/blob.c
@@ -70,10 +70,10 @@
else
return CMD_RET_USAGE;
- src_addr = simple_strtoul(argv[2], NULL, 16);
- dst_addr = simple_strtoul(argv[3], NULL, 16);
- len = simple_strtoul(argv[4], NULL, 16);
- key_addr = simple_strtoul(argv[5], NULL, 16);
+ src_addr = hextoul(argv[2], NULL);
+ dst_addr = hextoul(argv[3], NULL);
+ len = hextoul(argv[4], NULL);
+ key_addr = hextoul(argv[5], NULL);
km_ptr = (uint8_t *)(uintptr_t)key_addr;
src_ptr = (uint8_t *)(uintptr_t)src_addr;
diff --git a/cmd/bmp.c b/cmd/bmp.c
index 6040fa5..071ba90 100644
--- a/cmd/bmp.c
+++ b/cmd/bmp.c
@@ -102,7 +102,7 @@
addr = image_load_addr;
break;
case 2: /* use argument */
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
break;
default:
return CMD_RET_USAGE;
@@ -124,18 +124,18 @@
addr = image_load_addr;
break;
case 2: /* use argument */
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
break;
case 4:
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
if (!strcmp(argv[2], "m"))
x = BMP_ALIGN_CENTER;
else
- x = simple_strtoul(argv[2], NULL, 10);
+ x = dectoul(argv[2], NULL);
if (!strcmp(argv[3], "m"))
y = BMP_ALIGN_CENTER;
else
- y = simple_strtoul(argv[3], NULL, 10);
+ y = dectoul(argv[3], NULL);
break;
default:
return CMD_RET_USAGE;
diff --git a/cmd/boot.c b/cmd/boot.c
index b84c0ed..fab294e 100644
--- a/cmd/boot.c
+++ b/cmd/boot.c
@@ -29,7 +29,7 @@
if (argc < 2)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
printf ("## Starting application at 0x%08lX ...\n", addr);
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index cba81ff..83eab0b 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -281,7 +281,7 @@
return EFI_NOT_FOUND;
}
}
- fdt_addr = simple_strtoul(fdt_opt, NULL, 16);
+ fdt_addr = hextoul(fdt_opt, NULL);
if (!fdt_addr) {
log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
return EFI_LOAD_ERROR;
@@ -628,7 +628,7 @@
if (argc > 2) {
uintptr_t fdt_addr;
- fdt_addr = simple_strtoul(argv[2], NULL, 16);
+ fdt_addr = hextoul(argv[2], NULL);
fdt = map_sysmem(fdt_addr, 0);
} else {
fdt = EFI_FDT_USE_INTERNAL;
diff --git a/cmd/booti.c b/cmd/booti.c
index 3df70ea..397d4b8 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -43,7 +43,7 @@
debug("* kernel: default image load address = 0x%08lx\n",
image_load_addr);
} else {
- ld = simple_strtoul(argv[0], NULL, 16);
+ ld = hextoul(argv[0], NULL);
debug("* kernel: cmdline image address = 0x%08lx\n", ld);
}
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 81c6b93..92468d0 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -112,7 +112,7 @@
if (argc > 0) {
char *endp;
- simple_strtoul(argv[0], &endp, 16);
+ hextoul(argv[0], &endp);
/* endp pointing to NULL means that argv[0] was just a
* valid number, pass it along to the normal bootm processing
*
@@ -240,7 +240,7 @@
}
for (arg = 1; arg < argc; ++arg) {
- addr = simple_strtoul(argv[arg], NULL, 16);
+ addr = hextoul(argv[arg], NULL);
if (image_info(addr) != 0)
rcode = 1;
}
diff --git a/cmd/bootstage.c b/cmd/bootstage.c
index 0e623f2..77a4bc6 100644
--- a/cmd/bootstage.c
+++ b/cmd/bootstage.c
@@ -24,12 +24,12 @@
*sizep = CONFIG_BOOTSTAGE_STASH_SIZE;
if (argc < 2)
return 0;
- *basep = simple_strtoul(argv[1], &endp, 16);
+ *basep = hextoul(argv[1], &endp);
if (*argv[1] == 0 || *endp != 0)
return -1;
if (argc == 2)
return 0;
- *sizep = simple_strtoul(argv[2], &endp, 16);
+ *sizep = hextoul(argv[2], &endp);
if (*argv[2] == 0 || *endp != 0)
return -1;
diff --git a/cmd/bootz.c b/cmd/bootz.c
index 7556cd2..4f024bd 100644
--- a/cmd/bootz.c
+++ b/cmd/bootz.c
@@ -39,7 +39,7 @@
debug("* kernel: default image load address = 0x%08lx\n",
image_load_addr);
} else {
- images->ep = simple_strtoul(argv[0], NULL, 16);
+ images->ep = hextoul(argv[0], NULL);
debug("* kernel: cmdline image address = 0x%08lx\n",
images->ep);
}
diff --git a/cmd/broadcom/nitro_image_load.c b/cmd/broadcom/nitro_image_load.c
index 4a36b30..93b5cb4 100644
--- a/cmd/broadcom/nitro_image_load.c
+++ b/cmd/broadcom/nitro_image_load.c
@@ -53,13 +53,13 @@
return CMD_RET_USAGE;
/* convert command parameter to fastboot address (base 16), i.e. hex */
- images_load_addr = simple_strtoul(argv[1], NULL, 16);
+ images_load_addr = hextoul(argv[1], NULL);
if (!images_load_addr) {
pr_err("Invalid load address\n");
return CMD_RET_USAGE;
}
- spi_load_addr = simple_strtoul(argv[2], NULL, 16);
+ spi_load_addr = hextoul(argv[2], NULL);
if (!spi_load_addr) {
pr_err("Invalid spi load address\n");
return CMD_RET_USAGE;
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 10c2c92..8a61f2c 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -22,7 +22,7 @@
return 0;
}
if (argc == 2) {
- end_of_rom = simple_strtoul(argv[1], &ep, 16);
+ end_of_rom = hextoul(argv[1], &ep);
if (*ep) {
puts("\n** Invalid end of ROM **\n");
return 1;
@@ -58,9 +58,9 @@
}
/* parse offset and count */
- offset = simple_strtoul(argv[1], NULL, 16);
+ offset = hextoul(argv[1], NULL);
if (argc == 4)
- count = simple_strtoul(argv[3], NULL, 16);
+ count = hextoul(argv[3], NULL);
else
count = 0;
diff --git a/cmd/clk.c b/cmd/clk.c
index 7ece245..dbbdc31 100644
--- a/cmd/clk.c
+++ b/cmd/clk.c
@@ -120,7 +120,7 @@
s32 freq;
struct udevice *dev;
- freq = simple_strtoul(argv[2], NULL, 10);
+ freq = dectoul(argv[2], NULL);
dev = clk_lookup(argv[1]);
diff --git a/cmd/clone.c b/cmd/clone.c
index 32473a0..a906207 100644
--- a/cmd/clone.c
+++ b/cmd/clone.c
@@ -34,7 +34,7 @@
printf("Unable to open destination device\n");
return 1;
}
- requested = simple_strtoul(argv[5], &unit, 10);
+ requested = dectoul(argv[5], &unit);
srcbz = srcdesc->blksz;
destbz = destdesc->blksz;
diff --git a/cmd/cramfs.c b/cmd/cramfs.c
index 1aeb567..44c0818 100644
--- a/cmd/cramfs.c
+++ b/cmd/cramfs.c
@@ -107,7 +107,7 @@
struct mtdids id;
ulong addr;
- addr = simple_strtoul(env_get("cramfsaddr"), NULL, 16);
+ addr = hextoul(env_get("cramfsaddr"), NULL);
/* hack! */
/* cramfs_* only supports NOR flash chips */
@@ -172,7 +172,7 @@
struct mtdids id;
ulong addr;
- addr = simple_strtoul(env_get("cramfsaddr"), NULL, 16);
+ addr = hextoul(env_get("cramfsaddr"), NULL);
/* hack! */
/* cramfs_* only supports NOR flash chips */
diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c
index eb5053d..a40f589 100644
--- a/cmd/cros_ec.c
+++ b/cmd/cros_ec.c
@@ -65,11 +65,11 @@
return 1;
if (argc < 4)
return 1;
- addr = simple_strtoul(argv[3], &endp, 16);
+ addr = hextoul(argv[3], &endp);
if (*argv[3] == 0 || *endp != 0)
return 1;
if (argc > 4) {
- size = simple_strtoul(argv[4], &endp, 16);
+ size = hextoul(argv[4], &endp);
if (*argv[4] == 0 || *endp != 0)
return 1;
}
@@ -501,11 +501,11 @@
if (argc < 3)
return CMD_RET_USAGE;
- index = simple_strtoul(argv[2], &endp, 10);
+ index = dectoul(argv[2], &endp);
if (*argv[2] == 0 || *endp != 0)
return CMD_RET_USAGE;
if (argc > 3) {
- state = simple_strtoul(argv[3], &endp, 10);
+ state = dectoul(argv[3], &endp);
if (*argv[3] == 0 || *endp != 0)
return CMD_RET_USAGE;
ret = cros_ec_set_ldo(dev, index, state);
diff --git a/cmd/demo.c b/cmd/demo.c
index 78a55f7..571f562 100644
--- a/cmd/demo.c
+++ b/cmd/demo.c
@@ -48,7 +48,7 @@
int ret;
if (argc) {
- light = simple_strtoul(argv[0], NULL, 16);
+ light = hextoul(argv[0], NULL);
ret = demo_set_light(demo_dev, light);
} else {
ret = demo_get_light(demo_dev);
@@ -106,7 +106,7 @@
return CMD_RET_USAGE;
if (argc) {
- devnum = simple_strtoul(argv[0], NULL, 10);
+ devnum = dectoul(argv[0], NULL);
ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev);
if (ret)
return cmd_process_error(cmdtp, ret);
diff --git a/cmd/disk.c b/cmd/disk.c
index 2726115..cb3b990 100644
--- a/cmd/disk.c
+++ b/cmd/disk.c
@@ -36,7 +36,7 @@
bootstage_mark(BOOTSTAGE_ID_IDE_ADDR);
if (argc > 1)
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 8211a58..67ab06a 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -61,7 +61,7 @@
argv++;
}
- capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16);
+ capsule = (typeof(capsule))hextoul(argv[1], &endp);
if (endp == argv[1]) {
printf("Invalid address: %s", argv[1]);
return CMD_RET_FAILURE;
@@ -117,7 +117,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16);
+ capsule = (typeof(capsule))hextoul(argv[1], &endp);
if (endp == argv[1]) {
printf("Invalid address: %s", argv[1]);
return CMD_RET_FAILURE;
@@ -256,7 +256,7 @@
argc--;
argv++;
- capsule_id = simple_strtoul(argv[0], &endp, 16);
+ capsule_id = hextoul(argv[0], &endp);
if (capsule_id < 0 || capsule_id > 0xffff)
return CMD_RET_USAGE;
@@ -983,7 +983,7 @@
r = CMD_RET_USAGE;
goto out;
}
- id = (int)simple_strtoul(argv[1], &endp, 16);
+ id = (int)hextoul(argv[1], &endp);
if (*endp != '\0' || id > 0xffff)
return CMD_RET_USAGE;
@@ -1113,7 +1113,7 @@
guid = efi_global_variable_guid;
for (i = 1; i < argc; i++, argv++) {
- id = (int)simple_strtoul(argv[1], &endp, 16);
+ id = (int)hextoul(argv[1], &endp);
if (*endp != '\0' || id > 0xffff)
return CMD_RET_FAILURE;
@@ -1410,7 +1410,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- bootnext = (u16)simple_strtoul(argv[1], &endp, 16);
+ bootnext = (u16)hextoul(argv[1], &endp);
if (*endp) {
printf("invalid value: %s\n", argv[1]);
r = CMD_RET_FAILURE;
@@ -1469,7 +1469,7 @@
return CMD_RET_FAILURE;
for (i = 0; i < argc; i++) {
- id = (int)simple_strtoul(argv[i], &endp, 16);
+ id = (int)hextoul(argv[i], &endp);
if (*endp != '\0' || id > 0xffff) {
printf("invalid value: %s\n", argv[i]);
r = CMD_RET_FAILURE;
diff --git a/cmd/elf.c b/cmd/elf.c
index d44b95d..d75b214 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -115,7 +115,7 @@
if (argc < 2)
addr = image_load_addr;
else
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
#if defined(CONFIG_CMD_NET)
/*
@@ -200,7 +200,7 @@
}
if (!bootaddr)
- bootaddr = simple_strtoul(tmp, NULL, 16);
+ bootaddr = hextoul(tmp, NULL);
/*
* Check to see if the bootline is defined in the 'bootargs' parameter.
diff --git a/cmd/exit.c b/cmd/exit.c
index 923f087..2c71326 100644
--- a/cmd/exit.c
+++ b/cmd/exit.c
@@ -11,7 +11,7 @@
char *const argv[])
{
if (argc > 1)
- return simple_strtoul(argv[1], NULL, 10);
+ return dectoul(argv[1], NULL);
return 0;
}
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index ad5c064..033a2c9 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -112,13 +112,13 @@
case 'l':
if (--argc <= 0)
return CMD_RET_USAGE;
- buf_addr = simple_strtoul(*++argv, NULL, 16);
+ buf_addr = hextoul(*++argv, NULL);
goto NXTARG;
case 's':
if (--argc <= 0)
return CMD_RET_USAGE;
- buf_size = simple_strtoul(*++argv, NULL, 16);
+ buf_size = hextoul(*++argv, NULL);
goto NXTARG;
default:
diff --git a/cmd/fdt.c b/cmd/fdt.c
index baec055..c42f1c7 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -143,7 +143,7 @@
return 0;
}
- addr = simple_strtoul(argv[0], NULL, 16);
+ addr = hextoul(argv[0], NULL);
blob = map_sysmem(addr, 0);
if (!fdt_valid(&blob))
return 1;
@@ -157,7 +157,7 @@
int err;
/* Optional new length */
- len = simple_strtoul(argv[1], NULL, 16);
+ len = hextoul(argv[1], NULL);
if (len < fdt_totalsize(blob)) {
printf("New length %d < existing length %d, ignoring\n",
len, fdt_totalsize(blob));
@@ -195,11 +195,11 @@
/*
* Set the address and length of the fdt.
*/
- working_fdt = (struct fdt_header *)simple_strtoul(argv[2], NULL, 16);
+ working_fdt = (struct fdt_header *)hextoul(argv[2], NULL);
if (!fdt_valid(&working_fdt))
return 1;
- newaddr = (struct fdt_header *)simple_strtoul(argv[3],NULL,16);
+ newaddr = (struct fdt_header *)hextoul(argv[3], NULL);
/*
* If the user specifies a length, use that. Otherwise use the
@@ -208,7 +208,7 @@
if (argc <= 4) {
len = fdt_totalsize(working_fdt);
} else {
- len = simple_strtoul(argv[4], NULL, 16);
+ len = hextoul(argv[4], NULL);
if (len < fdt_totalsize(working_fdt)) {
printf ("New length 0x%X < existing length "
"0x%X, aborting.\n",
@@ -364,21 +364,22 @@
}
if (subcmd[0] == 'n' || (subcmd[0] == 's' && argc == 5)) {
- int reqIndex = -1;
+ int req_index = -1;
int startDepth = fdt_node_depth(
working_fdt, nodeoffset);
int curDepth = startDepth;
- int curIndex = -1;
+ int cur_index = -1;
int nextNodeOffset = fdt_next_node(
working_fdt, nodeoffset, &curDepth);
if (subcmd[0] == 'n')
- reqIndex = simple_strtoul(argv[5], NULL, 16);
+ req_index = hextoul(argv[5], NULL);
while (curDepth > startDepth) {
if (curDepth == startDepth + 1)
- curIndex++;
- if (subcmd[0] == 'n' && curIndex == reqIndex) {
+ cur_index++;
+ if (subcmd[0] == 'n' &&
+ cur_index == req_index) {
const char *node_name;
node_name = fdt_get_name(working_fdt,
@@ -394,7 +395,7 @@
}
if (subcmd[0] == 's') {
/* get the num nodes at this level */
- env_set_ulong(var, curIndex + 1);
+ env_set_ulong(var, cur_index + 1);
} else {
/* node index not found */
printf("libfdt node not found\n");
@@ -548,7 +549,7 @@
* Set boot cpu id
*/
} else if (strncmp(argv[1], "boo", 3) == 0) {
- unsigned long tmp = simple_strtoul(argv[2], NULL, 16);
+ unsigned long tmp = hextoul(argv[2], NULL);
fdt_set_boot_cpuid_phys(working_fdt, tmp);
/*
@@ -600,7 +601,7 @@
return err;
}
} else if (argv[2][0] == 'd') {
- unsigned long idx = simple_strtoul(argv[3], NULL, 16);
+ unsigned long idx = hextoul(argv[3], NULL);
int err = fdt_del_mem_rsv(working_fdt, idx);
if (err < 0) {
@@ -636,8 +637,8 @@
return CMD_RET_USAGE;
if (argc == 4) {
- initrd_start = simple_strtoul(argv[2], NULL, 16);
- initrd_end = simple_strtoul(argv[3], NULL, 16);
+ initrd_start = hextoul(argv[2], NULL);
+ initrd_end = hextoul(argv[3], NULL);
}
fdt_chosen(working_fdt);
@@ -654,7 +655,7 @@
return CMD_RET_FAILURE;
if (argc > 2) {
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
blob = map_sysmem(addr, 0);
} else {
blob = (struct fdt_header *)gd->fdt_blob;
@@ -691,7 +692,7 @@
if (!working_fdt)
return CMD_RET_FAILURE;
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
blob = map_sysmem(addr, 0);
if (!fdt_valid(&blob))
return CMD_RET_FAILURE;
@@ -706,7 +707,7 @@
else if (strncmp(argv[1], "re", 2) == 0) {
uint extrasize;
if (argc > 2)
- extrasize = simple_strtoul(argv[2], NULL, 16);
+ extrasize = hextoul(argv[2], NULL);
else
extrasize = 0;
fdt_shrink_to_minimum(working_fdt, extrasize);
@@ -797,7 +798,7 @@
}
if (!isxdigit(*newp))
break;
- tmp = simple_strtoul(newp, &newp, 16);
+ tmp = hextoul(newp, &newp);
*data++ = tmp & 0xFF;
*len = *len + 1;
}
@@ -883,7 +884,7 @@
env_max_dump = env_get("fdt_max_dump");
if (env_max_dump)
- max_dump = simple_strtoul(env_max_dump, NULL, 16);
+ max_dump = hextoul(env_max_dump, NULL);
/*
* It is a string, but it may have multiple strings (embedded '\0's).
diff --git a/cmd/flash.c b/cmd/flash.c
index 240871e..819febc 100644
--- a/cmd/flash.c
+++ b/cmd/flash.c
@@ -57,7 +57,7 @@
return 0;
*p++ = '\0';
- bank = simple_strtoul (str, &ep, 10);
+ bank = dectoul(str, &ep);
if (ep == str || *ep != '\0' ||
bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS ||
(fp = &flash_info[bank - 1])->flash_id == FLASH_UNKNOWN)
@@ -67,12 +67,12 @@
if ((p = strchr (str, '-')) != NULL)
*p++ = '\0';
- first = simple_strtoul (str, &ep, 10);
+ first = dectoul(str, &ep);
if (ep == str || *ep != '\0' || first >= fp->sector_count)
return -1;
if (p != NULL) {
- last = simple_strtoul (p, &ep, 10);
+ last = dectoul(p, &ep);
if (ep == p || *ep != '\0' ||
last < first || last >= fp->sector_count)
return -1;
@@ -151,7 +151,7 @@
char *ep;
char len_used; /* indicates if the "start +length" form used */
- *addr_first = simple_strtoul(arg1, &ep, 16);
+ *addr_first = hextoul(arg1, &ep);
if (ep == arg1 || *ep != '\0')
return -1;
@@ -161,7 +161,7 @@
++arg2;
}
- *addr_last = simple_strtoul(arg2, &ep, 16);
+ *addr_last = hextoul(arg2, &ep);
if (ep == arg2 || *ep != '\0')
return -1;
@@ -287,7 +287,7 @@
return 0;
}
- bank = simple_strtoul(argv[1], NULL, 16);
+ bank = hextoul(argv[1], NULL);
if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) {
printf ("Only FLASH Banks # 1 ... # %d supported\n",
CONFIG_SYS_MAX_FLASH_BANKS);
@@ -366,7 +366,7 @@
return CMD_RET_USAGE;
if (strcmp(argv[1], "bank") == 0) {
- bank = simple_strtoul(argv[2], NULL, 16);
+ bank = hextoul(argv[2], NULL);
if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) {
printf ("Only FLASH Banks # 1 ... # %d supported\n",
CONFIG_SYS_MAX_FLASH_BANKS);
@@ -547,7 +547,7 @@
return CMD_RET_USAGE;
if (strcmp(argv[2], "bank") == 0) {
- bank = simple_strtoul(argv[3], NULL, 16);
+ bank = hextoul(argv[3], NULL);
if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) {
printf ("Only FLASH Banks # 1 ... # %d supported\n",
CONFIG_SYS_MAX_FLASH_BANKS);
diff --git a/cmd/fpga.c b/cmd/fpga.c
index 51410a8..3fdd0b3 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -57,7 +57,7 @@
}
*fpga_data = local_fpga_data;
- local_data_size = simple_strtoul(argv[2], NULL, 16);
+ local_data_size = hextoul(argv[2], NULL);
if (!local_data_size) {
debug("fpga: zero size\n");
return CMD_RET_USAGE;
@@ -95,8 +95,8 @@
*/
argc++;
- fpga_sec_info.encflag = (u8)simple_strtoul(argv[4], NULL, 16);
- fpga_sec_info.authflag = (u8)simple_strtoul(argv[3], NULL, 16);
+ fpga_sec_info.encflag = (u8)hextoul(argv[4], NULL);
+ fpga_sec_info.authflag = (u8)hextoul(argv[3], NULL);
if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
@@ -134,7 +134,7 @@
return ret;
fpga_fsinfo.fstype = FS_TYPE_ANY;
- fpga_fsinfo.blocksize = (unsigned int)simple_strtoul(argv[3], NULL, 16);
+ fpga_fsinfo.blocksize = (unsigned int)hextoul(argv[3], NULL);
fpga_fsinfo.interface = argv[4];
fpga_fsinfo.dev_part = argv[5];
fpga_fsinfo.filename = argv[6];
@@ -274,7 +274,7 @@
} else
#endif
{
- fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
+ fpga_data = (void *)hextoul(datastr, NULL);
debug("* fpga: cmdline image address = 0x%08lx\n",
(ulong)fpga_data);
}
diff --git a/cmd/fpgad.c b/cmd/fpgad.c
index fb2fe63..e65441b 100644
--- a/cmd/fpgad.c
+++ b/cmd/fpgad.c
@@ -49,19 +49,19 @@
/*
* FPGA is specified since argc > 2
*/
- fpga = simple_strtoul(argv[1], NULL, 16);
+ fpga = hextoul(argv[1], NULL);
/*
* Address is specified since argc > 2
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
/*
* If another parameter, it is the length to display.
* Length is the number of objects, not number of bytes.
*/
if (argc > 3)
- length = simple_strtoul(argv[3], NULL, 16);
+ length = hextoul(argv[3], NULL);
}
nbytes = length * sizeof(u16);
diff --git a/cmd/gpio.c b/cmd/gpio.c
index 4fdb313..4150024 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -17,7 +17,7 @@
__weak int name_to_gpio(const char *name)
{
- return simple_strtoul(name, NULL, 10);
+ return dectoul(name, NULL);
}
enum gpio_cmd {
@@ -99,7 +99,7 @@
p = gpio_name + banklen;
if (gpio_name && *p) {
- offset = simple_strtoul(p, NULL, 10);
+ offset = dectoul(p, NULL);
gpio_get_description(dev, bank_name, offset,
&flags, true);
} else {
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 17f2b83..f818fbb 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -985,7 +985,7 @@
#endif
return CMD_RET_USAGE;
- dev = (int)simple_strtoul(argv[3], &ep, 10);
+ dev = (int)dectoul(argv[3], &ep);
if (!ep || ep[0] != '\0') {
printf("'%s' is not a number\n", argv[3]);
return CMD_RET_USAGE;
diff --git a/cmd/host.c b/cmd/host.c
index 6aa3d91..2e998ab 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -62,7 +62,7 @@
if (argc > 2)
return CMD_RET_USAGE;
dev_str = argv[0];
- dev = simple_strtoul(dev_str, &ep, 16);
+ dev = hextoul(dev_str, &ep);
if (*ep) {
printf("** Bad device specification %s **\n", dev_str);
return CMD_RET_USAGE;
@@ -82,7 +82,7 @@
if (argc >= 2) {
char *ep;
char *dev_str = argv[1];
- int dev = simple_strtoul(dev_str, &ep, 16);
+ int dev = hextoul(dev_str, &ep);
if (*ep) {
printf("** Bad device specification %s **\n", dev_str);
return CMD_RET_USAGE;
@@ -139,7 +139,7 @@
return 0;
}
- dev = simple_strtoul(argv[1], &ep, 16);
+ dev = hextoul(argv[1], &ep);
if (*ep) {
printf("** Bad device specification %s **\n", argv[2]);
return CMD_RET_USAGE;
diff --git a/cmd/i2c.c b/cmd/i2c.c
index 0e1895a..c7c08c4 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -308,13 +308,13 @@
/*
* I2C chip address
*/
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
/*
* I2C data address within the chip. This can be 1 or
* 2 bytes long. Some day it might be 3 bytes long :-).
*/
- devaddr = simple_strtoul(argv[2], NULL, 16);
+ devaddr = hextoul(argv[2], NULL);
alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
if (alen > 3)
return CMD_RET_USAGE;
@@ -322,12 +322,12 @@
/*
* Length is the number of objects, not number of bytes.
*/
- length = simple_strtoul(argv[3], NULL, 16);
+ length = hextoul(argv[3], NULL);
/*
* memaddr is the address where to store things in memory
*/
- memaddr = (u_char *)simple_strtoul(argv[4], NULL, 16);
+ memaddr = (u_char *)hextoul(argv[4], NULL);
#if CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_get_cur_bus_chip(chip, &dev);
@@ -363,18 +363,18 @@
/*
* memaddr is the address where to store things in memory
*/
- memaddr = (u_char *)simple_strtoul(argv[1], NULL, 16);
+ memaddr = (u_char *)hextoul(argv[1], NULL);
/*
* I2C chip address
*/
- chip = simple_strtoul(argv[2], NULL, 16);
+ chip = hextoul(argv[2], NULL);
/*
* I2C data address within the chip. This can be 1 or
* 2 bytes long. Some day it might be 3 bytes long :-).
*/
- devaddr = simple_strtoul(argv[3], NULL, 16);
+ devaddr = hextoul(argv[3], NULL);
alen = get_alen(argv[3], DEFAULT_ADDR_LEN);
if (alen > 3)
return cmd_usage(cmdtp);
@@ -382,7 +382,7 @@
/*
* Length is the number of bytes.
*/
- length = simple_strtoul(argv[4], NULL, 16);
+ length = hextoul(argv[4], NULL);
#if CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_get_cur_bus_chip(chip, &dev);
@@ -447,13 +447,13 @@
if (argc < 2)
return CMD_RET_USAGE;
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
ret = i2c_get_cur_bus_chip(chip, &dev);
if (ret)
return i2c_report_err(ret, I2C_ERR_READ);
if (argc > 2) {
- flags = simple_strtoul(argv[2], NULL, 16);
+ flags = hextoul(argv[2], NULL);
ret = i2c_set_chip_flags(dev, flags);
} else {
ret = i2c_get_chip_flags(dev, &flags);
@@ -477,13 +477,13 @@
if (argc < 2)
return CMD_RET_USAGE;
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
ret = i2c_get_cur_bus_chip(chip, &dev);
if (ret)
return i2c_report_err(ret, I2C_ERR_READ);
if (argc > 2) {
- olen = simple_strtoul(argv[2], NULL, 16);
+ olen = hextoul(argv[2], NULL);
ret = i2c_set_chip_offset_len(dev, olen);
} else {
ret = i2c_get_chip_offset_len(dev);
@@ -543,13 +543,13 @@
/*
* I2C chip address
*/
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
/*
* I2C data address within the chip. This can be 1 or
* 2 bytes long. Some day it might be 3 bytes long :-).
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
if (alen > 3)
return CMD_RET_USAGE;
@@ -559,7 +559,7 @@
* Length is the number of objects, not number of bytes.
*/
if (argc > 3)
- length = simple_strtoul(argv[3], NULL, 16);
+ length = hextoul(argv[3], NULL);
}
#if CONFIG_IS_ENABLED(DM_I2C)
@@ -651,12 +651,12 @@
/*
* Chip is always specified.
*/
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
/*
* Address is always specified.
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
if (alen > 3)
return CMD_RET_USAGE;
@@ -671,13 +671,13 @@
/*
* Value to write is always specified.
*/
- byte = simple_strtoul(argv[3], NULL, 16);
+ byte = hextoul(argv[3], NULL);
/*
* Optional count
*/
if (argc == 5)
- count = simple_strtoul(argv[4], NULL, 16);
+ count = hextoul(argv[4], NULL);
else
count = 1;
@@ -740,12 +740,12 @@
/*
* Chip is always specified.
*/
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
/*
* Address is always specified.
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
if (alen > 3)
return CMD_RET_USAGE;
@@ -760,7 +760,7 @@
/*
* Count is always specified
*/
- count = simple_strtoul(argv[3], NULL, 16);
+ count = hextoul(argv[3], NULL);
printf ("CRC32 for %08lx ... %08lx ==> ", addr, addr + count - 1);
/*
@@ -840,12 +840,12 @@
/*
* Chip is always specified.
*/
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
/*
* Address is always specified.
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
if (alen > 3)
return CMD_RET_USAGE;
@@ -900,7 +900,7 @@
else {
char *endp;
- data = simple_strtoul(console_buffer, &endp, 16);
+ data = hextoul(console_buffer, &endp);
if (size == 1)
data = data << 24;
else if (size == 2)
@@ -1049,12 +1049,12 @@
/*
* Chip is always specified.
*/
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
/*
* Address is always specified.
*/
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
alen = get_alen(argv[2], DEFAULT_ADDR_LEN);
if (alen > 3)
return CMD_RET_USAGE;
@@ -1070,7 +1070,7 @@
* Length is the number of objects, not number of bytes.
*/
length = 1;
- length = simple_strtoul(argv[3], NULL, 16);
+ length = hextoul(argv[3], NULL);
if (length > sizeof(bytes))
length = sizeof(bytes);
@@ -1079,7 +1079,7 @@
*/
delay = 1000;
if (argc > 3)
- delay = simple_strtoul(argv[4], NULL, 10);
+ delay = dectoul(argv[4], NULL);
/*
* Run the loop...
*/
@@ -1219,7 +1219,7 @@
/*
* Chip is always specified.
*/
- chip = simple_strtoul (argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
#if CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_get_cur_bus_chip(chip, &dev);
@@ -1673,7 +1673,7 @@
return 1;
}
- chip = simple_strtoul(argv[1], NULL, 16);
+ chip = hextoul(argv[1], NULL);
#if CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_get_cur_bus_chip(chip, &dev);
if (!ret)
@@ -1765,7 +1765,7 @@
int i;
/* show specific bus */
- i = simple_strtoul(argv[1], NULL, 10);
+ i = dectoul(argv[1], NULL);
#if CONFIG_IS_ENABLED(DM_I2C)
struct udevice *bus;
int ret;
@@ -1833,7 +1833,7 @@
#endif
printf("Current bus is %d\n", bus_no);
} else {
- bus_no = simple_strtoul(argv[1], NULL, 10);
+ bus_no = dectoul(argv[1], NULL);
#if defined(CONFIG_SYS_I2C_LEGACY)
if (bus_no >= CONFIG_SYS_NUM_I2C_BUSES) {
printf("Invalid bus %d\n", bus_no);
@@ -1884,7 +1884,7 @@
/* querying current speed */
printf("Current bus speed=%d\n", speed);
} else {
- speed = simple_strtoul(argv[1], NULL, 10);
+ speed = dectoul(argv[1], NULL);
printf("Setting bus speed to %d Hz\n", speed);
#if CONFIG_IS_ENABLED(DM_I2C)
ret = dm_i2c_set_bus_speed(bus, speed);
diff --git a/cmd/ini.c b/cmd/ini.c
index c075be6..81dfc4c 100644
--- a/cmd/ini.c
+++ b/cmd/ini.c
@@ -236,10 +236,10 @@
return CMD_RET_USAGE;
section = argv[1];
- file_address = (char *)simple_strtoul(
- argc < 3 ? env_get("loadaddr") : argv[2], NULL, 16);
- file_size = (size_t)simple_strtoul(
- argc < 4 ? env_get("filesize") : argv[3], NULL, 16);
+ file_address = (char *)hextoul(argc < 3 ? env_get("loadaddr") : argv[2],
+ NULL);
+ file_size = (size_t)hextoul(argc < 4 ? env_get("filesize") : argv[3],
+ NULL);
return ini_parse(file_address, file_size, ini_handler, (void *)section);
}
diff --git a/cmd/io.c b/cmd/io.c
index c7e9641..e23ea62 100644
--- a/cmd/io.c
+++ b/cmd/io.c
@@ -51,7 +51,7 @@
return 1;
/* Address is specified since argc > 1 */
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
addr += base_address;
/*
@@ -59,7 +59,7 @@
* Length is the number of objects, not number of bytes.
*/
if (argc > 2)
- length = simple_strtoul(argv[2], NULL, 16);
+ length = hextoul(argv[2], NULL);
}
bytes = size * length;
@@ -102,8 +102,8 @@
if (size < 0)
return 1;
- addr = simple_strtoul(argv[1], NULL, 16);
- val = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[1], NULL);
+ val = hextoul(argv[2], NULL);
if (size == 4)
outl((u32) val, addr);
diff --git a/cmd/iotrace.c b/cmd/iotrace.c
index 652ebef..f28359e 100644
--- a/cmd/iotrace.c
+++ b/cmd/iotrace.c
@@ -60,8 +60,8 @@
ulong addr = 0, size = 0;
if (argc == 2) {
- addr = simple_strtoul(*argv++, NULL, 16);
- size = simple_strtoul(*argv++, NULL, 16);
+ addr = hextoul(*argv++, NULL);
+ size = hextoul(*argv++, NULL);
} else if (argc != 0) {
return CMD_RET_USAGE;
}
@@ -76,8 +76,8 @@
ulong addr = 0, size = 0;
if (argc == 2) {
- addr = simple_strtoul(*argv++, NULL, 16);
- size = simple_strtoul(*argv++, NULL, 16);
+ addr = hextoul(*argv++, NULL);
+ size = hextoul(*argv++, NULL);
} else if (argc != 0) {
return CMD_RET_USAGE;
}
diff --git a/cmd/itest.c b/cmd/itest.c
index 9a441ce..74414cb 100644
--- a/cmd/itest.c
+++ b/cmd/itest.c
@@ -57,7 +57,7 @@
/* if the parameter starts with a * then assume is a pointer to the value we want */
if (s[0] == '*') {
- addr = simple_strtoul(&s[1], NULL, 16);
+ addr = hextoul(&s[1], NULL);
buf = map_physmem(addr, w, MAP_WRBACK);
if (!buf && addr) {
puts("Failed to map physical memory\n");
@@ -82,7 +82,7 @@
unmap_physmem(buf, w);
return l;
} else {
- l = simple_strtoul(s, NULL, 16);
+ l = hextoul(s, NULL);
}
/* avoid overflow on mask calculus */
@@ -93,7 +93,7 @@
{
/* if the parameter starts with a * then assume a string pointer else its a literal */
if (s[0] == '*') {
- return (char *)simple_strtoul(&s[1], NULL, 16);
+ return (char *)hextoul(&s[1], NULL);
} else if (s[0] == '$') {
int i = 2;
diff --git a/cmd/jffs2.c b/cmd/jffs2.c
index 9540988..63bd552 100644
--- a/cmd/jffs2.c
+++ b/cmd/jffs2.c
@@ -491,7 +491,7 @@
filename = argv[1];
}
if (argc == 3) {
- offset = simple_strtoul(argv[1], NULL, 16);
+ offset = hextoul(argv[1], NULL);
image_load_addr = offset;
filename = argv[2];
}
diff --git a/cmd/led.c b/cmd/led.c
index aa77519..48a02ba 100644
--- a/cmd/led.c
+++ b/cmd/led.c
@@ -93,7 +93,7 @@
if (cmd == LEDST_BLINK) {
if (argc < 4)
return CMD_RET_USAGE;
- freq_ms = simple_strtoul(argv[3], NULL, 10);
+ freq_ms = dectoul(argv[3], NULL);
}
#endif
ret = led_get_by_label(led_label, &dev);
diff --git a/cmd/legacy_led.c b/cmd/legacy_led.c
index 86cd969..5256255 100644
--- a/cmd/legacy_led.c
+++ b/cmd/legacy_led.c
@@ -129,7 +129,7 @@
if (argc != 4)
return CMD_RET_USAGE;
- freq = simple_strtoul(argv[3], NULL, 10);
+ freq = dectoul(argv[3], NULL);
__led_blink(led_commands[i].mask, freq);
}
/* Need to set only 1 led if led_name wasn't 'all' */
diff --git a/cmd/load.c b/cmd/load.c
index b7894d7..381ed1b 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -70,7 +70,7 @@
offset = simple_strtol(argv[1], NULL, 16);
}
if (argc == 3) {
- load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
+ load_baudrate = (int)dectoul(argv[2], NULL);
/* default to current baudrate */
if (load_baudrate == 0)
@@ -257,14 +257,14 @@
#endif
if (argc >= 2) {
- offset = simple_strtoul(argv[1], NULL, 16);
+ offset = hextoul(argv[1], NULL);
}
#ifdef CONFIG_SYS_LOADS_BAUD_CHANGE
if (argc >= 3) {
- size = simple_strtoul(argv[2], NULL, 16);
+ size = hextoul(argv[2], NULL);
}
if (argc == 4) {
- save_baudrate = (int)simple_strtoul(argv[3], NULL, 10);
+ save_baudrate = (int)dectoul(argv[3], NULL);
/* default to current baudrate */
if (save_baudrate == 0)
@@ -284,7 +284,7 @@
}
#else /* ! CONFIG_SYS_LOADS_BAUD_CHANGE */
if (argc == 3) {
- size = simple_strtoul(argv[2], NULL, 16);
+ size = hextoul(argv[2], NULL);
}
#endif /* CONFIG_SYS_LOADS_BAUD_CHANGE */
@@ -438,15 +438,15 @@
/* pre-set offset from $loadaddr */
s = env_get("loadaddr");
if (s)
- offset = simple_strtoul(s, NULL, 16);
+ offset = hextoul(s, NULL);
load_baudrate = current_baudrate = gd->baudrate;
if (argc >= 2) {
- offset = simple_strtoul(argv[1], NULL, 16);
+ offset = hextoul(argv[1], NULL);
}
if (argc == 3) {
- load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
+ load_baudrate = (int)dectoul(argv[2], NULL);
/* default to current baudrate */
if (load_baudrate == 0)
diff --git a/cmd/log.c b/cmd/log.c
index 72380c5..c377aee 100644
--- a/cmd/log.c
+++ b/cmd/log.c
@@ -352,7 +352,7 @@
if (argc < 7)
return CMD_RET_USAGE;
cat = log_get_cat_by_name(argv[1]);
- level = simple_strtoul(argv[2], &end, 10);
+ level = dectoul(argv[2], &end);
if (end == argv[2]) {
level = log_get_level_by_name(argv[2]);
@@ -366,7 +366,7 @@
return CMD_RET_USAGE;
}
file = argv[3];
- line = simple_strtoul(argv[4], NULL, 10);
+ line = dectoul(argv[4], NULL);
func = argv[5];
msg = argv[6];
if (_log(cat, level, file, line, func, "%s\n", msg))
diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c
index 3b8db0a..81924da 100644
--- a/cmd/lzmadec.c
+++ b/cmd/lzmadec.c
@@ -26,11 +26,11 @@
switch (argc) {
case 4:
- dst_len = simple_strtoul(argv[3], NULL, 16);
+ dst_len = hextoul(argv[3], NULL);
/* fall through */
case 3:
- src = simple_strtoul(argv[1], NULL, 16);
- dst = simple_strtoul(argv[2], NULL, 16);
+ src = hextoul(argv[1], NULL);
+ dst = hextoul(argv[2], NULL);
break;
default:
return CMD_RET_USAGE;
diff --git a/cmd/mbr.c b/cmd/mbr.c
index da2e3a4..e7e2298 100644
--- a/cmd/mbr.c
+++ b/cmd/mbr.c
@@ -269,7 +269,7 @@
if (argc != 4 && argc != 5)
return CMD_RET_USAGE;
- dev = (int)simple_strtoul(argv[3], &ep, 10);
+ dev = (int)dectoul(argv[3], &ep);
if (!ep || ep[0] != '\0') {
printf("'%s' is not a number\n", argv[3]);
return CMD_RET_USAGE;
diff --git a/cmd/md5sum.c b/cmd/md5sum.c
index 5ae3ddf..0f0e1d3 100644
--- a/cmd/md5sum.c
+++ b/cmd/md5sum.c
@@ -25,7 +25,7 @@
if (*dest == '*') {
u8 *ptr;
- ptr = (u8 *)simple_strtoul(dest + 1, NULL, 16);
+ ptr = (u8 *)hextoul(dest + 1, NULL);
for (i = 0; i < 16; i++)
*ptr++ = sum[i];
} else {
@@ -46,7 +46,7 @@
if (*verify_str == '*') {
u8 *ptr;
- ptr = (u8 *)simple_strtoul(verify_str + 1, NULL, 16);
+ ptr = (u8 *)hextoul(verify_str + 1, NULL);
memcpy(vsum, ptr, 16);
} else {
unsigned int i;
@@ -66,7 +66,7 @@
*nullp = '\0';
*(u8 *)(vsum + i) =
- simple_strtoul(vsum_str + (i * 2), NULL, 16);
+ hextoul(vsum_str + (i * 2), NULL);
*nullp = end;
}
}
@@ -97,8 +97,8 @@
return CMD_RET_USAGE;
}
- addr = simple_strtoul(*av++, NULL, 16);
- len = simple_strtoul(*av++, NULL, 16);
+ addr = hextoul(*av++, NULL);
+ len = hextoul(*av++, NULL);
buf = map_sysmem(addr, len);
md5_wd(buf, len, output, CHUNKSZ_MD5);
@@ -147,8 +147,8 @@
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);
buf = map_sysmem(addr, len);
md5_wd(buf, len, output, CHUNKSZ_MD5);
diff --git a/cmd/mdio.c b/cmd/mdio.c
index cfa45ad..3c74326 100644
--- a/cmd/mdio.c
+++ b/cmd/mdio.c
@@ -254,7 +254,7 @@
switch (op[0]) {
case 'w':
if (pos > 1)
- data = simple_strtoul(argv[pos--], NULL, 16);
+ data = hextoul(argv[pos--], NULL);
/* Intentional fall-through - Get reg for read and write */
case 'r':
if (pos > 1)
diff --git a/cmd/mem.c b/cmd/mem.c
index 1eb83b7..b751138 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -89,14 +89,14 @@
/* Address is specified since argc > 1
*/
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
addr += base_address;
/* If another parameter, it is the length to display.
* Length is the number of objects, not number of bytes.
*/
if (argc > 2)
- length = simple_strtoul(argv[2], NULL, 16);
+ length = hextoul(argv[2], NULL);
}
bytes = size * length;
@@ -144,7 +144,7 @@
/* Address is specified since argc > 1
*/
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
addr += base_address;
/* Get the value to write.
@@ -152,11 +152,11 @@
if (SUPPORT_64BIT_DATA)
writeval = simple_strtoull(argv[2], NULL, 16);
else
- writeval = simple_strtoul(argv[2], NULL, 16);
+ writeval = hextoul(argv[2], NULL);
/* Count ? */
if (argc == 4) {
- count = simple_strtoul(argv[3], NULL, 16);
+ count = hextoul(argv[3], NULL);
} else {
count = 1;
}
@@ -189,7 +189,7 @@
if (argc < 4)
return CMD_RET_USAGE;
- count = simple_strtoul(argv[3], NULL, 10);
+ count = dectoul(argv[3], NULL);
for (;;) {
do_mem_md (NULL, 0, 3, argv);
@@ -217,7 +217,7 @@
if (argc < 4)
return CMD_RET_USAGE;
- count = simple_strtoul(argv[3], NULL, 10);
+ count = dectoul(argv[3], NULL);
for (;;) {
do_mem_mw (NULL, 0, 3, argv);
@@ -258,13 +258,13 @@
size == 4 ? "word" :
size == 2 ? "halfword" : "byte";
- addr1 = simple_strtoul(argv[1], NULL, 16);
+ addr1 = hextoul(argv[1], NULL);
addr1 += base_address;
- addr2 = simple_strtoul(argv[2], NULL, 16);
+ addr2 = hextoul(argv[2], NULL);
addr2 += base_address;
- count = simple_strtoul(argv[3], NULL, 16);
+ count = hextoul(argv[3], NULL);
bytes = size * count;
base = buf1 = map_sysmem(addr1, bytes);
@@ -321,13 +321,13 @@
if ((size = cmd_get_data_size(argv[0], 4)) < 0)
return 1;
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
addr += base_address;
- dest = simple_strtoul(argv[2], NULL, 16);
+ dest = hextoul(argv[2], NULL);
dest += base_address;
- count = simple_strtoul(argv[3], NULL, 16);
+ count = hextoul(argv[3], NULL);
if (count == 0) {
puts ("Zero length ???\n");
@@ -405,7 +405,7 @@
if (ch == 'q')
quiet = true;
else if (ch == 'l' && isxdigit(argv[0][2]))
- limit = simple_strtoul(argv[0] + 2, NULL, 16);
+ limit = hextoul(argv[0] + 2, NULL);
else
return CMD_RET_USAGE;
argc--;
@@ -413,11 +413,11 @@
}
/* Address is specified since argc > 1 */
- addr = simple_strtoul(argv[0], NULL, 16);
+ addr = hextoul(argv[0], NULL);
addr += base_address;
/* Length is the number of objects, not number of bytes */
- length = simple_strtoul(argv[1], NULL, 16);
+ length = hextoul(argv[1], NULL);
/* Read the bytes to search for */
end = search_buf + sizeof(search_buf);
@@ -434,7 +434,7 @@
ptr += len;
continue;
} else {
- u32 val = simple_strtoul(argv[i], NULL, 16);
+ u32 val = hextoul(argv[i], NULL);
switch (size) {
case 1:
@@ -512,7 +512,7 @@
if (argc > 1) {
/* Set new base address.
*/
- base_address = simple_strtoul(argv[1], NULL, 16);
+ base_address = hextoul(argv[1], NULL);
}
/* Print the current base address.
*/
@@ -543,11 +543,11 @@
/* Address is always specified.
*/
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
/* Length is the number of objects, not number of bytes.
*/
- length = simple_strtoul(argv[2], NULL, 16);
+ length = hextoul(argv[2], NULL);
bytes = size * length;
buf = map_sysmem(addr, bytes);
@@ -636,17 +636,17 @@
/* Address is always specified.
*/
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
/* Length is the number of objects, not number of bytes.
*/
- length = simple_strtoul(argv[2], NULL, 16);
+ length = hextoul(argv[2], NULL);
/* data to write */
if (SUPPORT_64BIT_DATA)
data = simple_strtoull(argv[3], NULL, 16);
else
- data = simple_strtoul(argv[3], NULL, 16);
+ data = hextoul(argv[3], NULL);
bytes = size * length;
buf = map_sysmem(addr, bytes);
@@ -1175,7 +1175,7 @@
/* Address is specified since argc > 1
*/
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
addr += base_address;
}
@@ -1215,7 +1215,7 @@
if (SUPPORT_64BIT_DATA)
i = simple_strtoull(console_buffer, &endp, 16);
else
- i = simple_strtoul(console_buffer, &endp, 16);
+ i = hextoul(console_buffer, &endp);
nbytes = endp - console_buffer;
if (nbytes) {
/* good enough to not time out
@@ -1282,11 +1282,11 @@
if (argc < 3 || argc > 4)
return CMD_RET_USAGE;
- len = simple_strtoul(argv[2], NULL, 16);
- addr = simple_strtoul(argv[1], NULL, 16);
+ len = hextoul(argv[2], NULL);
+ addr = hextoul(argv[1], NULL);
if (argc == 4) {
- seed = simple_strtoul(argv[3], NULL, 16);
+ seed = hextoul(argv[3], NULL);
if (seed == 0) {
printf("The seed cannot be 0. Using 0xDEADBEEF.\n");
seed = 0xDEADBEEF;
diff --git a/cmd/mfsl.c b/cmd/mfsl.c
index 31f5b36..0c78720 100644
--- a/cmd/mfsl.c
+++ b/cmd/mfsl.c
@@ -23,8 +23,8 @@
if (argc < 2)
return CMD_RET_USAGE;
- fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
- blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
+ fslnum = (unsigned int)hextoul(argv[1], NULL);
+ blocking = (unsigned int)hextoul(argv[2], NULL);
if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
puts ("Bad number of FSL\n");
return CMD_RET_USAGE;
@@ -178,9 +178,9 @@
if (argc < 3)
return CMD_RET_USAGE;
- fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
- num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
- blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
+ fslnum = (unsigned int)hextoul(argv[1], NULL);
+ num = (unsigned int)hextoul(argv[2], NULL);
+ blocking = (unsigned int)hextoul(argv[3], NULL);
if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
return CMD_RET_USAGE;
@@ -332,8 +332,8 @@
if (argc < 2)
return CMD_RET_USAGE;
- reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
- val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
+ reg = (unsigned int)hextoul(argv[1], NULL);
+ val = (unsigned int)hextoul(argv[2], NULL);
switch (reg) {
case 0x1:
if (argc > 2) {
diff --git a/cmd/mii.c b/cmd/mii.c
index fe8602e..fab420e 100644
--- a/cmd/mii.c
+++ b/cmd/mii.c
@@ -267,10 +267,10 @@
unsigned char * phi)
{
char * end;
- *plo = simple_strtoul(input, &end, 16);
+ *plo = hextoul(input, &end);
if (*end == '-') {
end++;
- *phi = simple_strtoul(end, NULL, 16);
+ *phi = hextoul(end, NULL);
}
else {
*phi = *plo;
@@ -319,9 +319,9 @@
if (argc >= 4)
extract_range(argv[3], ®lo, ®hi);
if (argc >= 5)
- data = simple_strtoul(argv[4], NULL, 16);
+ data = hextoul(argv[4], NULL);
if (argc >= 6)
- mask = simple_strtoul(argv[5], NULL, 16);
+ mask = hextoul(argv[5], NULL);
}
if (addrhi > 31 && strncmp(op, "de", 2)) {
diff --git a/cmd/misc.c b/cmd/misc.c
index ef540e8..bcd8d96 100644
--- a/cmd/misc.c
+++ b/cmd/misc.c
@@ -57,9 +57,9 @@
return ret;
}
- offset = simple_strtoul(argv[1], NULL, 16);
- buf = (void *)simple_strtoul(argv[2], NULL, 16);
- size = simple_strtoul(argv[3], NULL, 16);
+ offset = hextoul(argv[1], NULL);
+ buf = (void *)hextoul(argv[2], NULL);
+ size = hextoul(argv[3], NULL);
if (op == MISC_OP_READ)
misc_op = misc_read;
diff --git a/cmd/mmc.c b/cmd/mmc.c
index b942576..c67ad76 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)
@@ -519,10 +519,10 @@
if (argc == 1) {
dev = curr_device;
} else if (argc == 2) {
- dev = simple_strtoul(argv[1], NULL, 10);
+ dev = dectoul(argv[1], NULL);
} else if (argc == 3) {
- dev = (int)simple_strtoul(argv[1], NULL, 10);
- part = (int)simple_strtoul(argv[2], NULL, 10);
+ dev = (int)dectoul(argv[1], NULL);
+ part = (int)dectoul(argv[2], NULL);
if (part > PART_ACCESS_MASK) {
printf("#part_num shouldn't be larger than %d\n",
PART_ACCESS_MASK);
@@ -572,9 +572,9 @@
if (i + 2 >= argc)
return -1;
pconf->user.enh_start =
- simple_strtoul(argv[i+1], NULL, 10);
+ dectoul(argv[i + 1], NULL);
pconf->user.enh_size =
- simple_strtoul(argv[i+2], NULL, 10);
+ dectoul(argv[i + 2], NULL);
i += 3;
} else if (!strcmp(argv[i], "wrrel")) {
if (i + 1 >= argc)
@@ -603,7 +603,7 @@
if (1 >= argc)
return -1;
- pconf->gp_part[pidx].size = simple_strtoul(argv[0], NULL, 10);
+ pconf->gp_part[pidx].size = dectoul(argv[0], NULL);
i = 1;
while (i < argc) {
@@ -721,10 +721,10 @@
if (argc != 5)
return CMD_RET_USAGE;
- dev = simple_strtoul(argv[1], NULL, 10);
- width = simple_strtoul(argv[2], NULL, 10);
- reset = simple_strtoul(argv[3], NULL, 10);
- mode = simple_strtoul(argv[4], NULL, 10);
+ dev = dectoul(argv[1], NULL);
+ width = dectoul(argv[2], NULL);
+ reset = dectoul(argv[3], NULL);
+ mode = dectoul(argv[4], NULL);
mmc = init_mmc_device(dev, false);
if (!mmc)
@@ -785,9 +785,9 @@
if (argc != 4)
return CMD_RET_USAGE;
- dev = simple_strtoul(argv[1], NULL, 10);
- bootsize = simple_strtoul(argv[2], NULL, 10);
- rpmbsize = simple_strtoul(argv[3], NULL, 10);
+ dev = dectoul(argv[1], NULL);
+ bootsize = dectoul(argv[2], NULL);
+ rpmbsize = dectoul(argv[3], NULL);
mmc = init_mmc_device(dev, false);
if (!mmc)
@@ -842,7 +842,7 @@
if (argc != 2 && argc != 3 && argc != 5)
return CMD_RET_USAGE;
- dev = simple_strtoul(argv[1], NULL, 10);
+ dev = dectoul(argv[1], NULL);
mmc = init_mmc_device(dev, false);
if (!mmc)
@@ -856,9 +856,9 @@
if (argc == 2 || argc == 3)
return mmc_partconf_print(mmc, argc == 3 ? argv[2] : NULL);
- ack = simple_strtoul(argv[2], NULL, 10);
- part_num = simple_strtoul(argv[3], NULL, 10);
- access = simple_strtoul(argv[4], NULL, 10);
+ ack = dectoul(argv[2], NULL);
+ part_num = dectoul(argv[3], NULL);
+ access = dectoul(argv[4], NULL);
/* acknowledge to be sent during boot operation */
return mmc_set_part_conf(mmc, ack, part_num, access);
@@ -879,8 +879,8 @@
if (argc != 3)
return CMD_RET_USAGE;
- dev = simple_strtoul(argv[1], NULL, 10);
- enable = simple_strtoul(argv[2], NULL, 10);
+ dev = dectoul(argv[1], NULL);
+ enable = dectoul(argv[2], NULL);
if (enable > 2) {
puts("Invalid RST_n_ENABLE value\n");
@@ -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) {
@@ -937,7 +937,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- dev = simple_strtoul(argv[1], NULL, 10);
+ dev = dectoul(argv[1], NULL);
mmc = init_mmc_device(dev, false);
if (!mmc)
diff --git a/cmd/mp.c b/cmd/mp.c
index c2b5235..8d14401 100644
--- a/cmd/mp.c
+++ b/cmd/mp.c
@@ -36,7 +36,7 @@
if (argc < 3)
return CMD_RET_USAGE;
- cpuid = simple_strtoul(argv[1], NULL, 10);
+ cpuid = dectoul(argv[1], NULL);
if (!is_core_valid(cpuid)) {
printf ("Core num: %lu is not valid\n", cpuid);
return 1;
diff --git a/cmd/mtd.c b/cmd/mtd.c
index c22478c..ad5cc98 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -285,12 +285,12 @@
goto out_put_mtd;
}
- user_addr = simple_strtoul(argv[0], NULL, 16);
+ user_addr = hextoul(argv[0], NULL);
argc--;
argv++;
}
- start_off = argc > 0 ? simple_strtoul(argv[0], NULL, 16) : 0;
+ start_off = argc > 0 ? hextoul(argv[0], NULL) : 0;
if (!mtd_is_aligned_with_min_io_size(mtd, start_off)) {
printf("Offset not aligned with a page (0x%x)\n",
mtd->writesize);
@@ -299,7 +299,7 @@
}
default_len = dump ? mtd->writesize : mtd->size;
- len = argc > 1 ? simple_strtoul(argv[1], NULL, 16) : default_len;
+ len = argc > 1 ? hextoul(argv[1], NULL) : default_len;
if (!mtd_is_aligned_with_min_io_size(mtd, len)) {
len = round_up(len, mtd->writesize);
printf("Size not on a page boundary (0x%x), rounding to 0x%llx\n",
@@ -411,8 +411,8 @@
argc -= 2;
argv += 2;
- off = argc > 0 ? simple_strtoul(argv[0], NULL, 16) : 0;
- len = argc > 1 ? simple_strtoul(argv[1], NULL, 16) : mtd->size;
+ off = argc > 0 ? hextoul(argv[0], NULL) : 0;
+ len = argc > 1 ? hextoul(argv[1], NULL) : mtd->size;
if (!mtd_is_aligned_with_block_size(mtd, off)) {
printf("Offset not aligned with a block (0x%x)\n",
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index 5cd520e..d4f381b 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -137,7 +137,7 @@
addr_str = env_get("loadaddr");
if (addr_str)
- addr = simple_strtoul(addr_str, NULL, 16);
+ addr = hextoul(addr_str, NULL);
else
addr = CONFIG_SYS_LOAD_ADDR;
diff --git a/cmd/mvebu/comphy_rx_training.c b/cmd/mvebu/comphy_rx_training.c
index 0798dec..25a9e15 100644
--- a/cmd/mvebu/comphy_rx_training.c
+++ b/cmd/mvebu/comphy_rx_training.c
@@ -25,8 +25,8 @@
return -1;
}
- cp_index = simple_strtoul(argv[1], NULL, 16);
- comphy_index = simple_strtoul(argv[2], NULL, 16);
+ cp_index = hextoul(argv[1], NULL);
+ comphy_index = hextoul(argv[2], NULL);
ret = uclass_get(UCLASS_MISC, &uc);
if (ret) {
diff --git a/cmd/nand.c b/cmd/nand.c
index 97e117a..d381053 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -424,7 +424,7 @@
return 0;
}
- dev = (int)simple_strtoul(argv[2], NULL, 10);
+ dev = (int)dectoul(argv[2], NULL);
set_dev(dev);
return 0;
@@ -543,7 +543,7 @@
if (argc < 3)
goto usage;
- off = (int)simple_strtoul(argv[2], NULL, 16);
+ off = (int)hextoul(argv[2], NULL);
ret = nand_dump(mtd, off, !strcmp(&cmd[4], ".oob"), repeat);
return ret == 0 ? 1 : 0;
@@ -559,7 +559,7 @@
if (argc < 4)
goto usage;
- addr = (ulong)simple_strtoul(argv[2], NULL, 16);
+ addr = (ulong)hextoul(argv[2], NULL);
read = strncmp(cmd, "read", 4) == 0; /* 1 = read, 0 = write */
printf("\nNAND %s: ", read ? "read" : "write");
@@ -713,7 +713,7 @@
goto usage;
while (argc > 0) {
- addr = simple_strtoul(*argv, NULL, 16);
+ addr = hextoul(*argv, NULL);
if (mtd_block_markbad(mtd, addr)) {
printf("block 0x%08lx NOT marked "
@@ -957,7 +957,7 @@
if (argc > 3)
goto usage;
if (argc == 3)
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
else
addr = CONFIG_SYS_LOAD_ADDR;
@@ -975,17 +975,17 @@
boot_device = env_get("bootdevice");
break;
case 2:
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
boot_device = env_get("bootdevice");
break;
case 3:
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
boot_device = argv[2];
break;
case 4:
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
boot_device = argv[2];
- offset = simple_strtoul(argv[3], NULL, 16);
+ offset = hextoul(argv[3], NULL);
break;
default:
#if defined(CONFIG_CMD_MTDPARTS)
@@ -1003,7 +1003,7 @@
}
bootstage_mark(BOOTSTAGE_ID_NAND_BOOT_DEVICE);
- idx = simple_strtoul(boot_device, NULL, 16);
+ idx = hextoul(boot_device, NULL);
mtd = get_nand_dev_by_index(idx);
if (!mtd) {
diff --git a/cmd/net.c b/cmd/net.c
index 76c7e75..651c141 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -205,7 +205,7 @@
/* pre-set image_load_addr */
s = env_get("loadaddr");
if (s != NULL)
- image_load_addr = simple_strtoul(s, NULL, 16);
+ image_load_addr = hextoul(s, NULL);
switch (argc) {
case 1:
@@ -220,7 +220,7 @@
* form must be written in a format which can not be
* mis-interpreted as a valid number.
*/
- addr = simple_strtoul(argv[1], &end, 16);
+ addr = hextoul(argv[1], &end);
if (end == (argv[1] + strlen(argv[1]))) {
image_load_addr = addr;
/* refresh bootfile name from env */
@@ -234,7 +234,7 @@
break;
case 3:
- image_load_addr = simple_strtoul(argv[1], NULL, 16);
+ image_load_addr = hextoul(argv[1], NULL);
net_boot_file_name_explicit = true;
copy_filename(net_boot_file_name, argv[2],
sizeof(net_boot_file_name));
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index d14ba10..ddc715b 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -358,7 +358,7 @@
s = env_get(varname);
if (s)
- value = simple_strtoul(s, &endp, 16);
+ value = hextoul(s, &endp);
if (!s || endp == s)
return default_val;
@@ -423,7 +423,7 @@
* the size. Otherwise we echo it as part of the
* message.
*/
- i = simple_strtoul(argv[argc - 1], &endptr, 10);
+ i = dectoul(argv[argc - 1], &endptr);
if (*endptr != '\0') { /* no size */
size = CONFIG_SYS_CBSIZE - 1;
} else { /* size given */
@@ -984,7 +984,7 @@
case 's': /* size given */
if (--argc <= 0)
return cmd_usage(cmdtp);
- size = simple_strtoul(*++argv, NULL, 16);
+ size = hextoul(*++argv, NULL);
goto NXTARG;
case 't': /* text format */
if (fmt++)
@@ -1001,7 +1001,7 @@
if (argc < 1)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[0], NULL, 16);
+ addr = hextoul(argv[0], NULL);
ptr = map_sysmem(addr, size);
if (size)
@@ -1140,11 +1140,11 @@
if (sep != '\n' && crlf_is_lf )
crlf_is_lf = 0;
- addr = simple_strtoul(argv[0], NULL, 16);
+ addr = hextoul(argv[0], NULL);
ptr = map_sysmem(addr, 0);
if (argc >= 2 && strcmp(argv[1], "-")) {
- size = simple_strtoul(argv[1], NULL, 16);
+ size = hextoul(argv[1], NULL);
} else if (chk) {
puts("## Error: external checksum format must pass size\n");
return CMD_RET_FAILURE;
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index d5e9382..676bbda 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -471,12 +471,12 @@
argc--;
argv++;
- addr = simple_strtoul(argv[0], &ep, 16);
+ addr = hextoul(argv[0], &ep);
if (*ep != ':')
return CMD_RET_USAGE;
/* 0 should be allowed for delete */
- size = simple_strtoul(++ep, NULL, 16);
+ size = hextoul(++ep, NULL);
value_on_memory = true;
} else if (!strcmp(argv[0], "-v")) {
diff --git a/cmd/onenand.c b/cmd/onenand.c
index 216458b..852ed5c 100644
--- a/cmd/onenand.c
+++ b/cmd/onenand.c
@@ -398,7 +398,7 @@
if ((s != NULL) && (!strcmp(s, ".oob")))
oob = 1;
- addr = (ulong)simple_strtoul(argv[1], NULL, 16);
+ addr = (ulong)hextoul(argv[1], NULL);
printf("\nOneNAND read: ");
if (arg_off_size_onenand(argc - 2, argv + 2, &ofs, &len) != 0)
@@ -425,7 +425,7 @@
if (strncmp(argv[0] + 6, "yaffs", 5) == 0)
withoob = 1;
- addr = (ulong)simple_strtoul(argv[1], NULL, 16);
+ addr = (ulong)hextoul(argv[1], NULL);
printf("\nOneNAND write: ");
if (arg_off_size_onenand(argc - 2, argv + 2, &ofs, &len) != 0)
@@ -512,7 +512,7 @@
return CMD_RET_USAGE;
s = strchr(argv[0], '.');
- ofs = (int)simple_strtoul(argv[1], NULL, 16);
+ ofs = (int)hextoul(argv[1], NULL);
if (s != NULL && strcmp(s, ".oob") == 0)
ret = onenand_dump(mtd, ofs, 1);
@@ -535,7 +535,7 @@
return CMD_RET_USAGE;
while (argc > 0) {
- addr = simple_strtoul(*argv, NULL, 16);
+ addr = hextoul(*argv, NULL);
if (mtd_block_markbad(mtd, addr)) {
printf("block 0x%08lx NOT marked "
diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
index 0d6b1cb..e0e44bb 100644
--- a/cmd/optee_rpmb.c
+++ b/cmd/optee_rpmb.c
@@ -195,7 +195,7 @@
return CMD_RET_USAGE;
name = argv[1];
- bytes = simple_strtoul(argv[2], &endp, 10);
+ bytes = dectoul(argv[2], &endp);
if (*endp && *endp != '\n')
return CMD_RET_USAGE;
diff --git a/cmd/osd.c b/cmd/osd.c
index 703d640..c8c62d4 100644
--- a/cmd/osd.c
+++ b/cmd/osd.c
@@ -99,10 +99,10 @@
return CMD_RET_FAILURE;
}
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
hexstr = argv[3];
- count = (argc > 4) ? simple_strtoul(argv[4], NULL, 16) : 1;
+ count = (argc > 4) ? hextoul(argv[4], NULL) : 1;
buflen = strlen(hexstr) / 2;
@@ -148,9 +148,9 @@
return CMD_RET_FAILURE;
}
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
- color = simple_strtoul(argv[3], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
+ color = hextoul(argv[3], NULL);
text = argv[4];
res = video_osd_print(osd_cur, x, y, color, text);
@@ -176,8 +176,8 @@
return CMD_RET_FAILURE;
}
- x = simple_strtoul(argv[1], NULL, 16);
- y = simple_strtoul(argv[2], NULL, 16);
+ x = hextoul(argv[1], NULL);
+ y = hextoul(argv[2], NULL);
res = video_osd_set_size(osd_cur, x, y);
if (res) {
@@ -211,7 +211,7 @@
int i, res;
/* show specific OSD */
- i = simple_strtoul(argv[1], NULL, 10);
+ i = dectoul(argv[1], NULL);
res = uclass_get_device_by_seq(UCLASS_VIDEO_OSD, i, &osd);
if (res) {
@@ -240,7 +240,7 @@
osd_no = -1;
printf("Current osd is %d\n", osd_no);
} else {
- osd_no = simple_strtoul(argv[1], NULL, 10);
+ osd_no = dectoul(argv[1], NULL);
printf("Setting osd to %d\n", osd_no);
res = cmd_osd_set_osd_num(osd_no);
diff --git a/cmd/pcap.c b/cmd/pcap.c
index d0172f3..ab5c1a7 100644
--- a/cmd/pcap.c
+++ b/cmd/pcap.c
@@ -18,8 +18,8 @@
if (argc != 3)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[1], NULL, 16);
- size = simple_strtoul(argv[2], NULL, 10);
+ addr = hextoul(argv[1], NULL);
+ size = dectoul(argv[2], NULL);
return pcap_init(addr, size) ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
}
diff --git a/cmd/pci.c b/cmd/pci.c
index e53b7c8..22de942 100644
--- a/cmd/pci.c
+++ b/cmd/pci.c
@@ -470,14 +470,14 @@
if (name[i] == '.') {
memcpy(cnum, &name[iold], i - iold);
cnum[i - iold] = '\0';
- bdfs[n++] = simple_strtoul(cnum, NULL, 16);
+ bdfs[n++] = hextoul(cnum, NULL);
iold = i + 1;
}
}
strcpy(cnum, &name[iold]);
if (n == 0)
n = 1;
- bdfs[n] = simple_strtoul(cnum, NULL, 16);
+ bdfs[n] = hextoul(cnum, NULL);
return PCI_BDF(bdfs[0], bdfs[1], bdfs[2]);
}
@@ -588,7 +588,7 @@
#endif
else {
char *endp;
- i = simple_strtoul(console_buffer, &endp, 16);
+ i = hextoul(console_buffer, &endp);
nbytes = endp - console_buffer;
if (nbytes) {
/* good enough to not time out
@@ -683,9 +683,9 @@
cmd_size = cmd_get_data_size(argv[1], 4);
size = (cmd_size == 4) ? PCI_SIZE_32 : cmd_size - 1;
if (argc > 3)
- addr = simple_strtoul(argv[3], NULL, 16);
+ addr = hextoul(argv[3], NULL);
if (argc > 4)
- value = simple_strtoul(argv[4], NULL, 16);
+ value = hextoul(argv[4], NULL);
case 'h': /* header */
#ifdef CONFIG_DM_PCI
case 'b': /* bars */
@@ -709,7 +709,7 @@
argc--;
}
if (argc > 1)
- busnum = simple_strtoul(argv[1], NULL, 16);
+ busnum = hextoul(argv[1], NULL);
}
#ifdef CONFIG_DM_PCI
ret = uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus);
diff --git a/cmd/pstore.c b/cmd/pstore.c
index 5656bae..9fac8c7 100644
--- a/cmd/pstore.c
+++ b/cmd/pstore.c
@@ -172,26 +172,26 @@
/* Address is specified since argc > 2
*/
- pstore_addr = simple_strtoul(argv[1], NULL, 16);
+ pstore_addr = hextoul(argv[1], NULL);
/* Length is specified since argc > 2
*/
- pstore_length = simple_strtoul(argv[2], NULL, 16);
+ pstore_length = hextoul(argv[2], NULL);
if (argc > 3)
- pstore_record_size = simple_strtoul(argv[3], NULL, 16);
+ pstore_record_size = hextoul(argv[3], NULL);
if (argc > 4)
- pstore_console_size = simple_strtoul(argv[4], NULL, 16);
+ pstore_console_size = hextoul(argv[4], NULL);
if (argc > 5)
- pstore_ftrace_size = simple_strtoul(argv[5], NULL, 16);
+ pstore_ftrace_size = hextoul(argv[5], NULL);
if (argc > 6)
- pstore_pmsg_size = simple_strtoul(argv[6], NULL, 16);
+ pstore_pmsg_size = hextoul(argv[6], NULL);
if (argc > 7)
- pstore_ecc_size = simple_strtoul(argv[7], NULL, 16);
+ pstore_ecc_size = hextoul(argv[7], NULL);
if (pstore_length < (pstore_record_size + pstore_console_size
+ pstore_ftrace_size + pstore_pmsg_size)) {
@@ -279,7 +279,7 @@
- pstore_ftrace_size - pstore_console_size;
if (argc > 2) {
- ptr += simple_strtoul(argv[2], NULL, 10)
+ ptr += dectoul(argv[2], NULL)
* pstore_record_size;
ptr_end = ptr + pstore_record_size;
}
diff --git a/cmd/pwm.c b/cmd/pwm.c
index e1f97c7..87d840a 100644
--- a/cmd/pwm.c
+++ b/cmd/pwm.c
@@ -66,7 +66,7 @@
return CMD_RET_USAGE;
}
- pwm_dev = simple_strtoul(str_pwm, NULL, 10);
+ pwm_dev = dectoul(str_pwm, NULL);
ret = uclass_get_device(UCLASS_PWM, pwm_dev, &dev);
if (ret) {
printf("pwm: '%s' not found\n", str_pwm);
@@ -74,22 +74,22 @@
}
str_channel = *argv;
- channel = simple_strtoul(str_channel, NULL, 10);
+ channel = dectoul(str_channel, NULL);
argc--;
argv++;
if (sub_cmd == PWM_SET_INVERT) {
str_enable = *argv;
- pwm_enable = simple_strtoul(str_enable, NULL, 10);
+ pwm_enable = dectoul(str_enable, NULL);
ret = pwm_set_invert(dev, channel, pwm_enable);
} else if (sub_cmd == PWM_SET_CONFIG) {
str_period = *argv;
argc--;
argv++;
- period_ns = simple_strtoul(str_period, NULL, 10);
+ period_ns = dectoul(str_period, NULL);
str_duty = *argv;
- duty_ns = simple_strtoul(str_duty, NULL, 10);
+ duty_ns = dectoul(str_duty, NULL);
ret = pwm_set_config(dev, channel, period_ns, duty_ns);
} else if (sub_cmd == PWM_SET_ENABLE) {
diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 9a30629..067c24e 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -351,7 +351,7 @@
int err;
/* Get the main fdt and map it */
- fdt_addr = simple_strtoul(env_get("fdt_addr_r"), NULL, 16);
+ fdt_addr = hextoul(env_get("fdt_addr_r"), NULL);
working_fdt = map_sysmem(fdt_addr, 0);
err = fdt_check_header(working_fdt);
if (err)
@@ -364,7 +364,7 @@
return;
}
- fdtoverlay_addr = simple_strtoul(fdtoverlay_addr_env, NULL, 16);
+ fdtoverlay_addr = hextoul(fdtoverlay_addr_env, NULL);
/* Cycle over the overlay files and apply them in order */
do {
diff --git a/cmd/qfw.c b/cmd/qfw.c
index e6a9fdb..eb6a552 100644
--- a/cmd/qfw.c
+++ b/cmd/qfw.c
@@ -120,7 +120,7 @@
env = env_get("loadaddr");
load_addr = env ?
- (void *)simple_strtoul(env, NULL, 16) :
+ (void *)hextoul(env, NULL) :
#ifdef CONFIG_LOADADDR
(void *)CONFIG_LOADADDR;
#else
@@ -129,7 +129,7 @@
env = env_get("ramdiskaddr");
initrd_addr = env ?
- (void *)simple_strtoul(env, NULL, 16) :
+ (void *)hextoul(env, NULL) :
#ifdef CONFIG_RAMDISK_ADDR
(void *)CONFIG_RAMDISK_ADDR;
#else
@@ -137,10 +137,10 @@
#endif
if (argc == 2) {
- load_addr = (void *)simple_strtoul(argv[0], NULL, 16);
- initrd_addr = (void *)simple_strtoul(argv[1], NULL, 16);
+ load_addr = (void *)hextoul(argv[0], NULL);
+ initrd_addr = (void *)hextoul(argv[1], NULL);
} else if (argc == 1) {
- load_addr = (void *)simple_strtoul(argv[0], NULL, 16);
+ load_addr = (void *)hextoul(argv[0], NULL);
}
if (!load_addr || !initrd_addr) {
diff --git a/cmd/read.c b/cmd/read.c
index 34f53f9..99c7e38 100644
--- a/cmd/read.c
+++ b/cmd/read.c
@@ -30,13 +30,13 @@
return 1;
}
- dev = (int)simple_strtoul(argv[2], &ep, 16);
+ dev = (int)hextoul(argv[2], &ep);
if (*ep) {
if (*ep != ':') {
printf("Invalid block device %s\n", argv[2]);
return 1;
}
- part = (int)simple_strtoul(++ep, NULL, 16);
+ part = (int)hextoul(++ep, NULL);
}
dev_desc = blk_get_dev(argv[1], dev);
@@ -45,9 +45,9 @@
return 1;
}
- addr = (void *)simple_strtoul(argv[3], NULL, 16);
- blk = simple_strtoul(argv[4], NULL, 16);
- cnt = simple_strtoul(argv[5], NULL, 16);
+ addr = (void *)hextoul(argv[3], NULL);
+ blk = hextoul(argv[4], NULL);
+ cnt = hextoul(argv[5], NULL);
if (part != 0) {
if (part_get_info(dev_desc, part, &part_info)) {
diff --git a/cmd/reiser.c b/cmd/reiser.c
index 3db926f..707167f 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -90,7 +90,7 @@
case 3:
addr_str = env_get("loadaddr");
if (addr_str != NULL) {
- addr = simple_strtoul (addr_str, NULL, 16);
+ addr = hextoul(addr_str, NULL);
} else {
addr = CONFIG_SYS_LOAD_ADDR;
}
@@ -98,19 +98,19 @@
count = 0;
break;
case 4:
- addr = simple_strtoul (argv[3], NULL, 16);
+ addr = hextoul(argv[3], NULL);
filename = env_get("bootfile");
count = 0;
break;
case 5:
- addr = simple_strtoul (argv[3], NULL, 16);
+ addr = hextoul(argv[3], NULL);
filename = argv[4];
count = 0;
break;
case 6:
- addr = simple_strtoul (argv[3], NULL, 16);
+ addr = hextoul(argv[3], NULL);
filename = argv[4];
- count = simple_strtoul (argv[5], NULL, 16);
+ count = hextoul(argv[5], NULL);
break;
default:
diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
index b3ddceb..ca3b436 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -84,7 +84,7 @@
return 0;
printf("Few Remote Processors failed to be initialized\n");
} else if (argc == 2) {
- id = (int)simple_strtoul(argv[1], NULL, 10);
+ id = (int)dectoul(argv[1], NULL);
if (!rproc_dev_init(id))
return 0;
printf("Remote Processor %d failed to be initialized\n", id);
@@ -129,10 +129,10 @@
if (argc != 4)
return CMD_RET_USAGE;
- id = (int)simple_strtoul(argv[1], NULL, 10);
- addr = simple_strtoul(argv[2], NULL, 16);
+ id = (int)dectoul(argv[1], NULL);
+ addr = hextoul(argv[2], NULL);
- size = simple_strtoul(argv[3], NULL, 16);
+ size = hextoul(argv[3], NULL);
if (!size) {
printf("\t Expect some size??\n");
@@ -167,7 +167,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- id = (int)simple_strtoul(argv[1], NULL, 10);
+ id = (int)dectoul(argv[1], NULL);
if (!strcmp(argv[0], "start")) {
ret = rproc_start(id);
diff --git a/cmd/rng.c b/cmd/rng.c
index 9747c11..1ad5a09 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -24,7 +24,7 @@
}
if (argc >= 2)
- n = simple_strtoul(argv[1], NULL, 16);
+ n = hextoul(argv[1], NULL);
buf = malloc(n);
if (!buf) {
diff --git a/cmd/rtc.c b/cmd/rtc.c
index b4f61b2..75d4b64 100644
--- a/cmd/rtc.c
+++ b/cmd/rtc.c
@@ -18,13 +18,13 @@
if (argc < 2 || argc > 3)
return CMD_RET_USAGE;
- reg = simple_strtoul(argv[0], NULL, 16);
- len = simple_strtoul(argv[1], NULL, 16);
+ reg = hextoul(argv[0], NULL);
+ len = hextoul(argv[1], NULL);
if (argc == 3) {
u8 *addr;
- addr = map_sysmem(simple_strtoul(argv[2], NULL, 16), len);
+ addr = map_sysmem(hextoul(argv[2], NULL), len);
ret = dm_rtc_read(dev, reg, addr, len);
unmap_sysmem(addr);
if (ret) {
@@ -59,13 +59,13 @@
if (argc < 2 || argc > 3)
return CMD_RET_USAGE;
- reg = simple_strtoul(argv[0], NULL, 16);
+ reg = hextoul(argv[0], NULL);
if (argc == 3) {
u8 *addr;
- len = simple_strtoul(argv[1], NULL, 16);
- addr = map_sysmem(simple_strtoul(argv[2], NULL, 16), len);
+ len = hextoul(argv[1], NULL);
+ addr = map_sysmem(hextoul(argv[2], NULL), len);
ret = dm_rtc_write(dev, reg, addr, len);
unmap_sysmem(addr);
if (ret) {
@@ -130,7 +130,7 @@
idx = curr_rtc;
if (!strcmp(argv[0], "dev") && argc >= 2)
- idx = simple_strtoul(argv[1], NULL, 10);
+ idx = dectoul(argv[1], NULL);
ret = uclass_get_device(UCLASS_RTC, idx, &dev);
if (ret) {
diff --git a/cmd/sata.c b/cmd/sata.c
index aa396c1..76da190 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -88,7 +88,7 @@
int devnum = 0;
if (argc == 3)
- devnum = (int)simple_strtoul(argv[2], NULL, 10);
+ devnum = (int)dectoul(argv[2], NULL);
if (!strcmp(argv[1], "stop"))
return sata_remove(devnum);
diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index 1eb67e2..05d6558 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -49,7 +49,7 @@
int len;
char *str;
- addr = simple_strtoul(&s[1], NULL, 16);
+ addr = hextoul(&s[1], NULL);
switch (w) {
case 1:
p = map_sysmem(addr, sizeof(uchar));
@@ -94,7 +94,7 @@
} else {
if (w == CMD_DATA_SIZE_STR)
return -EINVAL;
- arg.ival = simple_strtoul(s, NULL, 16);
+ arg.ival = hextoul(s, NULL);
}
*argp = arg;
diff --git a/cmd/sf.c b/cmd/sf.c
index 46346fb..eac27ed 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -54,7 +54,7 @@
++arg;
}
- len_arg = simple_strtoul(arg, &ep, 16);
+ len_arg = hextoul(arg, &ep);
if (ep == arg || *ep != '\0')
return -1;
@@ -119,7 +119,7 @@
return -1;
}
if (argc >= 4) {
- mode = simple_strtoul(argv[3], &endp, 16);
+ mode = hextoul(argv[3], &endp);
if (*argv[3] == 0 || *endp != 0)
return -1;
}
@@ -272,7 +272,7 @@
if (argc < 3)
return -1;
- addr = simple_strtoul(argv[1], &endp, 16);
+ addr = hextoul(argv[1], &endp);
if (*argv[1] == 0 || *endp != 0)
return -1;
@@ -517,10 +517,10 @@
if (argc < 3)
return -1;
- offset = simple_strtoul(argv[1], &endp, 16);
+ offset = hextoul(argv[1], &endp);
if (*argv[1] == 0 || *endp != 0)
return -1;
- len = simple_strtoul(argv[2], &endp, 16);
+ len = hextoul(argv[2], &endp);
if (*argv[2] == 0 || *endp != 0)
return -1;
diff --git a/cmd/sleep.c b/cmd/sleep.c
index 1fff400..c741b4a 100644
--- a/cmd/sleep.c
+++ b/cmd/sleep.c
@@ -20,7 +20,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
+ delay = dectoul(argv[1], NULL) * CONFIG_SYS_HZ;
frpart = strchr(argv[1], '.');
diff --git a/cmd/smccc.c b/cmd/smccc.c
index 0ff9a08..f527181 100644
--- a/cmd/smccc.c
+++ b/cmd/smccc.c
@@ -28,15 +28,15 @@
if (argc < 2)
return CMD_RET_USAGE;
- fid = simple_strtoul(argv[1], NULL, 16);
+ fid = hextoul(argv[1], NULL);
- a1 = argc > 2 ? simple_strtoul(argv[2], NULL, 16) : 0;
- a2 = argc > 3 ? simple_strtoul(argv[3], NULL, 16) : 0;
- a3 = argc > 4 ? simple_strtoul(argv[4], NULL, 16) : 0;
- a4 = argc > 5 ? simple_strtoul(argv[5], NULL, 16) : 0;
- a5 = argc > 6 ? simple_strtoul(argv[6], NULL, 16) : 0;
- a6 = argc > 7 ? simple_strtoul(argv[7], NULL, 16) : 0;
- a7 = argc > 8 ? simple_strtoul(argv[8], NULL, 16) : 0;
+ a1 = argc > 2 ? hextoul(argv[2], NULL) : 0;
+ a2 = argc > 3 ? hextoul(argv[3], NULL) : 0;
+ a3 = argc > 4 ? hextoul(argv[4], NULL) : 0;
+ a4 = argc > 5 ? hextoul(argv[5], NULL) : 0;
+ a5 = argc > 6 ? hextoul(argv[6], NULL) : 0;
+ a6 = argc > 7 ? hextoul(argv[7], NULL) : 0;
+ a7 = argc > 8 ? hextoul(argv[8], NULL) : 0;
if (!strcmp(argv[0], "smc"))
arm_smccc_smc(fid, a1, a2, a3, a4, a5, a6, a7, &res);
diff --git a/cmd/sound.c b/cmd/sound.c
index fdcde36..f82f2aa 100644
--- a/cmd/sound.c
+++ b/cmd/sound.c
@@ -41,9 +41,9 @@
int freq = 400;
if (argc > 1)
- msec = simple_strtoul(argv[1], NULL, 10);
+ msec = dectoul(argv[1], NULL);
if (argc > 2)
- freq = simple_strtoul(argv[2], NULL, 10);
+ freq = dectoul(argv[2], NULL);
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
if (!ret)
diff --git a/cmd/source.c b/cmd/source.c
index 71f7152..81e015b 100644
--- a/cmd/source.c
+++ b/cmd/source.c
@@ -179,7 +179,7 @@
fit_uname, addr);
#endif
} else {
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
debug("* source: cmdline image address = 0x%08lx\n", addr);
}
diff --git a/cmd/spi.c b/cmd/spi.c
index 4aea191..bdbdbac 100644
--- a/cmd/spi.c
+++ b/cmd/spi.c
@@ -114,20 +114,20 @@
{
if (argc >= 2) {
mode = CONFIG_DEFAULT_SPI_MODE;
- bus = simple_strtoul(argv[1], &cp, 10);
+ bus = dectoul(argv[1], &cp);
if (*cp == ':') {
- cs = simple_strtoul(cp+1, &cp, 10);
+ cs = dectoul(cp + 1, &cp);
} else {
cs = bus;
bus = CONFIG_DEFAULT_SPI_BUS;
}
if (*cp == '.')
- mode = simple_strtoul(cp+1, &cp, 10);
+ mode = dectoul(cp + 1, &cp);
if (*cp == '@')
- freq = simple_strtoul(cp+1, &cp, 10);
+ freq = dectoul(cp + 1, &cp);
}
if (argc >= 3)
- bitlen = simple_strtoul(argv[2], NULL, 10);
+ bitlen = dectoul(argv[2], NULL);
if (argc >= 4) {
cp = argv[3];
for(j = 0; *cp; j++, cp++) {
diff --git a/cmd/strings.c b/cmd/strings.c
index 85fdc34..bf348af 100644
--- a/cmd/strings.c
+++ b/cmd/strings.c
@@ -18,9 +18,9 @@
return CMD_RET_USAGE;
if ((flag & CMD_FLAG_REPEAT) == 0) {
- start_addr = (char *)simple_strtoul(argv[1], NULL, 16);
+ start_addr = (char *)hextoul(argv[1], NULL);
if (argc > 2)
- last_addr = (char *)simple_strtoul(argv[2], NULL, 16);
+ last_addr = (char *)hextoul(argv[2], NULL);
else
last_addr = (char *)-1;
}
diff --git a/cmd/ti/ddr3.c b/cmd/ti/ddr3.c
index 6b43a73..be937a7 100644
--- a/cmd/ti/ddr3.c
+++ b/cmd/ti/ddr3.c
@@ -290,8 +290,8 @@
return CMD_RET_FAILURE;
}
- start_addr = simple_strtoul(argv[2], NULL, 16);
- ecc_err = simple_strtoul(argv[3], NULL, 16);
+ start_addr = hextoul(argv[2], NULL);
+ ecc_err = hextoul(argv[3], NULL);
if (!is_addr_valid(start_addr)) {
puts("Invalid address. Please enter ECC supported address!\n");
@@ -306,8 +306,8 @@
((argc == 5) && (strncmp(argv[1], "compare", 8) == 0))))
return cmd_usage(cmdtp);
- start_addr = simple_strtoul(argv[2], NULL, 16);
- end_addr = simple_strtoul(argv[3], NULL, 16);
+ start_addr = hextoul(argv[2], NULL);
+ end_addr = hextoul(argv[3], NULL);
if ((start_addr < CONFIG_SYS_SDRAM_BASE) ||
(start_addr > (CONFIG_SYS_SDRAM_BASE +
@@ -321,7 +321,7 @@
puts("Please wait ...\n");
if (argc == 5) {
- size = simple_strtoul(argv[4], NULL, 16);
+ size = hextoul(argv[4], NULL);
ddr_memory_compare(start_addr, end_addr, size);
} else {
ddr_memory_test(start_addr, end_addr, 0);
diff --git a/cmd/ti/pd.c b/cmd/ti/pd.c
index 9e820b8..008668f 100644
--- a/cmd/ti/pd.c
+++ b/cmd/ti/pd.c
@@ -119,8 +119,8 @@
if (!data)
return CMD_RET_FAILURE;
- psc_id = simple_strtoul(argv[1], NULL, 10);
- lpsc_id = simple_strtoul(argv[2], NULL, 10);
+ psc_id = dectoul(argv[1], NULL);
+ lpsc_id = dectoul(argv[2], NULL);
for (i = 0; i < data->num_lpsc; i++) {
lpsc = &data->lpsc[i];
diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
index 5099cbd..2b643f9 100644
--- a/cmd/tlv_eeprom.c
+++ b/cmd/tlv_eeprom.c
@@ -751,7 +751,7 @@
/* Convert string to binary */
for (i = 0, p = (char *)string; i < 6; i++) {
- buf[i] = p ? simple_strtoul(p, &end, 16) : 0;
+ buf[i] = p ? hextoul(p, &end) : 0;
if (p)
p = (*end) ? end + 1 : end;
}
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index 88c9e08..1d5442c 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -68,7 +68,7 @@
for (i = 0; i < length; i += 2) {
byte[0] = bytes[i];
byte[1] = bytes[i + 1];
- data[i / 2] = (u8)simple_strtoul(byte, NULL, 16);
+ data[i / 2] = (u8)hextoul(byte, NULL);
}
if (count_ptr)
@@ -302,7 +302,7 @@
int rc;
if (argc == 2) {
- num = simple_strtoul(argv[1], NULL, 10);
+ num = dectoul(argv[1], NULL);
rc = tpm_set_device(num);
if (rc)
diff --git a/cmd/trace.c b/cmd/trace.c
index 4ce47c7..2e3ee1d 100644
--- a/cmd/trace.c
+++ b/cmd/trace.c
@@ -21,8 +21,8 @@
*buff_size);
*buff_ptr = env_get_ulong("profoffset", 16, 0);
} else {
- *buff_size = simple_strtoul(argv[3], NULL, 16);
- *buff = map_sysmem(simple_strtoul(argv[2], NULL, 16),
+ *buff_size = hextoul(argv[3], NULL);
+ *buff = map_sysmem(hextoul(argv[2], NULL),
*buff_size);
*buff_ptr = 0;
};
diff --git a/cmd/tsi148.c b/cmd/tsi148.c
index 2eae14f..0d849d9 100644
--- a/cmd/tsi148.c
+++ b/cmd/tsi148.c
@@ -392,15 +392,15 @@
if (argc > 1)
cmd = argv[1][0];
if (argc > 2)
- addr1 = simple_strtoul(argv[2], NULL, 16);
+ addr1 = hextoul(argv[2], NULL);
if (argc > 3)
- addr2 = simple_strtoul(argv[3], NULL, 16);
+ addr2 = hextoul(argv[3], NULL);
if (argc > 4)
- size = simple_strtoul(argv[4], NULL, 16);
+ size = hextoul(argv[4], NULL);
if (argc > 5)
- vam = simple_strtoul(argv[5], NULL, 16);
+ vam = hextoul(argv[5], NULL);
if (argc > 6)
- vdw = simple_strtoul(argv[6], NULL, 16);
+ vdw = hextoul(argv[6], NULL);
switch (cmd) {
case 'c':
diff --git a/cmd/ubi.c b/cmd/ubi.c
index cb14e3e..fe8ac58 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -661,8 +661,8 @@
return 1;
}
- addr = simple_strtoul(argv[2], NULL, 16);
- size = simple_strtoul(argv[4], NULL, 16);
+ addr = hextoul(argv[2], NULL);
+ size = hextoul(argv[4], NULL);
if (strlen(argv[1]) == 10 &&
strncmp(argv[1] + 5, ".part", 5) == 0) {
@@ -671,7 +671,7 @@
(void *)addr, size);
} else {
size_t full_size;
- full_size = simple_strtoul(argv[5], NULL, 16);
+ full_size = hextoul(argv[5], NULL);
ret = ubi_volume_begin_write(argv[3],
(void *)addr, size, full_size);
}
@@ -691,13 +691,13 @@
/* E.g., read volume size */
if (argc == 5) {
- size = simple_strtoul(argv[4], NULL, 16);
+ size = hextoul(argv[4], NULL);
argc--;
}
/* E.g., read volume */
if (argc == 4) {
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
argc--;
}
diff --git a/cmd/ubifs.c b/cmd/ubifs.c
index a26b653..7a620c5 100644
--- a/cmd/ubifs.c
+++ b/cmd/ubifs.c
@@ -122,14 +122,14 @@
if (argc < 3)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[1], &endp, 16);
+ addr = hextoul(argv[1], &endp);
if (endp == argv[1])
return CMD_RET_USAGE;
filename = argv[2];
if (argc == 4) {
- size = simple_strtoul(argv[3], &endp, 16);
+ size = hextoul(argv[3], &endp);
if (endp == argv[3])
return CMD_RET_USAGE;
}
diff --git a/cmd/ufs.c b/cmd/ufs.c
index 858cd49..d4a1e66 100644
--- a/cmd/ufs.c
+++ b/cmd/ufs.c
@@ -16,7 +16,7 @@
if (argc >= 2) {
if (!strcmp(argv[1], "init")) {
if (argc == 3) {
- dev = simple_strtoul(argv[2], NULL, 10);
+ dev = dectoul(argv[2], NULL);
ret = ufs_probe_dev(dev);
if (ret)
return CMD_RET_FAILURE;
diff --git a/cmd/universe.c b/cmd/universe.c
index 5ff47dd..fb3a32d 100644
--- a/cmd/universe.c
+++ b/cmd/universe.c
@@ -307,17 +307,17 @@
if (argc > 1)
cmd = argv[1][0];
if (argc > 2)
- addr1 = simple_strtoul(argv[2], NULL, 16);
+ addr1 = hextoul(argv[2], NULL);
if (argc > 3)
- addr2 = simple_strtoul(argv[3], NULL, 16);
+ addr2 = hextoul(argv[3], NULL);
if (argc > 4)
- size = simple_strtoul(argv[4], NULL, 16);
+ size = hextoul(argv[4], NULL);
if (argc > 5)
- vam = simple_strtoul(argv[5], NULL, 16);
+ vam = hextoul(argv[5], NULL);
if (argc > 6)
- pms = simple_strtoul(argv[6], NULL, 16);
+ pms = hextoul(argv[6], NULL);
if (argc > 7)
- vdw = simple_strtoul(argv[7], NULL, 16);
+ vdw = hextoul(argv[7], NULL);
switch (cmd) {
case 'i': /* init */
diff --git a/cmd/unlz4.c b/cmd/unlz4.c
index 4ae7f34..323ab46 100644
--- a/cmd/unlz4.c
+++ b/cmd/unlz4.c
@@ -18,9 +18,9 @@
switch (argc) {
case 4:
- src = simple_strtoul(argv[1], NULL, 16);
- dst = simple_strtoul(argv[2], NULL, 16);
- dst_len = simple_strtoul(argv[3], NULL, 16);
+ src = hextoul(argv[1], NULL);
+ dst = hextoul(argv[2], NULL);
+ dst_len = hextoul(argv[3], NULL);
break;
default:
return CMD_RET_USAGE;
diff --git a/cmd/unzip.c b/cmd/unzip.c
index 9b28328..3d1f5f3 100644
--- a/cmd/unzip.c
+++ b/cmd/unzip.c
@@ -18,11 +18,11 @@
switch (argc) {
case 4:
- dst_len = simple_strtoul(argv[3], NULL, 16);
+ dst_len = hextoul(argv[3], NULL);
/* fall through */
case 3:
- src = simple_strtoul(argv[1], NULL, 16);
- dst = simple_strtoul(argv[2], NULL, 16);
+ src = hextoul(argv[1], NULL);
+ dst = hextoul(argv[2], NULL);
break;
default:
return CMD_RET_USAGE;
@@ -60,11 +60,11 @@
if (ret < 0)
return CMD_RET_FAILURE;
- addr = (unsigned char *)simple_strtoul(argv[3], NULL, 16);
- length = simple_strtoul(argv[4], NULL, 16);
+ addr = (unsigned char *)hextoul(argv[3], NULL);
+ length = hextoul(argv[4], NULL);
if (5 < argc) {
- writebuf = simple_strtoul(argv[5], NULL, 16);
+ writebuf = hextoul(argv[5], NULL);
if (6 < argc) {
startoffs = simple_strtoull(argv[6], NULL, 16);
if (7 < argc)
diff --git a/cmd/usb.c b/cmd/usb.c
index b9ec29a..3d87376 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -690,7 +690,7 @@
* have multiple controllers and the device numbering
* starts at 1 on each bus.
*/
- i = simple_strtoul(argv[2], NULL, 10);
+ i = dectoul(argv[2], NULL);
printf("config for device %d\n", i);
udev = usb_find_device(i);
if (udev == NULL) {
@@ -706,13 +706,13 @@
if (strncmp(argv[1], "test", 4) == 0) {
if (argc < 5)
return CMD_RET_USAGE;
- i = simple_strtoul(argv[2], NULL, 10);
+ i = dectoul(argv[2], NULL);
udev = usb_find_device(i);
if (udev == NULL) {
printf("Device %d does not exist.\n", i);
return 1;
}
- i = simple_strtoul(argv[3], NULL, 10);
+ i = dectoul(argv[3], NULL);
return usb_test(udev, i, argv[4]);
}
#ifdef CONFIG_USB_STORAGE
diff --git a/cmd/w1.c b/cmd/w1.c
index d0f0ee1..3209e65 100644
--- a/cmd/w1.c
+++ b/cmd/w1.c
@@ -51,16 +51,16 @@
u8 buf[512];
if (argc > 2)
- bus_n = simple_strtoul(argv[2], NULL, 10);
+ bus_n = dectoul(argv[2], NULL);
if (argc > 3)
- dev_n = simple_strtoul(argv[3], NULL, 10);
+ dev_n = dectoul(argv[3], NULL);
if (argc > 4)
- offset = simple_strtoul(argv[4], NULL, 10);
+ offset = dectoul(argv[4], NULL);
if (argc > 5)
- len = simple_strtoul(argv[5], NULL, 10);
+ len = dectoul(argv[5], NULL);
if (len > 512) {
printf("len needs to be <= 512\n");
diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c
index fc61a54..b213a94 100644
--- a/cmd/x86/mtrr.c
+++ b/cmd/x86/mtrr.c
@@ -78,8 +78,8 @@
printf("Invalid type name %s\n", typename);
return CMD_RET_USAGE;
}
- start = simple_strtoul(argv[1], NULL, 16);
- size = simple_strtoul(argv[2], NULL, 16);
+ start = hextoul(argv[1], NULL);
+ size = hextoul(argv[2], NULL);
base = start | type;
valid = native_read_msr(MTRR_PHYS_MASK_MSR(reg)) & MTRR_PHYS_MASK_VALID;
@@ -126,7 +126,7 @@
if (cmd != 'l') {
if (argc < 2)
return CMD_RET_USAGE;
- reg = simple_strtoul(argv[1], NULL, 16);
+ reg = hextoul(argv[1], NULL);
if (reg >= reg_count) {
printf("Invalid register number\n");
return CMD_RET_USAGE;
diff --git a/cmd/ximg.c b/cmd/ximg.c
index ef738eb..65ba413 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -59,16 +59,16 @@
verify = env_get_yesno("verify");
if (argc > 1) {
- addr = simple_strtoul(argv[1], NULL, 16);
+ addr = hextoul(argv[1], NULL);
}
if (argc > 2) {
- part = simple_strtoul(argv[2], NULL, 16);
+ part = hextoul(argv[2], NULL);
#if defined(CONFIG_FIT)
uname = argv[2];
#endif
}
if (argc > 3) {
- dest = simple_strtoul(argv[3], NULL, 16);
+ dest = hextoul(argv[3], NULL);
}
switch (genimg_get_format((void *)addr)) {
diff --git a/cmd/yaffs2.c b/cmd/yaffs2.c
index f29ebcc..27fbd1b 100644
--- a/cmd/yaffs2.c
+++ b/cmd/yaffs2.c
@@ -165,8 +165,8 @@
}
filename = argv[1];
- value = simple_strtoul(argv[2], NULL, 16);
- numValues = simple_strtoul(argv[3], NULL, 16);
+ value = hextoul(argv[2], NULL);
+ numValues = hextoul(argv[3], NULL);
printf("Writing value (%lx) %lx times to %s... ", value, numValues,
filename);
@@ -188,7 +188,7 @@
}
filename = argv[1];
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
cmd_yaffs_mread_file(filename, (char *)addr);
@@ -207,8 +207,8 @@
}
filename = argv[1];
- addr = simple_strtoul(argv[2], NULL, 16);
- size = simple_strtoul(argv[3], NULL, 16);
+ addr = hextoul(argv[2], NULL);
+ size = hextoul(argv[3], NULL);
cmd_yaffs_mwrite_file(filename, (char *)addr, size);
diff --git a/cmd/zfs.c b/cmd/zfs.c
index e429ac8..6ef1b56 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -50,13 +50,13 @@
return CMD_RET_USAGE;
count = 0;
- addr = simple_strtoul(argv[3], NULL, 16);
+ addr = hextoul(argv[3], NULL);
filename = env_get("bootfile");
switch (argc) {
case 3:
addr_str = env_get("loadaddr");
if (addr_str != NULL)
- addr = simple_strtoul(addr_str, NULL, 16);
+ addr = hextoul(addr_str, NULL);
else
addr = CONFIG_SYS_LOAD_ADDR;
@@ -68,7 +68,7 @@
break;
case 6:
filename = argv[4];
- count = simple_strtoul(argv[5], NULL, 16);
+ count = hextoul(argv[5], NULL);
break;
default:
diff --git a/cmd/zip.c b/cmd/zip.c
index 8ad3768..08afd62 100644
--- a/cmd/zip.c
+++ b/cmd/zip.c
@@ -16,12 +16,12 @@
switch (argc) {
case 5:
- dst_len = simple_strtoul(argv[4], NULL, 16);
+ dst_len = hextoul(argv[4], NULL);
/* fall through */
case 4:
- src = simple_strtoul(argv[1], NULL, 16);
- src_len = simple_strtoul(argv[2], NULL, 16);
- dst = simple_strtoul(argv[3], NULL, 16);
+ src = hextoul(argv[1], NULL);
+ src_len = hextoul(argv[2], NULL);
+ dst = hextoul(argv[3], NULL);
break;
default:
return cmd_usage(cmdtp);
diff --git a/common/bedbug.c b/common/bedbug.c
index 18a35ca..c76fa48 100644
--- a/common/bedbug.c
+++ b/common/bedbug.c
@@ -1005,9 +1005,9 @@
}
if (txt[0] == '0' && (txt[1] == 'x' || txt[1] == 'X')) /* hex */
- val = simple_strtoul (&txt[2], NULL, 16);
+ val = hextoul(&txt[2], NULL);
else /* decimal */
- val = simple_strtoul (txt, NULL, 10);
+ val = dectoul(txt, NULL);
if (is_neg)
val = -val;
diff --git a/common/bootm_os.c b/common/bootm_os.c
index 0b6325d..d635037 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -238,7 +238,7 @@
/* See README.plan9 */
s = env_get("confaddr");
if (s != NULL) {
- char *confaddr = (char *)simple_strtoul(s, NULL, 16);
+ char *confaddr = (char *)hextoul(s, NULL);
if (argc > 0) {
copy_args(confaddr, argc, argv, '\n');
@@ -360,8 +360,7 @@
/* find f=0xnumber flag */
if ((bootargs[pos] == '=') && (pos >= 1) &&
(bootargs[pos - 1] == 'f')) {
- vxflags = simple_strtoul(&bootargs[pos + 1],
- NULL, 16);
+ vxflags = hextoul(&bootargs[pos + 1], NULL);
if (vxflags & VXWORKS_SYSFLG_STD_DTB)
std_dtb = true;
}
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 240f1e5..4341d84 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -579,7 +579,7 @@
for (j = 0; j < 6; j++) {
mac_addr[j] = tmp ?
- simple_strtoul(tmp, &end, 16) : 0;
+ hextoul(tmp, &end) : 0;
if (tmp)
tmp = (*end) ? end + 1 : end;
}
diff --git a/common/hash.c b/common/hash.c
index 90cf46b..dca2363 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -396,8 +396,8 @@
for (i = 0; i < algo->digest_size; i++) {
char chr[3];
- strncpy(chr, &str[i * 2], 2);
- result[i] = simple_strtoul(chr, NULL, 16);
+ strlcpy(chr, &str[i * 2], 3);
+ result[i] = hextoul(chr, NULL);
}
return 0;
@@ -470,7 +470,7 @@
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 @@
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 @@
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 @@
addr, addr + len - 1, crc);
if (argc >= 3) {
- ptr = (ulong *)simple_strtoul(argv[0], NULL, 16);
+ ptr = (ulong *)hextoul(argv[0], NULL);
*ptr = crc;
}
}
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 06dce92..9441e63 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -186,7 +186,7 @@
/* If fdt_high is set use it to select the relocation address */
fdt_high = env_get("fdt_high");
if (fdt_high) {
- void *desired_addr = (void *)simple_strtoul(fdt_high, NULL, 16);
+ void *desired_addr = (void *)hextoul(fdt_high, NULL);
if (((ulong) desired_addr) == ~0UL) {
/* All ones means use fdt in place */
@@ -297,7 +297,7 @@
*of_size = 0;
img_addr = (argc == 0) ? image_load_addr :
- simple_strtoul(argv[0], NULL, 16);
+ hextoul(argv[0], NULL);
buf = map_sysmem(img_addr, 0);
if (argc > 2)
@@ -329,7 +329,7 @@
} else
#endif
{
- fdt_addr = simple_strtoul(select, NULL, 16);
+ fdt_addr = hextoul(select, NULL);
debug("* fdt: cmdline image address = 0x%08lx\n",
fdt_addr);
}
diff --git a/common/image-fit.c b/common/image-fit.c
index d6b2c3c..aff4670 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -53,7 +53,7 @@
sep = strchr(spec, sepc);
if (sep) {
if (sep - spec > 0)
- *addr = simple_strtoul(spec, NULL, 16);
+ *addr = hextoul(spec, NULL);
*name = sep + 1;
return 1;
diff --git a/common/image.c b/common/image.c
index 51854aa..59c52a1 100644
--- a/common/image.c
+++ b/common/image.c
@@ -662,7 +662,7 @@
switch (op) {
case env_op_create:
case env_op_overwrite:
- image_load_addr = simple_strtoul(value, NULL, 16);
+ image_load_addr = hextoul(value, NULL);
break;
default:
break;
@@ -676,7 +676,7 @@
{
char *s = env_get("bootm_low");
if (s) {
- ulong tmp = simple_strtoul(s, NULL, 16);
+ ulong tmp = hextoul(s, NULL);
return tmp;
}
@@ -1060,7 +1060,7 @@
*fit_uname_kernel, kernel_addr);
#endif
} else {
- kernel_addr = simple_strtoul(img_addr, NULL, 16);
+ kernel_addr = hextoul(img_addr, NULL);
debug("* kernel: cmdline image address = 0x%08lx\n",
kernel_addr);
}
@@ -1227,7 +1227,7 @@
} else
#endif
{
- rd_addr = simple_strtoul(select, NULL, 16);
+ rd_addr = hextoul(select, NULL);
debug("* ramdisk: cmdline image address = "
"0x%08lx\n",
rd_addr);
@@ -1301,7 +1301,7 @@
if (select)
end = strchr(select, ':');
if (end) {
- rd_len = simple_strtoul(++end, NULL, 16);
+ rd_len = hextoul(++end, NULL);
rd_data = rd_addr;
} else
#endif
@@ -1379,7 +1379,7 @@
/* a value of "no" or a similar string will act like 0,
* turning the "load high" feature off. This is intentional.
*/
- initrd_high = simple_strtoul(s, NULL, 16);
+ initrd_high = hextoul(s, NULL);
if (initrd_high == ~0)
initrd_copy_to_ram = 0;
} else {
diff --git a/common/kallsyms.c b/common/kallsyms.c
index ce42a93..13344e6 100644
--- a/common/kallsyms.c
+++ b/common/kallsyms.c
@@ -31,7 +31,7 @@
*caddr = 0;
while (*sym) {
- sym_addr = simple_strtoul(sym, &esym, 16);
+ sym_addr = hextoul(sym, &esym);
sym = esym;
if (sym_addr > addr)
break;
diff --git a/common/lcd.c b/common/lcd.c
index ab5614a..16a0a7c 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -747,7 +747,7 @@
if (op == env_op_delete)
return 0;
- addr = simple_strtoul(value, NULL, 16);
+ addr = hextoul(value, NULL);
/* See README.displaying-bmps */
aligned = (addr % 4 == 2);
if (!aligned) {
diff --git a/common/lcd_console.c b/common/lcd_console.c
index 1a246c4..9c0ff44 100644
--- a/common/lcd_console.c
+++ b/common/lcd_console.c
@@ -229,8 +229,8 @@
if (argc != 3)
return CMD_RET_USAGE;
- col = simple_strtoul(argv[1], NULL, 10);
- row = simple_strtoul(argv[2], NULL, 10);
+ col = dectoul(argv[1], NULL);
+ row = dectoul(argv[2], NULL);
lcd_position_cursor(col, row);
return 0;
diff --git a/common/splash.c b/common/splash.c
index 2b9313e..de720df 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -65,7 +65,7 @@
if (!splashimage)
return -ENOENT;
- bmp_load_addr = simple_strtoul(splashimage, 0, 16);
+ bmp_load_addr = hextoul(splashimage, 0);
if (!bmp_load_addr) {
printf("Error: bad 'splashimage' address\n");
return -EFAULT;
@@ -162,7 +162,7 @@
if (!s)
return -EINVAL;
- addr = simple_strtoul(s, NULL, 16);
+ addr = hextoul(s, NULL);
ret = splash_screen_prepare();
if (ret)
return ret;
diff --git a/common/splash_source.c b/common/splash_source.c
index 3cf926d..d05670f 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -414,7 +414,7 @@
if (env_splashimage_value == NULL)
return -ENOENT;
- bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16);
+ bmp_load_addr = hextoul(env_splashimage_value, 0);
if (bmp_load_addr == 0) {
printf("Error: bad splashimage address specified\n");
return -EFAULT;
diff --git a/common/update.c b/common/update.c
index f084895..f5c8684 100644
--- a/common/update.c
+++ b/common/update.c
@@ -272,7 +272,7 @@
/* get load address of downloaded update file */
env_addr = env_get("loadaddr");
if (env_addr)
- addr = simple_strtoul(env_addr, NULL, 16);
+ addr = hextoul(env_addr, NULL);
else
addr = CONFIG_UPDATE_LOAD_ADDR;
diff --git a/disk/part.c b/disk/part.c
index 086da84..a6a8f70 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -396,7 +396,7 @@
hwpart = 0;
}
- dev = simple_strtoul(dev_str, &ep, 16);
+ dev = hextoul(dev_str, &ep);
if (*ep) {
printf("** Bad device specification %s %s **\n",
ifname, dev_str);
@@ -405,7 +405,7 @@
}
if (hwpart_str) {
- hwpart = simple_strtoul(hwpart_str, &ep, 16);
+ hwpart = hextoul(hwpart_str, &ep);
if (*ep) {
printf("** Bad HW partition specification %s %s **\n",
ifname, hwpart_str);
@@ -534,7 +534,7 @@
part = PART_AUTO;
} else {
/* Something specified -> use exactly that */
- part = (int)simple_strtoul(part_str, &ep, 16);
+ part = (int)hextoul(part_str, &ep);
/*
* Less than whole string converted,
* or request for whole device, but caller requires partition.
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 7eea60b..ac7ada5 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -135,7 +135,7 @@
s = env_get("amiga_scanlimit");
if (s)
- limit = simple_strtoul(s, NULL, 10);
+ limit = dectoul(s, NULL);
else
limit = AMIGA_BLOCK_LIMIT;
@@ -175,7 +175,7 @@
s = env_get("amiga_scanlimit");
if (s)
- limit = simple_strtoul(s, NULL, 10);
+ limit = dectoul(s, NULL);
else
limit = AMIGA_BLOCK_LIMIT;
diff --git a/doc/usage/cmdline.rst b/doc/usage/cmdline.rst
new file mode 100644
index 0000000..88f18c9
--- /dev/null
+++ b/doc/usage/cmdline.rst
@@ -0,0 +1,93 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Command-line Parsing
+====================
+
+The command line is available in U-Boot proper, enabled by CONFIG_CMDLINE which
+is on by default. It is not enabled in SPL.
+
+There are two different command-line parsers available with U-Boot:
+the old "simple" one, and the much more powerful "hush" shell:
+
+Simple command-line parser
+--------------------------
+
+This takes very little code space and offers only basic features:
+
+- supports environment variables (through setenv / saveenv commands)
+- several commands on one line, separated by ';'
+- variable substitution using "... ${name} ..." syntax
+- special characters ('$', ';') can be escaped by prefixing with '\',
+ for example::
+
+ setenv bootcmd bootm \${address}
+
+- You can also escape text by enclosing in single apostrophes, for example::
+
+ setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off'
+
+Hush shell
+----------
+
+This is similar to Bourne shell, with control structures like:
+
+- `if`... `then` ... `else`... `fi`
+- `for`... `do` ... `done`
+- `while` ... `do` ... `done`
+- `until` ... `do` ... `done`
+
+Hush supports environment ("global") variables (through setenv / saveenv
+commands) and local shell variables (through standard shell syntax
+`name=value`); only environment variables can be used with the "run" command
+
+The Hush shell is enabled with `CONFIG_HUSH_PARSER`.
+
+General rules
+-------------
+
+#. If a command line (or an environment variable executed by a "run"
+ command) contains several commands separated by semicolon, and
+ one of these commands fails, then the remaining commands will be
+ executed anyway.
+
+#. If you execute several variables with one call to run (i. e.
+ calling run with a list of variables as arguments), any failing
+ command will cause "run" to terminate, i. e. the remaining
+ variables are not executed.
+
+Representing numbers
+--------------------
+
+Most U-Boot commands use hexadecimal (hex) as the default base, for convenient
+use of addresses, for example::
+
+ => md 1000 6
+ 00001000: 2c786f62 00697073 03000000 0c000000 box,spi.........
+ 00001010: 67020000 00000000 ...g....
+
+There is no need to add a `0x` prefix to the arguments and the output is shown
+in hex also, without any prefixes. This helps to avoid clutter.
+
+Some commands use decimal where it is more natural::
+
+ => i2c dev 0
+ Setting bus to 0
+ => i2c speed
+ Current bus speed=400000
+ => i2c speed 100000
+ Setting bus speed to 100000 Hz
+
+In some cases the default is decimal but it is possible to use octal if that is
+useful::
+
+ pmic dev pmic@41
+ dev: 1 @ pmic@41
+ => pmic write 2 0177
+ => pmic read 2
+ 0x02: 0x00007f
+
+It is possible to use a `0x` prefix to use a hex value if that is more
+convenient::
+
+ => i2c speed 0x30000
+ Setting bus speed to 196608 Hz
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index 719b2c9..356f2a5 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -9,6 +9,7 @@
fit
netconsole
partitions
+ cmdline
Shell commands
--------------
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index e63fa84..3dab5a5 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -348,7 +348,7 @@
const char *argv[3];
const char **parg = argv;
- dfu->data.mmc.dev_num = simple_strtoul(devstr, NULL, 10);
+ dfu->data.mmc.dev_num = dectoul(devstr, NULL);
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
*parg = strsep(&s, " ");
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index 894b570..0b7f177 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -268,9 +268,9 @@
st = strsep(&s, " ");
if (!strcmp(st, "raw")) {
dfu->layout = DFU_RAW_ADDR;
- dfu->data.mtd.start = simple_strtoul(s, &s, 16);
+ dfu->data.mtd.start = hextoul(s, &s);
s++;
- dfu->data.mtd.size = simple_strtoul(s, &s, 16);
+ dfu->data.mtd.size = hextoul(s, &s);
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
char mtd_id[32];
struct mtd_device *mtd_dev;
@@ -279,7 +279,7 @@
dfu->layout = DFU_RAW_ADDR;
- part = simple_strtoul(s, &s, 10);
+ part = dectoul(s, &s);
sprintf(mtd_id, "%s,%d", devstr, part - 1);
printf("using id '%s'\n", mtd_id);
diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
index b8d24d2..e53b35e 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -204,9 +204,9 @@
st = strsep(&s, " ");
if (!strcmp(st, "raw")) {
dfu->layout = DFU_RAW_ADDR;
- dfu->data.nand.start = simple_strtoul(s, &s, 16);
+ dfu->data.nand.start = hextoul(s, &s);
s++;
- dfu->data.nand.size = simple_strtoul(s, &s, 16);
+ dfu->data.nand.size = hextoul(s, &s);
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
char mtd_id[32];
struct mtd_device *mtd_dev;
@@ -215,9 +215,9 @@
dfu->layout = DFU_RAW_ADDR;
- dev = simple_strtoul(s, &s, 10);
+ dev = dectoul(s, &s);
s++;
- part = simple_strtoul(s, &s, 10);
+ part = dectoul(s, &s);
sprintf(mtd_id, "%s%d,%d", "nand", dev, part - 1);
debug("using id '%s'\n", mtd_id);
diff --git a/drivers/dfu/dfu_ram.c b/drivers/dfu/dfu_ram.c
index ab0ce9e..cc7e45b 100644
--- a/drivers/dfu/dfu_ram.c
+++ b/drivers/dfu/dfu_ram.c
@@ -74,8 +74,8 @@
}
dfu->layout = DFU_RAM_ADDR;
- dfu->data.ram.start = simple_strtoul(argv[1], NULL, 16);
- dfu->data.ram.size = simple_strtoul(argv[2], NULL, 16);
+ dfu->data.ram.start = hextoul(argv[1], NULL);
+ dfu->data.ram.size = hextoul(argv[2], NULL);
dfu->write_medium = dfu_write_medium_ram;
dfu->get_medium_size = dfu_get_medium_size_ram;
diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c
index 8f8c425..7e64ab7 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -171,9 +171,9 @@
st = strsep(&s, " ");
if (!strcmp(st, "raw")) {
dfu->layout = DFU_RAW_ADDR;
- dfu->data.sf.start = simple_strtoul(s, &s, 16);
+ dfu->data.sf.start = hextoul(s, &s);
s++;
- dfu->data.sf.size = simple_strtoul(s, &s, 16);
+ dfu->data.sf.size = hextoul(s, &s);
} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
(!strcmp(st, "part") || !strcmp(st, "partubi"))) {
char mtd_id[32];
@@ -184,9 +184,9 @@
dfu->layout = DFU_RAW_ADDR;
- dev = simple_strtoul(s, &s, 10);
+ dev = dectoul(s, &s);
s++;
- part = simple_strtoul(s, &s, 10);
+ part = dectoul(s, &s);
sprintf(mtd_id, "%s%d,%d", "nor", dev, part - 1);
printf("using id '%s'\n", mtd_id);
diff --git a/drivers/dfu/dfu_virt.c b/drivers/dfu/dfu_virt.c
index 62605bc..80c99cb 100644
--- a/drivers/dfu/dfu_virt.c
+++ b/drivers/dfu/dfu_virt.c
@@ -38,7 +38,7 @@
dfu->dev_type = DFU_DEV_VIRT;
dfu->layout = DFU_RAW_ADDR;
- dfu->data.virt.dev_num = simple_strtoul(devstr, NULL, 10);
+ dfu->data.virt.dev_num = dectoul(devstr, NULL);
dfu->write_medium = dfu_write_medium_virt;
dfu->get_medium_size = dfu_get_medium_size_virt;
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 3a5db5b..98eccc3 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -208,7 +208,7 @@
return;
}
fastboot_bytes_received = 0;
- fastboot_bytes_expected = simple_strtoul(cmd_parameter, &tmp, 16);
+ fastboot_bytes_expected = hextoul(cmd_parameter, &tmp);
if (fastboot_bytes_expected == 0) {
fastboot_fail("Expected nonzero image size", response);
return;
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 131099c..8c77777 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -122,7 +122,7 @@
int numeric;
int ret;
- numeric = isdigit(*name) ? simple_strtoul(name, NULL, 10) : -1;
+ numeric = isdigit(*name) ? dectoul(name, NULL) : -1;
for (ret = uclass_first_device(UCLASS_GPIO, &dev);
dev;
ret = uclass_next_device(&dev)) {
diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index 5775a22..7b9d88a 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -123,12 +123,12 @@
unsigned bank, pin;
char *end;
- bank = simple_strtoul(name, &end, 10);
+ bank = dectoul(name, &end);
if (!*end || *end != ':')
return bank;
- pin = simple_strtoul(end + 1, NULL, 10);
+ pin = dectoul(end + 1, NULL);
return (bank << MXS_PAD_BANK_SHIFT) | (pin << MXS_PAD_PIN_SHIFT);
}
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 4ab8cee..2fd2996 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -221,11 +221,11 @@
/* arg2 used as chip number or pin number */
if (argc > 2)
- ul_arg2 = simple_strtoul(argv[2], NULL, 16);
+ ul_arg2 = hextoul(argv[2], NULL);
/* arg3 used as pin or invert value */
if (argc > 3)
- ul_arg3 = simple_strtoul(argv[3], NULL, 16) & 0x1;
+ ul_arg3 = hextoul(argv[3], NULL) & 0x1;
switch ((long)c->cmd) {
case PCA953X_CMD_INFO:
diff --git a/drivers/gpio/tca642x.c b/drivers/gpio/tca642x.c
index 7007c7a..7f67f96 100644
--- a/drivers/gpio/tca642x.c
+++ b/drivers/gpio/tca642x.c
@@ -262,11 +262,11 @@
/* arg2 used as chip number or pin number */
if (argc > 2)
- ul_arg2 = simple_strtoul(argv[2], NULL, 10);
+ ul_arg2 = dectoul(argv[2], NULL);
/* arg3 used as pin or invert value */
if (argc > 3)
- ul_arg3 = simple_strtoul(argv[3], NULL, 10) & 0x1;
+ ul_arg3 = dectoul(argv[3], NULL) & 0x1;
switch ((int)c->cmd) {
case TCA642X_CMD_INFO:
diff --git a/drivers/misc/ds4510.c b/drivers/misc/ds4510.c
index a2a5291..9340596 100644
--- a/drivers/misc/ds4510.c
+++ b/drivers/misc/ds4510.c
@@ -271,11 +271,11 @@
/* arg2 used as chip addr and pin number */
if (argc > 2)
- ul_arg2 = simple_strtoul(argv[2], NULL, 16);
+ ul_arg2 = hextoul(argv[2], NULL);
/* arg3 used as output/pullup value */
if (argc > 3)
- ul_arg3 = simple_strtoul(argv[3], NULL, 16);
+ ul_arg3 = hextoul(argv[3], NULL);
switch ((int)c->cmd) {
case DS4510_CMD_DEVICE:
@@ -337,9 +337,9 @@
else
return cmd_usage(cmdtp);
- addr = simple_strtoul(argv[3], NULL, 16);
- off += simple_strtoul(argv[4], NULL, 16);
- cnt = simple_strtoul(argv[5], NULL, 16);
+ addr = hextoul(argv[3], NULL);
+ off += hextoul(argv[4], NULL);
+ cnt = hextoul(argv[5], NULL);
if ((off + cnt) > end) {
printf("ERROR: invalid len\n");
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 60613b7..5bdcede 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5796,7 +5796,7 @@
}
/* Make sure we can find the requested e1000 card */
- cardnum = simple_strtoul(argv[1], NULL, 10);
+ cardnum = dectoul(argv[1], NULL);
#ifdef CONFIG_DM_ETH
e1000_name(name, cardnum);
ret = uclass_get_device_by_name(UCLASS_ETH, name, &dev);
diff --git a/drivers/net/e1000_spi.c b/drivers/net/e1000_spi.c
index 4fcc65d..69adf28 100644
--- a/drivers/net/e1000_spi.c
+++ b/drivers/net/e1000_spi.c
@@ -399,7 +399,7 @@
}
/* Parse the arguments */
- dest = (void *)simple_strtoul(argv[0], NULL, 16);
+ dest = (void *)hextoul(argv[0], NULL);
offset = simple_strtoul(argv[1], NULL, 0);
length = simple_strtoul(argv[2], NULL, 0);
@@ -444,7 +444,7 @@
}
/* Parse the arguments */
- source = (const void *)simple_strtoul(argv[0], NULL, 16);
+ source = (const void *)hextoul(argv[0], NULL);
offset = simple_strtoul(argv[1], NULL, 0);
length = simple_strtoul(argv[2], NULL, 0);
diff --git a/drivers/net/fm/fdt.c b/drivers/net/fm/fdt.c
index 242d27a..3855d7d 100644
--- a/drivers/net/fm/fdt.c
+++ b/drivers/net/fm/fdt.c
@@ -42,7 +42,7 @@
if (!p)
return;
- fmanfw = (struct qe_firmware *)simple_strtoul(p, NULL, 16);
+ fmanfw = (struct qe_firmware *)hextoul(p, NULL);
if (!fmanfw)
return;
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 914ec00..d52c986 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -642,7 +642,7 @@
char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR);
if (timeout_ms_env_var) {
- timeout_ms = simple_strtoul(timeout_ms_env_var, NULL, 10);
+ timeout_ms = dectoul(timeout_ms_env_var, NULL);
if (timeout_ms == 0) {
printf("fsl-mc: WARNING: Invalid value for \'"
MC_BOOT_TIMEOUT_ENV_VAR
@@ -956,8 +956,7 @@
char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR);
if (dram_block_size_env_var) {
- dram_block_size = simple_strtoul(dram_block_size_env_var, NULL,
- 16);
+ dram_block_size = hextoul(dram_block_size_env_var, NULL);
if (dram_block_size < CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) {
printf("fsl-mc: WARNING: Invalid value for \'"
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index f1d0630..cec96c5 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -87,7 +87,7 @@
return -1; /* ncip is 0.0.0.0 */
p = strchr(env_get("ncip"), ':');
if (p != NULL) {
- nc_out_port = simple_strtoul(p + 1, NULL, 10);
+ nc_out_port = dectoul(p + 1, NULL);
nc_in_port = nc_out_port;
}
} else {
@@ -96,10 +96,10 @@
p = env_get("ncoutport");
if (p != NULL)
- nc_out_port = simple_strtoul(p, NULL, 10);
+ nc_out_port = dectoul(p, NULL);
p = env_get("ncinport");
if (p != NULL)
- nc_in_port = simple_strtoul(p, NULL, 10);
+ nc_in_port = dectoul(p, NULL);
if (is_broadcast(nc_ip))
/* broadcast MAC address */
diff --git a/drivers/net/pfe_eth/pfe_cmd.c b/drivers/net/pfe_eth/pfe_cmd.c
index 364750f..2fe0db0 100644
--- a/drivers/net/pfe_eth/pfe_cmd.c
+++ b/drivers/net/pfe_eth/pfe_cmd.c
@@ -41,7 +41,7 @@
}
id = simple_strtoul(argv[4], NULL, 0);
- addr = simple_strtoul(argv[5], NULL, 16);
+ addr = hextoul(argv[5], NULL);
size = 4;
for (i = 0; i < num; i++, addr += 4) {
@@ -75,7 +75,7 @@
}
id = simple_strtoul(argv[4], NULL, 0);
- addr = simple_strtoul(argv[5], NULL, 16);
+ addr = hextoul(argv[5], NULL);
size = 4;
for (i = 0; i < num; i++, addr += 4) {
@@ -99,9 +99,9 @@
}
id = simple_strtoul(argv[4], NULL, 0);
- val = simple_strtoul(argv[5], NULL, 16);
+ val = hextoul(argv[5], NULL);
val = cpu_to_be32(val);
- addr = simple_strtoul(argv[6], NULL, 16);
+ addr = hextoul(argv[6], NULL);
size = 4;
pe_dmem_write(id, val, addr, size);
} else {
@@ -123,7 +123,7 @@
return;
}
- offset = simple_strtoul(argv[4], NULL, 16);
+ offset = hextoul(argv[4], NULL);
for (i = 0; i < num; i++, offset += 4) {
pe_lmem_read(&val, 4, offset);
@@ -141,9 +141,9 @@
return;
}
- val = simple_strtoul(argv[4], NULL, 16);
+ val = hextoul(argv[4], NULL);
val = cpu_to_be32(val);
- offset = simple_strtoul(argv[5], NULL, 16);
+ offset = hextoul(argv[5], NULL);
pe_lmem_write(&val, 4, offset);
} else {
printf("Usage: pfe pe lmem [read | write] <parameters>\n");
diff --git a/drivers/net/pfe_eth/pfe_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c
index ac86e33..ad5bc3c 100644
--- a/drivers/net/pfe_eth/pfe_firmware.c
+++ b/drivers/net/pfe_eth/pfe_firmware.c
@@ -298,7 +298,7 @@
if (!p) {
max_fw_count = 2;
} else {
- max_fw_count = simple_strtoul(p, NULL, 10);
+ max_fw_count = dectoul(p, NULL);
if (max_fw_count)
max_fw_count = 3;
else
diff --git a/drivers/net/phy/b53.c b/drivers/net/phy/b53.c
index 21da53c..c706e2b 100644
--- a/drivers/net/phy/b53.c
+++ b/drivers/net/phy/b53.c
@@ -646,9 +646,9 @@
return ret;
}
- page = simple_strtoul(argv[1], NULL, 16);
- offset = simple_strtoul(argv[2], NULL, 16);
- width = simple_strtoul(argv[3], NULL, 10);
+ page = hextoul(argv[1], NULL);
+ offset = hextoul(argv[2], NULL);
+ width = dectoul(argv[3], NULL);
switch (width) {
case 8:
@@ -698,13 +698,13 @@
return ret;
}
- page = simple_strtoul(argv[1], NULL, 16);
- offset = simple_strtoul(argv[2], NULL, 16);
- width = simple_strtoul(argv[3], NULL, 10);
+ page = hextoul(argv[1], NULL);
+ offset = hextoul(argv[2], NULL);
+ width = dectoul(argv[3], NULL);
if (width == 48 || width == 64)
value64 = simple_strtoull(argv[4], NULL, 16);
else
- value = simple_strtoul(argv[4], NULL, 16);
+ value = hextoul(argv[4], NULL);
switch (width) {
case 8:
diff --git a/drivers/net/phy/mv88e6352.c b/drivers/net/phy/mv88e6352.c
index 62a7f19..5606076 100644
--- a/drivers/net/phy/mv88e6352.c
+++ b/drivers/net/phy/mv88e6352.c
@@ -238,9 +238,9 @@
u16 value = 0, phyaddr, reg, port;
int ret;
- phyaddr = simple_strtoul(argv[1], NULL, 10);
- port = simple_strtoul(argv[2], NULL, 10);
- reg = simple_strtoul(argv[3], NULL, 10);
+ phyaddr = dectoul(argv[1], NULL);
+ port = dectoul(argv[2], NULL);
+ reg = dectoul(argv[3], NULL);
ret = sw_reg_read(name, phyaddr, port, reg, &value);
printf("%#x\n", value);
@@ -253,10 +253,10 @@
u16 value = 0, phyaddr, reg, port;
int ret;
- phyaddr = simple_strtoul(argv[1], NULL, 10);
- port = simple_strtoul(argv[2], NULL, 10);
- reg = simple_strtoul(argv[3], NULL, 10);
- value = simple_strtoul(argv[4], NULL, 16);
+ phyaddr = dectoul(argv[1], NULL);
+ port = dectoul(argv[2], NULL);
+ reg = dectoul(argv[3], NULL);
+ value = hextoul(argv[4], NULL);
ret = sw_reg_write(name, phyaddr, port, reg, value);
diff --git a/drivers/net/qe/dm_qe_uec.c b/drivers/net/qe/dm_qe_uec.c
index eb0501b..a12c8cd 100644
--- a/drivers/net/qe/dm_qe_uec.c
+++ b/drivers/net/qe/dm_qe_uec.c
@@ -938,7 +938,7 @@
return QE_CLK_NONE;
if (strncasecmp(source, "brg", 3) == 0) {
- i = simple_strtoul(source + 3, NULL, 10);
+ i = dectoul(source + 3, NULL);
if (i >= 1 && i <= 16)
return (QE_BRG1 - 1) + i;
else
@@ -946,7 +946,7 @@
}
if (strncasecmp(source, "clk", 3) == 0) {
- i = simple_strtoul(source + 3, NULL, 10);
+ i = dectoul(source + 3, NULL);
if (i >= 1 && i <= 24)
return (QE_CLK1 - 1) + i;
else
diff --git a/drivers/pinctrl/nexell/pinctrl-nexell.c b/drivers/pinctrl/nexell/pinctrl-nexell.c
index 6b01f47..20497a7 100644
--- a/drivers/pinctrl/nexell/pinctrl-nexell.c
+++ b/drivers/pinctrl/nexell/pinctrl-nexell.c
@@ -34,7 +34,7 @@
idx++;
}
bank[idx] = '\0';
- *pin = (u32)simple_strtoul(&pin_name[++idx], NULL, 10);
+ *pin = (u32)dectoul(&pin_name[++idx], NULL);
/* lookup the pin bank data using the pin bank name */
for (idx = 0; idx < nr_banks; idx++)
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index ea7275c..dfe60b6 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -69,7 +69,7 @@
* If statename is not found in "pinctrl-names",
* assume statename is just the integer state ID.
*/
- state = simple_strtoul(statename, &end, 10);
+ state = dectoul(statename, &end);
if (*end)
return -EINVAL;
}
diff --git a/drivers/power/power_core.c b/drivers/power/power_core.c
index eeed8e2..4f7ba09 100644
--- a/drivers/power/power_core.c
+++ b/drivers/power/power_core.c
@@ -159,7 +159,7 @@
if (argc < 4)
return CMD_RET_USAGE;
- reg = simple_strtoul(argv[3], NULL, 16);
+ reg = hextoul(argv[3], NULL);
ret = pmic_reg_read(p, reg, &val);
if (ret)
@@ -174,8 +174,8 @@
if (argc < 5)
return CMD_RET_USAGE;
- reg = simple_strtoul(argv[3], NULL, 16);
- val = simple_strtoul(argv[4], NULL, 16);
+ reg = hextoul(argv[3], NULL);
+ val = hextoul(argv[4], NULL);
pmic_reg_write(p, reg, val);
return CMD_RET_SUCCESS;
diff --git a/drivers/qe/qe.c b/drivers/qe/qe.c
index 97883ff..bd0a10c 100644
--- a/drivers/qe/qe.c
+++ b/drivers/qe/qe.c
@@ -794,7 +794,7 @@
return cmd_usage(cmdtp);
if (strcmp(argv[1], "fw") == 0) {
- addr = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[2], NULL);
if (!addr) {
printf("Invalid address\n");
@@ -807,7 +807,7 @@
*/
if (argc > 3) {
- ulong length = simple_strtoul(argv[3], NULL, 16);
+ ulong length = hextoul(argv[3], NULL);
struct qe_firmware *firmware = (void *)addr;
if (length != be32_to_cpu(firmware->header.length)) {
diff --git a/drivers/ram/octeon/octeon_ddr.c b/drivers/ram/octeon/octeon_ddr.c
index e7b61d3..42daf06 100644
--- a/drivers/ram/octeon/octeon_ddr.c
+++ b/drivers/ram/octeon/octeon_ddr.c
@@ -2544,7 +2544,7 @@
eptr = env_get("limit_dram_mbytes");
if (eptr) {
- unsigned int mbytes = simple_strtoul(eptr, NULL, 10);
+ unsigned int mbytes = dectoul(eptr, NULL);
if (mbytes > 0) {
memsize_mbytes = mbytes;
diff --git a/drivers/rtc/m41t60.c b/drivers/rtc/m41t60.c
index 692042b..b8ad33e 100644
--- a/drivers/rtc/m41t60.c
+++ b/drivers/rtc/m41t60.c
@@ -214,7 +214,7 @@
* the M41T60 documentation for further details.
*/
if (s) {
- unsigned long const l = simple_strtoul(s, 0, 16);
+ unsigned long const l = hextoul(s, 0);
if (l <= 0x3F) {
if ((data[RTC_CTRL] & 0x3F) != l) {
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 2b4feac..8171b17 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -395,7 +395,7 @@
/*
* Switch to new baudrate if new baudrate is supported
*/
- baudrate = simple_strtoul(value, NULL, 10);
+ baudrate = dectoul(value, NULL);
/* Not actually changing */
if (gd->baudrate == baudrate)
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index dea25a0..ebbd219 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -61,7 +61,7 @@
/*
* Switch to new baudrate if new baudrate is supported
*/
- baudrate = simple_strtoul(value, NULL, 10);
+ baudrate = dectoul(value, NULL);
/* Not actually changing */
if (gd->baudrate == baudrate)
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 83dbb5a..fcaeab9 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -1659,7 +1659,7 @@
/* ep name pattern likes epXin or epXout */
char c[2] = {ep->name[2], '\0'};
- num = simple_strtoul(c, NULL, 10);
+ num = dectoul(c, NULL);
priv_ep = ep_to_cdns3_ep(ep);
if (cdns3_ep_dir_is_correct(desc, priv_ep)) {
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 7da334f..01337d6 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -144,7 +144,7 @@
/* report address */
if (isdigit(ep->name[2])) {
- u8 num = simple_strtoul(&ep->name[2], NULL, 10);
+ u8 num = dectoul(&ep->name[2], NULL);
desc->bEndpointAddress |= num;
#ifdef MANY_ENDPOINTS
} else if (desc->bEndpointAddress & USB_DIR_IN) {
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 16922ff..4307328 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2401,8 +2401,7 @@
usb_gadget_connect(gadget);
if (env_get("cdc_connect_timeout"))
- timeout = simple_strtoul(env_get("cdc_connect_timeout"),
- NULL, 10) * CONFIG_SYS_HZ;
+ timeout = dectoul(env_get("cdc_connect_timeout"), NULL) * CONFIG_SYS_HZ;
ts = get_timer(0);
while (!dev->network_started) {
/* Handle control-c and timeouts */
diff --git a/drivers/video/ati_radeon_fb.c b/drivers/video/ati_radeon_fb.c
index c4da2e3..3836667 100644
--- a/drivers/video/ati_radeon_fb.c
+++ b/drivers/video/ati_radeon_fb.c
@@ -642,7 +642,7 @@
if (penv) {
/* deceide if it is a string */
if (penv[0] <= '9') {
- videomode = (int) simple_strtoul (penv, NULL, 16);
+ videomode = (int)hextoul(penv, NULL);
tmp = 1;
}
} else {
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 1f491a4..5e1ee06 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -1857,7 +1857,7 @@
ret = splash_screen_prepare();
if (ret < 0)
return video_fb_address;
- addr = simple_strtoul(s, NULL, 16);
+ addr = hextoul(s, NULL);
if (video_display_bitmap(addr,
video_logo_xpos,
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index 9b42ca8..e6dd2b8 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -820,7 +820,7 @@
if (penv) {
/* decide if it is a string */
if (penv[0] <= '9') {
- videomode = (int) simple_strtoul(penv, NULL, 16);
+ videomode = (int)hextoul(penv, NULL);
tmp = 1;
}
} else {
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 8f7d987..8132efa 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -692,8 +692,8 @@
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
return CMD_RET_FAILURE;
- col = simple_strtoul(argv[1], NULL, 10);
- row = simple_strtoul(argv[2], NULL, 10);
+ col = dectoul(argv[1], NULL);
+ row = dectoul(argv[2], NULL);
vidconsole_position_cursor(dev, col, row);
return 0;
diff --git a/examples/standalone/atmel_df_pow2.c b/examples/standalone/atmel_df_pow2.c
index 9c74f49..dcb25da 100644
--- a/examples/standalone/atmel_df_pow2.c
+++ b/examples/standalone/atmel_df_pow2.c
@@ -141,11 +141,12 @@
if (line[0] == '\0')
continue;
- bus = cs = simple_strtoul(line, &p, 10);
+ bus = dectoul(line, &p);
+ cs = bus;
if (*p) {
if (*p == ':') {
++p;
- cs = simple_strtoul(p, &p, 10);
+ cs = dectoul(p, &p);
}
if (*p) {
puts("invalid format, please try again\n");
diff --git a/fs/fs.c b/fs/fs.c
index b7936fd..7c68258 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -717,13 +717,13 @@
}
if (argc >= 4) {
- addr = simple_strtoul(argv[3], &ep, 16);
+ addr = hextoul(argv[3], &ep);
if (ep == argv[3] || *ep != '\0')
return CMD_RET_USAGE;
} else {
addr_str = env_get("loadaddr");
if (addr_str != NULL)
- addr = simple_strtoul(addr_str, NULL, 16);
+ addr = hextoul(addr_str, NULL);
else
addr = CONFIG_SYS_LOAD_ADDR;
}
@@ -737,11 +737,11 @@
}
}
if (argc >= 6)
- bytes = simple_strtoul(argv[5], NULL, 16);
+ bytes = hextoul(argv[5], NULL);
else
bytes = 0;
if (argc >= 7)
- pos = simple_strtoul(argv[6], NULL, 16);
+ pos = hextoul(argv[6], NULL);
else
pos = 0;
@@ -815,11 +815,11 @@
if (fs_set_blk_dev(argv[1], argv[2], fstype))
return 1;
- addr = simple_strtoul(argv[3], NULL, 16);
+ addr = hextoul(argv[3], NULL);
filename = argv[4];
- bytes = simple_strtoul(argv[5], NULL, 16);
+ bytes = hextoul(argv[5], NULL);
if (argc >= 7)
- pos = simple_strtoul(argv[6], NULL, 16);
+ pos = hextoul(argv[6], NULL);
else
pos = 0;
diff --git a/include/vsprintf.h b/include/vsprintf.h
index 4016de6..83d187e 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -10,12 +10,57 @@
#include <stdarg.h>
#include <linux/types.h>
+/**
+ * simple_strtoul - convert a string to an unsigned long
+ *
+ * @param cp The string to be converted
+ * @param endp Updated to point to the first character not converted
+ * @param base The number base to use (0 for the default)
+ * @return value decoded from string (0 if invalid)
+ *
+ * Converts a string to an unsigned long. If there are invalid characters at
+ * the end these are ignored. In the worst case, if all characters are invalid,
+ * 0 is returned
+ *
+ * A hex prefix is supported (e.g. 0x123) regardless of the value of @base.
+ * If found, the base is set to hex (16).
+ *
+ * If @base is 0:
+ * - an octal '0' prefix (e.g. 0777) sets the base to octal (8).
+ * - otherwise the base defaults to decimal (10).
+ */
ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
/**
+ * hex_strtoul - convert a string in hex to an unsigned long
+ *
+ * @param cp The string to be converted
+ * @param endp Updated to point to the first character not converted
+ * @return value decoded from string (0 if invalid)
+ *
+ * Converts a hex string to an unsigned long. If there are invalid characters at
+ * the end these are ignored. In the worst case, if all characters are invalid,
+ * 0 is returned
+ */
+unsigned long hextoul(const char *cp, char **endp);
+
+/**
+ * dec_strtoul - convert a string in decimal to an unsigned long
+ *
+ * @param cp The string to be converted
+ * @param endp Updated to point to the first character not converted
+ * @return value decoded from string (0 if invalid)
+ *
+ * Converts a decimal string to an unsigned long. If there are invalid
+ * characters at the end these are ignored. In the worst case, if all characters
+ * are invalid, 0 is returned
+ */
+unsigned long dectoul(const char *cp, char **endp);
+
+/**
* strict_strtoul - convert a string to an unsigned long strictly
* @param cp The string to be converted
- * @param base The number base to use
+ * @param base The number base to use (0 for the default)
* @param res The converted result value
* @return 0 if conversion is successful and *res is set to the converted
* value, otherwise it returns -EINVAL and *res is set to 0.
@@ -30,8 +75,12 @@
*
* echo will append a newline to the tail.
*
- * simple_strtoul just ignores the successive invalid characters and
- * return the converted value of prefix part of the string.
+ * A hex prefix is supported (e.g. 0x123) regardless of the value of @base.
+ * If found, the base is set to hex (16).
+ *
+ * If @base is 0:
+ * - an octal '0' prefix (e.g. 0777) sets the base to octal (8).
+ * - otherwise the base defaults to decimal (10).
*
* Copied this function from Linux 2.6.38 commit ID:
* 521cb40b0c44418a4fd36dc633f575813d59a43d
diff --git a/lib/dhry/cmd_dhry.c b/lib/dhry/cmd_dhry.c
index d55ab54..77b52a2 100644
--- a/lib/dhry/cmd_dhry.c
+++ b/lib/dhry/cmd_dhry.c
@@ -16,7 +16,7 @@
int iterations = 1000000;
if (argc > 1)
- iterations = simple_strtoul(argv[1], NULL, 10);
+ iterations = dectoul(argv[1], NULL);
start = get_timer(0);
dhry(iterations);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 4b097fb..07c7ebe 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -405,7 +405,7 @@
continue;
/* Get the alias number */
- number = simple_strtoul(path + name_len, NULL, 10);
+ number = dectoul(path + name_len, NULL);
if (number < 0 || number >= maxcount) {
debug("%s: warning: alias '%s' is out of range\n",
__func__, path);
diff --git a/lib/net_utils.c b/lib/net_utils.c
index 0a8a557..72a3b09 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -23,7 +23,7 @@
return addr;
for (addr.s_addr = 0, i = 0; i < 4; ++i) {
- ulong val = s ? simple_strtoul(s, &e, 10) : 0;
+ ulong val = s ? dectoul(s, &e) : 0;
if (val > 255) {
addr.s_addr = 0;
return addr;
@@ -52,7 +52,7 @@
return;
for (i = 0; i < 6; ++i) {
- enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
+ enetaddr[i] = addr ? hextoul(addr, &end) : 0;
if (addr)
addr = (*end) ? end + 1 : end;
}
diff --git a/lib/strto.c b/lib/strto.c
index f8b53d8..7bba1e3 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -14,33 +14,55 @@
#include <linux/ctype.h>
/* from lib/kstrtox.c */
-static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
+static const char *_parse_integer_fixup_radix(const char *s, uint *basep)
{
- if (*base == 0) {
- if (s[0] == '0') {
- if (tolower(s[1]) == 'x' && isxdigit(s[2]))
- *base = 16;
- else
- *base = 8;
- } else
- *base = 10;
+ /* Look for a 0x prefix */
+ if (s[0] == '0') {
+ int ch = tolower(s[1]);
+
+ if (ch == 'x') {
+ *basep = 16;
+ s += 2;
+ } else if (!*basep) {
+ /* Only select octal if we don't have a base */
+ *basep = 8;
+ }
}
- if (*base == 16 && s[0] == '0' && tolower(s[1]) == 'x')
- s += 2;
+
+ /* Use decimal by default */
+ if (!*basep)
+ *basep = 10;
+
return s;
}
+/**
+ * decode_digit() - Decode a single character into its numeric digit value
+ *
+ * This ignore case
+ *
+ * @ch: Character to convert (expects '0'..'9', 'a'..'f' or 'A'..'F')
+ * @return value of digit (0..0xf) or 255 if the character is invalid
+ */
+static uint decode_digit(int ch)
+{
+ if (!isxdigit(ch))
+ return 256;
+
+ ch = tolower(ch);
+
+ return ch <= '9' ? ch - '0' : ch - 'a' + 0xa;
+}
+
-unsigned long simple_strtoul(const char *cp, char **endp,
- unsigned int base)
+ulong simple_strtoul(const char *cp, char **endp, uint base)
{
- unsigned long result = 0;
- unsigned long value;
+ ulong result = 0;
+ uint value;
cp = _parse_integer_fixup_radix(cp, &base);
- while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
- ? toupper(*cp) : *cp)-'A'+10) < base) {
- result = result*base + value;
+ while (value = decode_digit(*cp), value < base) {
+ result = result * base + value;
cp++;
}
@@ -50,6 +72,16 @@
return result;
}
+ulong hextoul(const char *cp, char **endp)
+{
+ return simple_strtoul(cp, endp, 16);
+}
+
+ulong dectoul(const char *cp, char **endp)
+{
+ return simple_strtoul(cp, endp, 10);
+}
+
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
char *tail;
@@ -127,12 +159,12 @@
unsigned long long simple_strtoull(const char *cp, char **endp,
unsigned int base)
{
- unsigned long long result = 0, value;
+ unsigned long long result = 0;
+ uint value;
cp = _parse_integer_fixup_radix(cp, &base);
- while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0'
- : (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
+ while (value = decode_digit(*cp), value < base) {
result = result * base + value;
cp++;
}
@@ -160,7 +192,7 @@
if (isdigit(end[-1])) {
for (p = end - 1; p > str; p--) {
if (!isdigit(*p))
- return simple_strtoul(p + 1, NULL, 10);
+ return dectoul(p + 1, NULL);
}
}
diff --git a/lib/uuid.c b/lib/uuid.c
index 5bc6867..67267c6 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -164,26 +164,26 @@
}
if (str_format == UUID_STR_FORMAT_STD) {
- tmp32 = cpu_to_be32(simple_strtoul(uuid_str, NULL, 16));
+ tmp32 = cpu_to_be32(hextoul(uuid_str, NULL));
memcpy(uuid_bin, &tmp32, 4);
- tmp16 = cpu_to_be16(simple_strtoul(uuid_str + 9, NULL, 16));
+ tmp16 = cpu_to_be16(hextoul(uuid_str + 9, NULL));
memcpy(uuid_bin + 4, &tmp16, 2);
- tmp16 = cpu_to_be16(simple_strtoul(uuid_str + 14, NULL, 16));
+ tmp16 = cpu_to_be16(hextoul(uuid_str + 14, NULL));
memcpy(uuid_bin + 6, &tmp16, 2);
} else {
- tmp32 = cpu_to_le32(simple_strtoul(uuid_str, NULL, 16));
+ tmp32 = cpu_to_le32(hextoul(uuid_str, NULL));
memcpy(uuid_bin, &tmp32, 4);
- tmp16 = cpu_to_le16(simple_strtoul(uuid_str + 9, NULL, 16));
+ tmp16 = cpu_to_le16(hextoul(uuid_str + 9, NULL));
memcpy(uuid_bin + 4, &tmp16, 2);
- tmp16 = cpu_to_le16(simple_strtoul(uuid_str + 14, NULL, 16));
+ tmp16 = cpu_to_le16(hextoul(uuid_str + 14, NULL));
memcpy(uuid_bin + 6, &tmp16, 2);
}
- tmp16 = cpu_to_be16(simple_strtoul(uuid_str + 19, NULL, 16));
+ tmp16 = cpu_to_be16(hextoul(uuid_str + 19, NULL));
memcpy(uuid_bin + 8, &tmp16, 2);
tmp64 = cpu_to_be64(simple_strtoull(uuid_str + 24, NULL, 16));
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c14176dd..d7ee35b 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -858,7 +858,7 @@
{
char *endptr;
- *num = simple_strtoul(p, &endptr, 16);
+ *num = hextoul(p, &endptr);
return *p != '\0' && *endptr == '\0';
}
diff --git a/net/bootp.c b/net/bootp.c
index 163af41e..655b9cc 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -740,7 +740,7 @@
ep = env_get("bootpretryperiod");
if (ep != NULL)
- time_taken_max = simple_strtoul(ep, NULL, 10);
+ time_taken_max = dectoul(ep, NULL);
else
time_taken_max = TIMEOUT_MS;
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index c2a97d7..0da0e85 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -128,7 +128,7 @@
/* Must be longer than 3 to be an alias */
if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
startp = devname + len;
- seq = simple_strtoul(startp, &endp, 10);
+ seq = dectoul(startp, &endp);
}
ret = uclass_get(UCLASS_ETH, &uc);
@@ -241,7 +241,7 @@
struct udevice *dev;
/* look for an index after "eth" */
- index = simple_strtoul(name + 3, NULL, 10);
+ index = dectoul(name + 3, NULL);
retval = uclass_find_device_by_seq(UCLASS_ETH, index, &dev);
if (!retval) {
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index 96ed5a4..f383ccc 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -114,7 +114,7 @@
return 0;
/* look for an index after "eth" */
- index = simple_strtoul(name + 3, NULL, 10);
+ index = dectoul(name + 3, NULL);
dev = eth_devices;
do {
diff --git a/net/net.c b/net/net.c
index b58f306..c2992a0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1591,7 +1591,7 @@
if (*s < '0' || *s > '9')
id = VLAN_NONE;
else
- id = (ushort)simple_strtoul(s, NULL, 10);
+ id = (ushort)dectoul(s, NULL);
return htons(id);
}
diff --git a/net/tftp.c b/net/tftp.c
index 00ab7ca..5baf528 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -554,8 +554,7 @@
for (i = 0; i+8 < len; i++) {
if (strcasecmp((char *)pkt + i, "blksize") == 0) {
tftp_block_size = (unsigned short)
- simple_strtoul((char *)pkt + i + 8,
- NULL, 10);
+ dectoul((char *)pkt + i + 8, NULL);
debug("Blocksize oack: %s, %d\n",
(char *)pkt + i + 8, tftp_block_size);
if (tftp_block_size > tftp_block_size_option) {
@@ -566,8 +565,7 @@
}
if (strcasecmp((char *)pkt + i, "timeout") == 0) {
timeout_val_rcvd = (unsigned short)
- simple_strtoul((char *)pkt + i + 8,
- NULL, 10);
+ dectoul((char *)pkt + i + 8, NULL);
debug("Timeout oack: %s, %d\n",
(char *)pkt + i + 8, timeout_val_rcvd);
if (timeout_val_rcvd != (timeout_ms / 1000)) {
@@ -578,16 +576,15 @@
}
#ifdef CONFIG_TFTP_TSIZE
if (strcasecmp((char *)pkt + i, "tsize") == 0) {
- tftp_tsize = simple_strtoul((char *)pkt + i + 6,
- NULL, 10);
+ tftp_tsize = dectoul((char *)pkt + i + 6,
+ NULL);
debug("size = %s, %d\n",
(char *)pkt + i + 6, tftp_tsize);
}
#endif
if (strcasecmp((char *)pkt + i, "windowsize") == 0) {
tftp_windowsize =
- simple_strtoul((char *)pkt + i + 11,
- NULL, 10);
+ dectoul((char *)pkt + i + 11, NULL);
debug("windowsize = %s, %d\n",
(char *)pkt + i + 11, tftp_windowsize);
}
diff --git a/test/str_ut.c b/test/str_ut.c
index 359d7d4..d2840d5 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -15,6 +15,10 @@
static const char str1[] = "I'm sorry I'm late.";
static const char str2[] = "1099abNo, don't bother apologising.";
static const char str3[] = "0xbI'm sorry you're alive.";
+static const char str4[] = "1234567890123 I lost closer friends";
+static const char str5[] = "0x9876543210the last time I was deloused";
+static const char str6[] = "0778octal is seldom used";
+static const char str7[] = "707it is a piece of computing history";
/* Declare a new str test */
#define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test)
@@ -84,6 +88,12 @@
/* Base 10 and base 16 */
ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper));
ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper));
+ ut_assertok(run_strtoul(uts, str3, 16, 0xb, 3, upper));
+ ut_assertok(run_strtoul(uts, str3, 10, 0xb, 3, upper));
+
+ /* Octal */
+ ut_assertok(run_strtoul(uts, str6, 0, 63, 3, upper));
+ ut_assertok(run_strtoul(uts, str7, 8, 0x1c7, 3, upper));
/* Invalid string */
ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper));
@@ -105,6 +115,93 @@
}
STR_TEST(str_simple_strtoul, 0);
+static int run_strtoull(struct unit_test_state *uts, const char *str, int base,
+ unsigned long long expect_val, int expect_endp_offset,
+ bool upper)
+{
+ char out[TEST_STR_SIZE];
+ char *endp;
+ unsigned long long val;
+
+ strcpy(out, str);
+ if (upper)
+ str_to_upper(out, out, -1);
+
+ val = simple_strtoull(out, &endp, base);
+ ut_asserteq(expect_val, val);
+ ut_asserteq(expect_endp_offset, endp - out);
+
+ return 0;
+}
+
+static int str_simple_strtoull(struct unit_test_state *uts)
+{
+ int upper;
+
+ /* Check that it is case-insentive */
+ for (upper = 0; upper < 2; upper++) {
+ /* Base 10 and base 16 */
+ ut_assertok(run_strtoull(uts, str2, 10, 1099, 4, upper));
+ ut_assertok(run_strtoull(uts, str2, 16, 0x1099ab, 6, upper));
+ ut_assertok(run_strtoull(uts, str3, 16, 0xb, 3, upper));
+ ut_assertok(run_strtoull(uts, str3, 10, 0xb, 3, upper));
+
+ /* Octal */
+ ut_assertok(run_strtoull(uts, str6, 0, 63, 3, upper));
+ ut_assertok(run_strtoull(uts, str7, 8, 0x1c7, 3, upper));
+
+ /* Large values */
+ ut_assertok(run_strtoull(uts, str4, 10, 1234567890123, 13,
+ upper));
+ ut_assertok(run_strtoull(uts, str4, 16, 0x1234567890123, 13,
+ upper));
+ ut_assertok(run_strtoull(uts, str5, 0, 0x9876543210, 12,
+ upper));
+
+ /* Invalid string */
+ ut_assertok(run_strtoull(uts, str1, 10, 0, 0, upper));
+
+ /* Base 0 */
+ ut_assertok(run_strtoull(uts, str1, 0, 0, 0, upper));
+ ut_assertok(run_strtoull(uts, str2, 0, 1099, 4, upper));
+ ut_assertok(run_strtoull(uts, str3, 0, 0xb, 3, upper));
+
+ /* Base 2 */
+ ut_assertok(run_strtoull(uts, str1, 2, 0, 0, upper));
+ ut_assertok(run_strtoull(uts, str2, 2, 2, 2, upper));
+ }
+
+ /* Check endp being NULL */
+ ut_asserteq(1099, simple_strtoull(str2, NULL, 0));
+
+ return 0;
+}
+STR_TEST(str_simple_strtoull, 0);
+
+static int str_hextoul(struct unit_test_state *uts)
+{
+ char *endp;
+
+ /* Just a simple test, since we know this uses simple_strtoul() */
+ ut_asserteq(0x1099ab, hextoul(str2, &endp));
+ ut_asserteq(6, endp - str2);
+
+ return 0;
+}
+STR_TEST(str_hextoul, 0);
+
+static int str_dectoul(struct unit_test_state *uts)
+{
+ char *endp;
+
+ /* Just a simple test, since we know this uses simple_strtoul() */
+ ut_asserteq(1099, dectoul(str2, &endp));
+ ut_asserteq(4, endp - str2);
+
+ return 0;
+}
+STR_TEST(str_dectoul, 0);
+
int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test *tests = UNIT_TEST_SUITE_START(str_test);