[PATCH 03/15] global: Convert simple_strtoul() with decimal to dectoul()
Simon Glass
sjg at chromium.org
Tue Jul 20 15:29:27 CEST 2021
It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/arm/cpu/armv8/fsl-layerscape/soc.c | 2 +-
arch/arm/mach-imx/cmd_dek.c | 2 +-
arch/arm/mach-imx/cmd_mfgprot.c | 2 +-
arch/arm/mach-imx/imx8/snvs_security_sc.c | 2 +-
arch/arm/mach-keystone/cmd_clock.c | 10 ++---
arch/arm/mach-kirkwood/cpu.c | 2 +-
arch/arm/mach-nexell/clock.c | 2 +-
.../cmd_stm32prog/cmd_stm32prog.c | 2 +-
.../mach-stm32mp/cmd_stm32prog/stm32prog.c | 2 +-
arch/powerpc/cpu/mpc83xx/ecc.c | 4 +-
board/Arcturus/ucp1020/ucp1020.c | 2 +-
board/BuS/eb_cpu5282/eb_cpu5282.c | 8 ++--
board/atmel/common/board.c | 2 +-
board/cavium/thunderx/atf.c | 24 +++++------
board/compulab/common/eeprom.c | 2 +-
board/compulab/common/omap3_display.c | 2 +-
board/davinci/da8xxevm/da850evm.c | 2 +-
board/freescale/common/pixis.c | 8 ++--
board/freescale/common/sys_eeprom.c | 2 +-
board/gateworks/gw_ventana/gsc.c | 4 +-
board/gateworks/gw_ventana/gw_ventana.c | 2 +-
board/gateworks/venice/gsc.c | 2 +-
board/gdsys/common/cmd_ioloop.c | 16 ++++----
board/samsung/common/exynos5-dt.c | 2 +-
board/samsung/odroid/odroid.c | 2 +-
board/siemens/taurus/taurus.c | 5 +--
.../unmatched/hifive-platform-i2c-eeprom.c | 6 +--
board/synopsys/hsdk/env-lib.c | 2 +-
board/toradex/common/tdx-cfg-block.c | 14 +++----
board/varisys/common/sys_eeprom.c | 2 +-
.../work_92105/work_92105_display.c | 3 +-
cmd/avb.c | 2 +-
cmd/axi.c | 8 ++--
cmd/bind.c | 4 +-
cmd/binop.c | 2 +-
cmd/blk_common.c | 4 +-
cmd/bmp.c | 4 +-
cmd/clk.c | 2 +-
cmd/clone.c | 2 +-
cmd/cros_ec.c | 4 +-
cmd/demo.c | 2 +-
cmd/exit.c | 2 +-
cmd/flash.c | 6 +--
cmd/gpio.c | 4 +-
cmd/gpt.c | 2 +-
cmd/i2c.c | 8 ++--
cmd/led.c | 2 +-
cmd/legacy_led.c | 2 +-
cmd/load.c | 6 +--
cmd/log.c | 4 +-
cmd/mbr.c | 2 +-
cmd/mem.c | 4 +-
cmd/mmc.c | 40 +++++++++----------
cmd/mp.c | 2 +-
cmd/nand.c | 2 +-
cmd/nvedit.c | 2 +-
cmd/optee_rpmb.c | 2 +-
cmd/osd.c | 4 +-
cmd/pcap.c | 2 +-
cmd/pstore.c | 2 +-
cmd/pwm.c | 10 ++---
cmd/remoteproc.c | 6 +--
cmd/rtc.c | 2 +-
cmd/sata.c | 2 +-
cmd/sleep.c | 2 +-
cmd/sound.c | 4 +-
cmd/spi.c | 10 ++---
cmd/ti/pd.c | 4 +-
cmd/tpm-common.c | 2 +-
cmd/ufs.c | 2 +-
cmd/usb.c | 6 +--
cmd/w1.c | 8 ++--
common/bedbug.c | 2 +-
common/lcd_console.c | 4 +-
disk/part_amiga.c | 4 +-
drivers/dfu/dfu_mmc.c | 2 +-
drivers/dfu/dfu_mtd.c | 2 +-
drivers/dfu/dfu_nand.c | 4 +-
drivers/dfu/dfu_sf.c | 4 +-
drivers/dfu/dfu_virt.c | 2 +-
drivers/gpio/gpio-uclass.c | 2 +-
drivers/gpio/mxs_gpio.c | 4 +-
drivers/gpio/tca642x.c | 4 +-
drivers/net/e1000.c | 2 +-
drivers/net/fsl-mc/mc.c | 2 +-
drivers/net/netconsole.c | 6 +--
drivers/net/pfe_eth/pfe_firmware.c | 2 +-
drivers/net/phy/b53.c | 4 +-
drivers/net/phy/mv88e6352.c | 12 +++---
drivers/net/qe/dm_qe_uec.c | 4 +-
drivers/pinctrl/nexell/pinctrl-nexell.c | 2 +-
drivers/pinctrl/pinctrl-uclass.c | 2 +-
drivers/ram/octeon/octeon_ddr.c | 2 +-
drivers/serial/serial-uclass.c | 2 +-
drivers/serial/serial.c | 2 +-
drivers/usb/cdns3/gadget.c | 2 +-
drivers/usb/gadget/epautoconf.c | 2 +-
drivers/usb/gadget/ether.c | 3 +-
drivers/video/vidconsole-uclass.c | 4 +-
examples/standalone/atmel_df_pow2.c | 5 ++-
include/vsprintf.h | 13 ++++++
lib/dhry/cmd_dhry.c | 2 +-
lib/fdtdec.c | 2 +-
lib/net_utils.c | 2 +-
lib/strto.c | 7 +++-
net/bootp.c | 2 +-
net/eth-uclass.c | 4 +-
net/eth_legacy.c | 2 +-
net/net.c | 2 +-
net/tftp.c | 13 +++---
test/str_ut.c | 12 ++++++
111 files changed, 255 insertions(+), 230 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index c3cd6c7ac7f..7dbe594410a 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -277,7 +277,7 @@ static unsigned long get_internval_val_mhz(void)
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/mach-imx/cmd_dek.c b/arch/arm/mach-imx/cmd_dek.c
index 40df10dd739..1e3cfee4739 100644
--- a/arch/arm/mach-imx/cmd_dek.c
+++ b/arch/arm/mach-imx/cmd_dek.c
@@ -302,7 +302,7 @@ static int do_dek_blob(struct cmd_tbl *cmdtp, int flag, int argc,
src_addr = hextoul(argv[1], NULL);
dst_addr = hextoul(argv[2], NULL);
- len = simple_strtoul(argv[3], NULL, 10);
+ 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 29074fc2980..1e866b76c8d 100644
--- a/arch/arm/mach-imx/cmd_mfgprot.c
+++ b/arch/arm/mach-imx/cmd_mfgprot.c
@@ -72,7 +72,7 @@ static int do_mfgprot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
return CMD_RET_USAGE;
m_addr = hextoul(argv[2], NULL);
- m_size = simple_strtoul(argv[3], NULL, 10);
+ 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/imx8/snvs_security_sc.c b/arch/arm/mach-imx/imx8/snvs_security_sc.c
index 7c34ce6d5f8..507b5b42314 100644
--- a/arch/arm/mach-imx/imx8/snvs_security_sc.c
+++ b/arch/arm/mach-imx/imx8/snvs_security_sc.c
@@ -726,7 +726,7 @@ static int do_tamper_pin_cfg(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc != (2 + 1))
return CMD_RET_USAGE;
- conf.pad = simple_strtoul(argv[++idx], NULL, 10);
+ conf.pad = dectoul(argv[++idx], NULL);
conf.mux_conf = hextoul(argv[++idx], NULL);
err = apply_tamper_pin_list_config(&conf, 1);
diff --git a/arch/arm/mach-keystone/cmd_clock.c b/arch/arm/mach-keystone/cmd_clock.c
index 7165d666e5e..72dc394df5f 100644
--- a/arch/arm/mach-keystone/cmd_clock.c
+++ b/arch/arm/mach-keystone/cmd_clock.c
@@ -42,9 +42,9 @@ int do_pll_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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 @@ int do_getclk_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ int do_psc_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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-kirkwood/cpu.c b/arch/arm/mach-kirkwood/cpu.c
index 339ae7fd20d..3953aa9b9b5 100644
--- a/arch/arm/mach-kirkwood/cpu.c
+++ b/arch/arm/mach-kirkwood/cpu.c
@@ -125,7 +125,7 @@ static void kw_sysrst_check(void)
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 d5b46a87a18..24fa204ccd2 100644
--- a/arch/arm/mach-nexell/clock.c
+++ b/arch/arm/mach-nexell/clock.c
@@ -592,7 +592,7 @@ struct clk *clk_get(const char *id)
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-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index bf9a686e96e..be53a529772 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -59,7 +59,7 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_USAGE;
}
- dev = (int)simple_strtoul(argv[2], NULL, 10);
+ dev = (int)dectoul(argv[2], NULL);
addr = STM32_DDR_BASE;
size = 0;
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 96ebc6d9783..26fe8b654a7 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -253,7 +253,7 @@ static int parse_type(struct stm32prog_data *data,
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/powerpc/cpu/mpc83xx/ecc.c b/arch/powerpc/cpu/mpc83xx/ecc.c
index 68a7a780d23..7a8ec7f42f1 100644
--- a/arch/powerpc/cpu/mpc83xx/ecc.c
+++ b/arch/powerpc/cpu/mpc83xx/ecc.c
@@ -138,7 +138,7 @@ int do_ecc(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
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 @@ int do_ecc(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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");
diff --git a/board/Arcturus/ucp1020/ucp1020.c b/board/Arcturus/ucp1020/ucp1020.c
index 24d1d57ec4b..ee8a9e0a5e4 100644
--- a/board/Arcturus/ucp1020/ucp1020.c
+++ b/board/Arcturus/ucp1020/ucp1020.c
@@ -52,7 +52,7 @@ void spi_set_speed(struct spi_slave *slave, uint hz)
*/
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 5829299663d..b739bc3ca6a 100644
--- a/board/BuS/eb_cpu5282/eb_cpu5282.c
+++ b/board/BuS/eb_cpu5282/eb_cpu5282.c
@@ -194,13 +194,13 @@ int drv_video_init(void)
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;
@@ -234,8 +234,8 @@ int do_brightness(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/atmel/common/board.c b/board/atmel/common/board.c
index eee5c357bdc..c93c0e52e30 100644
--- a/board/atmel/common/board.c
+++ b/board/atmel/common/board.c
@@ -47,7 +47,7 @@ void at91_pda_detect(void)
break;
}
}
- pda = simple_strtoul((const char *)buf, NULL, 10);
+ pda = dectoul((const char *)buf, NULL);
switch (pda) {
case 7000:
diff --git a/board/cavium/thunderx/atf.c b/board/cavium/thunderx/atf.c
index 582af6f1f1a..1a039c53c14 100644
--- a/board/cavium/thunderx/atf.c
+++ b/board/cavium/thunderx/atf.c
@@ -236,47 +236,47 @@ int do_atf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if ((argc == 5) && !strcmp(argv[1], "readmmc")) {
buffer = (void *)hextoul(argv[2], NULL);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ 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 *)hextoul(argv[2], NULL);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ 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 *)hextoul(argv[2], NULL);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ 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 *)hextoul(argv[2], NULL);
- offset = simple_strtoul(argv[3], NULL, 10);
- size = simple_strtoul(argv[4], NULL, 10);
+ 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 5206cf5c0ad..b41c64d2a32 100644
--- a/board/compulab/common/eeprom.c
+++ b/board/compulab/common/eeprom.c
@@ -153,7 +153,7 @@ u32 cl_eeprom_get_board_rev(uint eeprom_bus)
*/
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 cb9ebae7f96..4ed3b9c00ac 100644
--- a/board/compulab/common/omap3_display.c
+++ b/board/compulab/common/omap3_display.c
@@ -244,7 +244,7 @@ static int parse_pixclock(char *pixclock)
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 383a8617384..6c75231ddf7 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -284,7 +284,7 @@ u32 get_board_rev(void)
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/freescale/common/pixis.c b/board/freescale/common/pixis.c
index 4127fbc1396..6fdb11039e5 100644
--- a/board/freescale/common/pixis.c
+++ b/board/freescale/common/pixis.c
@@ -403,10 +403,10 @@ static unsigned long strfractoint(char *strptr)
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 @@ static int pixis_reset_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
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 9e73056a298..35df8ba389e 100644
--- a/board/freescale/common/sys_eeprom.c
+++ b/board/freescale/common/sys_eeprom.c
@@ -456,7 +456,7 @@ int do_mac(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/gateworks/gw_ventana/gsc.c b/board/gateworks/gw_ventana/gsc.c
index ffed6b5fc8b..59fd1b6939a 100644
--- a/board/gateworks/gw_ventana/gsc.c
+++ b/board/gateworks/gw_ventana/gsc.c
@@ -277,7 +277,7 @@ static int do_gsc_sleep(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_gsc_wd(struct cmd_tbl *cmdtp, int flag, int argc,
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 6a0382dee39..912075db884 100644
--- a/board/gateworks/gw_ventana/gw_ventana.c
+++ b/board/gateworks/gw_ventana/gw_ventana.c
@@ -471,7 +471,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
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;
diff --git a/board/gateworks/venice/gsc.c b/board/gateworks/venice/gsc.c
index c75bc6f8557..271bc8c2293 100644
--- a/board/gateworks/venice/gsc.c
+++ b/board/gateworks/venice/gsc.c
@@ -660,7 +660,7 @@ static int do_gsc(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]
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 658756d9842..1412421a021 100644
--- a/board/gdsys/common/cmd_ioloop.c
+++ b/board/gdsys/common/cmd_ioloop.c
@@ -275,13 +275,13 @@ int do_ioreflect(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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 @@ int do_ioloop(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
/*
* 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 @@ int do_ioloop(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
/*
* 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 @@ int do_iodev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
index 1318ea716a5..0d77a57f808 100644
--- a/board/samsung/common/exynos5-dt.c
+++ b/board/samsung/common/exynos5-dt.c
@@ -169,7 +169,7 @@ char *get_dfu_alt_boot(char *interface, char *devstr)
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 90aab62d33b..35e4cee74f4 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -85,7 +85,7 @@ char *get_dfu_alt_boot(char *interface, char *devstr)
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/taurus/taurus.c b/board/siemens/taurus/taurus.c
index cad16f90656..dae064d4654 100644
--- a/board/siemens/taurus/taurus.c
+++ b/board/siemens/taurus/taurus.c
@@ -394,10 +394,9 @@ static int do_upgrade_available(struct cmd_tbl *cmdtp, int flag, int argc,
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 e8017df5aba..d256089c258 100644
--- a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
+++ b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
@@ -324,7 +324,7 @@ static void set_pcb_revision(char *string)
{
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 @@ static void set_bom_variant(char *string)
{
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 @@ static void set_product_id(char *string)
{
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 e2258385ceb..fd54ac75f20 100644
--- a/board/synopsys/hsdk/env-lib.c
+++ b/board/synopsys/hsdk/env-lib.c
@@ -254,7 +254,7 @@ static int arg_read_set(const struct env_map_common *map, u32 i, int argc,
if (map[i].type == ENV_HEX)
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/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 93eb20cf631..e4f9a0db914 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -548,7 +548,7 @@ static int get_cfgblock_interactive(void)
len = cli_readline(message);
}
- tdx_serial = simple_strtoul(console_buffer, NULL, 10);
+ tdx_serial = dectoul(console_buffer, NULL);
return 0;
}
@@ -566,14 +566,14 @@ static int get_cfgblock_barcode(char *barcode, struct toradex_hw *tag,
/* 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 @@ int try_migrate_tdx_cfg_block_carrier(void)
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 @@ static int get_cfgblock_carrier_interactive(void)
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 @@ static int get_cfgblock_carrier_interactive(void)
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 1bf543619b8..8f624e5e368 100644
--- a/board/varisys/common/sys_eeprom.c
+++ b/board/varisys/common/sys_eeprom.c
@@ -368,7 +368,7 @@ int do_mac(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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 fecbbbdb584..e8e559ce1f9 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 @@ void work_92105_display_init(void)
/* 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/cmd/avb.c b/cmd/avb.c
index 02b4b1f022c..783f51b8169 100644
--- a/cmd/avb.c
+++ b/cmd/avb.c
@@ -366,7 +366,7 @@ int do_avb_read_pvalue(struct cmd_tbl *cmdtp, int flag, int argc,
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 c676819b811..0c80fef0533 100644
--- a/cmd/axi.c
+++ b/cmd/axi.c
@@ -120,7 +120,7 @@ static int do_axi_show_bus(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_axi_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,
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,7 +193,7 @@ static int do_axi_md(struct cmd_tbl *cmdtp, int flag, int argc,
}
if ((flag & CMD_FLAG_REPEAT) == 0) {
- size = simple_strtoul(argv[1], NULL, 10);
+ size = dectoul(argv[1], NULL);
/*
* Address is specified since argc >= 3
@@ -273,7 +273,7 @@ static int do_axi_mw(struct cmd_tbl *cmdtp, int flag, int argc,
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:
diff --git a/cmd/bind.c b/cmd/bind.c
index af2f22cc4c3..07c629eff7c 100644
--- a/cmd/bind.c
+++ b/cmd/bind.c
@@ -218,13 +218,13 @@ static int do_bind_unbind(struct cmd_tbl *cmdtp, int flag, int argc,
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 bb5adc3e05f..592e9146901 100644
--- a/cmd/binop.c
+++ b/cmd/binop.c
@@ -89,7 +89,7 @@ static int do_binop(struct cmd_tbl *cmdtp, int flag, int argc,
else
return CMD_RET_USAGE;
- len = simple_strtoul(lenarg, NULL, 10);
+ len = dectoul(lenarg, NULL);
src1 = malloc(len);
src2 = malloc(len);
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 0898798dec3..4e442f2918b 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -40,7 +40,7 @@ int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
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 @@ int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
}
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",
diff --git a/cmd/bmp.c b/cmd/bmp.c
index f4fe97d89d4..071ba90b435 100644
--- a/cmd/bmp.c
+++ b/cmd/bmp.c
@@ -131,11 +131,11 @@ static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
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/clk.c b/cmd/clk.c
index 7ece2454e09..dbbdc31b35b 100644
--- a/cmd/clk.c
+++ b/cmd/clk.c
@@ -120,7 +120,7 @@ static int do_clk_setfreq(struct cmd_tbl *cmdtp, int flag, int argc,
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 32473a032c1..a9062077571 100644
--- a/cmd/clone.c
+++ b/cmd/clone.c
@@ -34,7 +34,7 @@ static int do_clone(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
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/cros_ec.c b/cmd/cros_ec.c
index abda5d6cd23..a40f5898b52 100644
--- a/cmd/cros_ec.c
+++ b/cmd/cros_ec.c
@@ -501,11 +501,11 @@ static int do_cros_ec(struct cmd_tbl *cmdtp, int flag, int argc,
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 a2957f770d0..571f562ec68 100644
--- a/cmd/demo.c
+++ b/cmd/demo.c
@@ -106,7 +106,7 @@ static int do_demo(struct cmd_tbl *cmdtp, int flag, int argc,
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/exit.c b/cmd/exit.c
index 923f0870fbf..2c7132693ad 100644
--- a/cmd/exit.c
+++ b/cmd/exit.c
@@ -11,7 +11,7 @@ static int do_exit(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
if (argc > 1)
- return simple_strtoul(argv[1], NULL, 10);
+ return dectoul(argv[1], NULL);
return 0;
}
diff --git a/cmd/flash.c b/cmd/flash.c
index bc93e984bca..819febc10ed 100644
--- a/cmd/flash.c
+++ b/cmd/flash.c
@@ -57,7 +57,7 @@ abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl)
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 @@ abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl)
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;
diff --git a/cmd/gpio.c b/cmd/gpio.c
index 4fdb3135fc1..4150024e628 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 @@ static int do_gpio_status(bool all, const char *gpio_name)
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 17f2b839d72..f818fbb71fc 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -985,7 +985,7 @@ static int do_gpt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
#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/i2c.c b/cmd/i2c.c
index cb1cba39b8e..90a4965a86e 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -1079,7 +1079,7 @@ static int do_i2c_loop(struct cmd_tbl *cmdtp, int flag, int argc,
*/
delay = 1000;
if (argc > 3)
- delay = simple_strtoul(argv[4], NULL, 10);
+ delay = dectoul(argv[4], NULL);
/*
* Run the loop...
*/
@@ -1765,7 +1765,7 @@ static int do_i2c_show_bus(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_i2c_bus_num(struct cmd_tbl *cmdtp, int flag, int argc,
#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)
if (bus_no >= CONFIG_SYS_NUM_I2C_BUSES) {
printf("Invalid bus %d\n", bus_no);
@@ -1884,7 +1884,7 @@ static int do_i2c_bus_speed(struct cmd_tbl *cmdtp, int flag, int argc,
/* 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/led.c b/cmd/led.c
index aa7751933e1..48a02baf509 100644
--- a/cmd/led.c
+++ b/cmd/led.c
@@ -93,7 +93,7 @@ int do_led(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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 86cd969e407..5256255f052 100644
--- a/cmd/legacy_led.c
+++ b/cmd/legacy_led.c
@@ -129,7 +129,7 @@ int do_legacy_led(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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 ec3eed18b14..381ed1b3e25 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -70,7 +70,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,
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)
@@ -264,7 +264,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, int argc,
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)
@@ -446,7 +446,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc,
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 72380c5691c..c377aee85c5 100644
--- a/cmd/log.c
+++ b/cmd/log.c
@@ -352,7 +352,7 @@ static int do_log_rec(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_log_rec(struct cmd_tbl *cmdtp, int flag, int argc,
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/mbr.c b/cmd/mbr.c
index da2e3a4722b..e7e22980969 100644
--- a/cmd/mbr.c
+++ b/cmd/mbr.c
@@ -269,7 +269,7 @@ static int do_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/mem.c b/cmd/mem.c
index 0978df5d106..b7511382d3a 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -189,7 +189,7 @@ static int do_mem_mdc(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_mem_mwc(struct cmd_tbl *cmdtp, int flag, int argc,
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);
diff --git a/cmd/mmc.c b/cmd/mmc.c
index f72277800a0..c67ad762422 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -519,10 +519,10 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag,
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 @@ static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
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 @@ static int parse_hwpart_gp(struct mmc_hwpart_conf *pconf, int pidx,
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 @@ static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag,
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 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,
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 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
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 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
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 @@ static int do_mmc_rst_func(struct cmd_tbl *cmdtp, int flag,
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");
@@ -937,7 +937,7 @@ static int do_mmc_bkops_enable(struct cmd_tbl *cmdtp, int flag,
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 c2b5235a373..8d14401b494 100644
--- a/cmd/mp.c
+++ b/cmd/mp.c
@@ -36,7 +36,7 @@ cpu_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/nand.c b/cmd/nand.c
index 34371b983a3..d381053c6ac 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -424,7 +424,7 @@ static int do_nand(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
- dev = (int)simple_strtoul(argv[2], NULL, 10);
+ dev = (int)dectoul(argv[2], NULL);
set_dev(dev);
return 0;
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 02a99b4a77a..ddc715b4f91 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -423,7 +423,7 @@ int do_env_ask(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
* 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 */
diff --git a/cmd/optee_rpmb.c b/cmd/optee_rpmb.c
index 0d6b1cb1d83..e0e44bbed04 100644
--- a/cmd/optee_rpmb.c
+++ b/cmd/optee_rpmb.c
@@ -195,7 +195,7 @@ int do_optee_rpmb_read(struct cmd_tbl *cmdtp, int flag, int argc,
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 8557894a5de..c8c62d4a2ab 100644
--- a/cmd/osd.c
+++ b/cmd/osd.c
@@ -211,7 +211,7 @@ static int do_show_osd(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_osd_num(struct cmd_tbl *cmdtp, int flag, int argc,
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 c751980c554..ab5c1a7e873 100644
--- a/cmd/pcap.c
+++ b/cmd/pcap.c
@@ -19,7 +19,7 @@ static int do_pcap_init(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_USAGE;
addr = hextoul(argv[1], NULL);
- size = simple_strtoul(argv[2], NULL, 10);
+ size = dectoul(argv[2], NULL);
return pcap_init(addr, size) ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
}
diff --git a/cmd/pstore.c b/cmd/pstore.c
index c6973aeb28f..9fac8c7218f 100644
--- a/cmd/pstore.c
+++ b/cmd/pstore.c
@@ -279,7 +279,7 @@ static int pstore_display(struct cmd_tbl *cmdtp, int flag, int argc,
- 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 e1f97c759d2..87d840a2b9b 100644
--- a/cmd/pwm.c
+++ b/cmd/pwm.c
@@ -66,7 +66,7 @@ static int do_pwm(struct cmd_tbl *cmdtp, int flag, int argc,
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 @@ static int do_pwm(struct cmd_tbl *cmdtp, int flag, int argc,
}
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/remoteproc.c b/cmd/remoteproc.c
index 2a0e5759716..ca3b436242a 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -84,7 +84,7 @@ static int do_rproc_init(struct cmd_tbl *cmdtp, int flag, int argc,
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,7 +129,7 @@ static int do_remoteproc_load(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc != 4)
return CMD_RET_USAGE;
- id = (int)simple_strtoul(argv[1], NULL, 10);
+ id = (int)dectoul(argv[1], NULL);
addr = hextoul(argv[2], NULL);
size = hextoul(argv[3], NULL);
@@ -167,7 +167,7 @@ static int do_remoteproc_wrapper(struct cmd_tbl *cmdtp, int flag, int argc,
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/rtc.c b/cmd/rtc.c
index 784879ec1a0..75d4b64d688 100644
--- a/cmd/rtc.c
+++ b/cmd/rtc.c
@@ -130,7 +130,7 @@ int do_rtc(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
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 aa396c1bbdf..76da1906b7f 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -88,7 +88,7 @@ static int do_sata(struct cmd_tbl *cmdtp, int flag, int argc,
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/sleep.c b/cmd/sleep.c
index 1fff400c791..c741b4aa029 100644
--- a/cmd/sleep.c
+++ b/cmd/sleep.c
@@ -20,7 +20,7 @@ static int do_sleep(struct cmd_tbl *cmdtp, int flag, int argc,
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/sound.c b/cmd/sound.c
index fdcde365339..f82f2aa6708 100644
--- a/cmd/sound.c
+++ b/cmd/sound.c
@@ -41,9 +41,9 @@ static int do_play(struct cmd_tbl *cmdtp, int flag, int argc,
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/spi.c b/cmd/spi.c
index 4aea1914129..bdbdbacecd9 100644
--- a/cmd/spi.c
+++ b/cmd/spi.c
@@ -114,20 +114,20 @@ int do_spi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
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/ti/pd.c b/cmd/ti/pd.c
index 9e820b84ca3..008668fd903 100644
--- a/cmd/ti/pd.c
+++ b/cmd/ti/pd.c
@@ -119,8 +119,8 @@ static int do_pd_endis(int argc, char *const argv[], u8 state)
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/tpm-common.c b/cmd/tpm-common.c
index a48c060273a..1d5442c06f6 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -302,7 +302,7 @@ int do_tpm_device(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/ufs.c b/cmd/ufs.c
index 858cd49b597..d4a1e66c1bd 100644
--- a/cmd/ufs.c
+++ b/cmd/ufs.c
@@ -16,7 +16,7 @@ static int do_ufs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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/usb.c b/cmd/usb.c
index b9ec29a8457..3d873765250 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -690,7 +690,7 @@ static int do_usb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
* 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 @@ static int do_usb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
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 d0f0ee1234b..3209e65f377 100644
--- a/cmd/w1.c
+++ b/cmd/w1.c
@@ -51,16 +51,16 @@ static int w1_read(int argc, char *const argv[])
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/common/bedbug.c b/common/bedbug.c
index 6e1fb58080f..c76fa4898c8 100644
--- a/common/bedbug.c
+++ b/common/bedbug.c
@@ -1007,7 +1007,7 @@ long read_number (char *txt)
if (txt[0] == '0' && (txt[1] == 'x' || txt[1] == 'X')) /* hex */
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/lcd_console.c b/common/lcd_console.c
index 1a246c492ce..9c0ff4480eb 100644
--- a/common/lcd_console.c
+++ b/common/lcd_console.c
@@ -229,8 +229,8 @@ static int do_lcd_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
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/disk/part_amiga.c b/disk/part_amiga.c
index 7eea60b564d..ac7ada54781 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -135,7 +135,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
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 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
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/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index e63fa84ce4f..3dab5a5f633 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -348,7 +348,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
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 a31d4804beb..0b7f17761fd 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -279,7 +279,7 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
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 6ddf80b78a5..e53b35e42b8 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -215,9 +215,9 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s)
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_sf.c b/drivers/dfu/dfu_sf.c
index ef5231980e6..7e64ab772f0 100644
--- a/drivers/dfu/dfu_sf.c
+++ b/drivers/dfu/dfu_sf.c
@@ -184,9 +184,9 @@ int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
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 62605bcde50..80c99cb06e3 100644
--- a/drivers/dfu/dfu_virt.c
+++ b/drivers/dfu/dfu_virt.c
@@ -38,7 +38,7 @@ int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char *s)
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/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 131099cc176..8c77777dbe3 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -122,7 +122,7 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
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 5775a22abd4..7b9d88a8a75 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -123,12 +123,12 @@ int name_to_gpio(const char *name)
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/tca642x.c b/drivers/gpio/tca642x.c
index 7007c7a0027..7f67f96b0ec 100644
--- a/drivers/gpio/tca642x.c
+++ b/drivers/gpio/tca642x.c
@@ -262,11 +262,11 @@ static int do_tca642x(struct cmd_tbl *cmdtp, int flag, int argc,
/* 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/net/e1000.c b/drivers/net/e1000.c
index 60613b7df07..5bdcede8f14 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5796,7 +5796,7 @@ static int do_e1000(struct cmd_tbl *cmdtp, int flag, int argc,
}
/* 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/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index f891cd181df..3b222b72508 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -642,7 +642,7 @@ static unsigned long get_mc_boot_timeout_ms(void)
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
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index f1d0630d020..cec96c57150 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -87,7 +87,7 @@ static int refresh_settings_from_env(void)
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 @@ static int refresh_settings_from_env(void)
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_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c
index ac86e33c550..ad5bc3c8624 100644
--- a/drivers/net/pfe_eth/pfe_firmware.c
+++ b/drivers/net/pfe_eth/pfe_firmware.c
@@ -298,7 +298,7 @@ int pfe_firmware_init(void)
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 695fac47b6c..c706e2b9bde 100644
--- a/drivers/net/phy/b53.c
+++ b/drivers/net/phy/b53.c
@@ -648,7 +648,7 @@ int do_b53_reg_read(const char *name, int argc, char *const argv[])
page = hextoul(argv[1], NULL);
offset = hextoul(argv[2], NULL);
- width = simple_strtoul(argv[3], NULL, 10);
+ width = dectoul(argv[3], NULL);
switch (width) {
case 8:
@@ -700,7 +700,7 @@ int do_b53_reg_write(const char *name, int argc, char *const argv[])
page = hextoul(argv[1], NULL);
offset = hextoul(argv[2], NULL);
- width = simple_strtoul(argv[3], NULL, 10);
+ width = dectoul(argv[3], NULL);
if (width == 48 || width == 64)
value64 = simple_strtoull(argv[4], NULL, 16);
else
diff --git a/drivers/net/phy/mv88e6352.c b/drivers/net/phy/mv88e6352.c
index 07a8e50b480..56060762d85 100644
--- a/drivers/net/phy/mv88e6352.c
+++ b/drivers/net/phy/mv88e6352.c
@@ -238,9 +238,9 @@ int do_mvsw_reg_read(const char *name, int argc, char *const argv[])
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,9 +253,9 @@ int do_mvsw_reg_write(const char *name, int argc, char *const argv[])
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);
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 eb0501bc5a8..a12c8cd2ac5 100644
--- a/drivers/net/qe/dm_qe_uec.c
+++ b/drivers/net/qe/dm_qe_uec.c
@@ -938,7 +938,7 @@ enum qe_clock qe_clock_source(const char *source)
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 @@ enum qe_clock qe_clock_source(const char *source)
}
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 6b01f47657c..20497a746d2 100644
--- a/drivers/pinctrl/nexell/pinctrl-nexell.c
+++ b/drivers/pinctrl/nexell/pinctrl-nexell.c
@@ -34,7 +34,7 @@ unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name,
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 ea7275ca004..dfe60b6dadb 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -69,7 +69,7 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
* 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/ram/octeon/octeon_ddr.c b/drivers/ram/octeon/octeon_ddr.c
index e7b61d39f5c..42daf068668 100644
--- a/drivers/ram/octeon/octeon_ddr.c
+++ b/drivers/ram/octeon/octeon_ddr.c
@@ -2544,7 +2544,7 @@ try_again:
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/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 2b4feace53a..8171b17faf8 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -395,7 +395,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op,
/*
* 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 dea25a049c8..ebbd21916d7 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -61,7 +61,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op,
/*
* 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 83dbb5a103d..fcaeab9cc1d 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -1659,7 +1659,7 @@ cdns3_endpoint *cdns3_find_available_ep(struct cdns3_device *priv_dev,
/* 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 7da334f5d31..01337d6511b 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -144,7 +144,7 @@ static int ep_matches(
/* 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 16922ff15c6..43073286572 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2401,8 +2401,7 @@ static int _usb_eth_init(struct ether_priv *priv)
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/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 8f7d987cdd2..8132efa55a3 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -692,8 +692,8 @@ static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
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 9c74f4994b9..dcb25da9498 100644
--- a/examples/standalone/atmel_df_pow2.c
+++ b/examples/standalone/atmel_df_pow2.c
@@ -141,11 +141,12 @@ int atmel_df_pow2(int argc, char *const argv[])
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/include/vsprintf.h b/include/vsprintf.h
index eeea8ea622c..2b0e15f84a3 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -37,6 +37,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
*/
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
diff --git a/lib/dhry/cmd_dhry.c b/lib/dhry/cmd_dhry.c
index d55ab54df97..77b52a23003 100644
--- a/lib/dhry/cmd_dhry.c
+++ b/lib/dhry/cmd_dhry.c
@@ -16,7 +16,7 @@ static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc,
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 4b097fb588e..07c7ebe74d8 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -405,7 +405,7 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,
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 f596c8f280c..72a3b098a70 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -23,7 +23,7 @@ struct in_addr string_to_ip(const char *s)
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;
diff --git a/lib/strto.c b/lib/strto.c
index d9e64cbcac8..f4fb3faf2fa 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -54,6 +54,11 @@ 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;
@@ -156,7 +161,7 @@ long trailing_strtoln(const char *str, const char *end)
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/net/bootp.c b/net/bootp.c
index 163af41e926..655b9cceb66 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -740,7 +740,7 @@ void bootp_request(void)
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 5146bd6666c..c6429fc68a1 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -126,7 +126,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)
/* 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);
@@ -239,7 +239,7 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op,
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 96ed5a47202..f383ccce0b9 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -114,7 +114,7 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op,
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 b58f3062b20..c2992a0908b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1591,7 +1591,7 @@ ushort string_to_vlan(const char *s)
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 00ab7ca0b3c..5baf528f4ec 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -554,8 +554,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
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 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
}
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 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
}
#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 4c3b566d2c1..19f2c127135 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -117,6 +117,18 @@ static int str_hextoul(struct unit_test_state *uts)
}
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);
--
2.32.0.402.g57bb445576-goog
More information about the U-Boot
mailing list