global: Convert simple_strtoul() with decimal to dectoul()
authorSimon Glass <sjg@chromium.org>
Sat, 24 Jul 2021 15:03:30 +0000 (09:03 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 2 Aug 2021 17:32:14 +0000 (13:32 -0400)
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@chromium.org>
111 files changed:
arch/arm/cpu/armv8/fsl-layerscape/soc.c
arch/arm/mach-imx/cmd_dek.c
arch/arm/mach-imx/cmd_mfgprot.c
arch/arm/mach-imx/imx8/snvs_security_sc.c
arch/arm/mach-keystone/cmd_clock.c
arch/arm/mach-kirkwood/cpu.c
arch/arm/mach-nexell/clock.c
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
arch/powerpc/cpu/mpc83xx/ecc.c
board/Arcturus/ucp1020/ucp1020.c
board/BuS/eb_cpu5282/eb_cpu5282.c
board/atmel/common/board.c
board/cavium/thunderx/atf.c
board/compulab/common/eeprom.c
board/compulab/common/omap3_display.c
board/davinci/da8xxevm/da850evm.c
board/freescale/common/pixis.c
board/freescale/common/sys_eeprom.c
board/gateworks/gw_ventana/gsc.c
board/gateworks/gw_ventana/gw_ventana.c
board/gateworks/venice/gsc.c
board/gdsys/common/cmd_ioloop.c
board/samsung/common/exynos5-dt.c
board/samsung/odroid/odroid.c
board/siemens/taurus/taurus.c
board/sifive/unmatched/hifive-platform-i2c-eeprom.c
board/synopsys/hsdk/env-lib.c
board/toradex/common/tdx-cfg-block.c
board/varisys/common/sys_eeprom.c
board/work-microwave/work_92105/work_92105_display.c
cmd/avb.c
cmd/axi.c
cmd/bind.c
cmd/binop.c
cmd/blk_common.c
cmd/bmp.c
cmd/clk.c
cmd/clone.c
cmd/cros_ec.c
cmd/demo.c
cmd/exit.c
cmd/flash.c
cmd/gpio.c
cmd/gpt.c
cmd/i2c.c
cmd/led.c
cmd/legacy_led.c
cmd/load.c
cmd/log.c
cmd/mbr.c
cmd/mem.c
cmd/mmc.c
cmd/mp.c
cmd/nand.c
cmd/nvedit.c
cmd/optee_rpmb.c
cmd/osd.c
cmd/pcap.c
cmd/pstore.c
cmd/pwm.c
cmd/remoteproc.c
cmd/rtc.c
cmd/sata.c
cmd/sleep.c
cmd/sound.c
cmd/spi.c
cmd/ti/pd.c
cmd/tpm-common.c
cmd/ufs.c
cmd/usb.c
cmd/w1.c
common/bedbug.c
common/lcd_console.c
disk/part_amiga.c
drivers/dfu/dfu_mmc.c
drivers/dfu/dfu_mtd.c
drivers/dfu/dfu_nand.c
drivers/dfu/dfu_sf.c
drivers/dfu/dfu_virt.c
drivers/gpio/gpio-uclass.c
drivers/gpio/mxs_gpio.c
drivers/gpio/tca642x.c
drivers/net/e1000.c
drivers/net/fsl-mc/mc.c
drivers/net/netconsole.c
drivers/net/pfe_eth/pfe_firmware.c
drivers/net/phy/b53.c
drivers/net/phy/mv88e6352.c
drivers/net/qe/dm_qe_uec.c
drivers/pinctrl/nexell/pinctrl-nexell.c
drivers/pinctrl/pinctrl-uclass.c
drivers/ram/octeon/octeon_ddr.c
drivers/serial/serial-uclass.c
drivers/serial/serial.c
drivers/usb/cdns3/gadget.c
drivers/usb/gadget/epautoconf.c
drivers/usb/gadget/ether.c
drivers/video/vidconsole-uclass.c
examples/standalone/atmel_df_pow2.c
include/vsprintf.h
lib/dhry/cmd_dhry.c
lib/fdtdec.c
lib/net_utils.c
lib/strto.c
net/bootp.c
net/eth-uclass.c
net/eth_legacy.c
net/net.c
net/tftp.c
test/str_ut.c

index 0562d28..1641b65 100644 (file)
@@ -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;
 }
index 40df10d..1e3cfee 100644 (file)
@@ -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);
 }
index 29074fc..1e866b7 100644 (file)
@@ -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;
index 7c34ce6..507b5b4 100644 (file)
@@ -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);
index 7165d66..72dc394 100644 (file)
@@ -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,
index 339ae7f..3953aa9 100644 (file)
@@ -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));
index d5b46a8..24fa204 100644 (file)
@@ -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;
                }
index bf9a686..be53a52 100644 (file)
@@ -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;
index 96ebc6d..26fe8b6 100644 (file)
@@ -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;
index 68a7a78..7a8ec7f 100644 (file)
@@ -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");
index 24d1d57..ee8a9e0 100644 (file)
@@ -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;
index 5829299..b739bc3 100644 (file)
@@ -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);
index eee5c35..c93c0e5 100644 (file)
@@ -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:
index 582af6f..1a039c5 100644 (file)
@@ -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")) {
index 5206cf5..b41c64d 100644 (file)
@@ -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;
index cb9ebae..4ed3b9c 100644 (file)
@@ -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)
index 383a861..6c75231 100644 (file)
@@ -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;
index 4127fbc..6fdb110 100644 (file)
@@ -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)
index 9e73056..35df8ba 100644 (file)
@@ -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:
index ffed6b5..59fd1b6 100644 (file)
@@ -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, &reg, 1))
                        return CMD_RET_FAILURE;
index 6a0382d..912075d 100644 (file)
@@ -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;
index c75bc6f..271bc8c 100644 (file)
@@ -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())
index 658756d..1412421 100644 (file)
@@ -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);
 
index 1318ea7..0d77a57 100644 (file)
@@ -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)
index 90aab62..35e4cee 100644 (file)
@@ -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)
index cad16f9..dae064d 100644 (file)
@@ -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);
index b230a71..2b985b9 100644 (file)
@@ -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);
index e225838..fd54ac7 100644 (file)
@@ -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;
 
index 93eb20c..e4f9a0d 100644 (file)
@@ -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;
 }
index 1bf5436..8f624e5 100644 (file)
@@ -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:
index fecbbbd..e8e559c 100644 (file)
@@ -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 */
index 02b4b1f..783f51b 100644 (file)
--- 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;
 
index c676819..0c80fef 100644 (file)
--- 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:
index af2f22c..07c629e 100644 (file)
@@ -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);
index bb5adc3..592e914 100644 (file)
@@ -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);
index 0898798..4e442f2 100644 (file)
@@ -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",
index f4fe97d..071ba90 100644 (file)
--- 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;
index 7ece245..dbbdc31 100644 (file)
--- 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]);
 
index 32473a0..a906207 100644 (file)
@@ -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;
 
index abda5d6..a40f589 100644 (file)
@@ -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);
index a2957f7..571f562 100644 (file)
@@ -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);
index 923f087..2c71326 100644 (file)
@@ -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;
 }
index bc93e98..819febc 100644 (file)
@@ -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;
index 4fdb313..4150024 100644 (file)
@@ -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 {
index 17f2b83..f818fbb 100644 (file)
--- 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;
index 631222c..c7c08c4 100644 (file)
--- 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_LEGACY)
                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);
index aa77519..48a02ba 100644 (file)
--- 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);
index 86cd969..5256255 100644 (file)
@@ -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' */
index ec3eed1..381ed1b 100644 (file)
@@ -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)
index 72380c5..c377aee 100644 (file)
--- 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))
index da2e3a4..e7e2298 100644 (file)
--- 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;
index 0978df5..b751138 100644 (file)
--- 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);
index f722778..c67ad76 100644 (file)
--- 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)
index c2b5235..8d14401 100644 (file)
--- 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;
index 34371b9..d381053 100644 (file)
@@ -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;
index 02a99b4..ddc715b 100644 (file)
@@ -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 */
index 0d6b1cb..e0e44bb 100644 (file)
@@ -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;
 
index 8557894..c8c62d4 100644 (file)
--- 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);
index c751980..ab5c1a7 100644 (file)
@@ -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;
 }
index c6973ae..9fac8c7 100644 (file)
@@ -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;
                }
index e1f97c7..87d840a 100644 (file)
--- 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) {
index 2a0e575..ca3b436 100644 (file)
@@ -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);
index 784879e..75d4b64 100644 (file)
--- 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) {
index aa396c1..76da190 100644 (file)
@@ -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);
 
index 1fff400..c741b4a 100644 (file)
@@ -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], '.');
 
index fdcde36..f82f2aa 100644 (file)
@@ -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)
index 4aea191..bdbdbac 100644 (file)
--- 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++) {
index 9e820b8..008668f 100644 (file)
@@ -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];
index a48c060..1d5442c 100644 (file)
@@ -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)
index 858cd49..d4a1e66 100644 (file)
--- 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;
index b9ec29a..3d87376 100644 (file)
--- 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
index d0f0ee1..3209e65 100644 (file)
--- 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");
index 6e1fb58..c76fa48 100644 (file)
@@ -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;
index 1a246c4..9c0ff44 100644 (file)
@@ -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;
index 7eea60b..ac7ada5 100644 (file)
@@ -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;
 
index e63fa84..3dab5a5 100644 (file)
@@ -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, " ");
index a31d480..0b7f177 100644 (file)
@@ -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);
index 6ddf80b..e53b35e 100644 (file)
@@ -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);
index ef52319..7e64ab7 100644 (file)
@@ -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);
index 62605bc..80c99cb 100644 (file)
@@ -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;
index 131099c..8c77777 100644 (file)
@@ -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)) {
index 5775a22..7b9d88a 100644 (file)
@@ -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);
 }
index 7007c7a..7f67f96 100644 (file)
@@ -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:
index 60613b7..5bdcede 100644 (file)
@@ -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);
index 3712221..d52c986 100644 (file)
@@ -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
index f1d0630..cec96c5 100644 (file)
@@ -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 */
index ac86e33..ad5bc3c 100644 (file)
@@ -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
index 695fac4..c706e2b 100644 (file)
@@ -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
index 07a8e50..5606076 100644 (file)
@@ -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);
index eb0501b..a12c8cd 100644 (file)
@@ -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
index 6b01f47..20497a7 100644 (file)
@@ -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++)
index ea7275c..dfe60b6 100644 (file)
@@ -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;
        }
index e7b61d3..42daf06 100644 (file)
@@ -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;
index 2b4feac..8171b17 100644 (file)
@@ -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)
index dea25a0..ebbd219 100644 (file)
@@ -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)
index 83dbb5a..fcaeab9 100644 (file)
@@ -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)) {
index 7da334f..01337d6 100644 (file)
@@ -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) {
index 16922ff..4307328 100644 (file)
@@ -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 */
index 8f7d987..8132efa 100644 (file)
@@ -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;
index 9c74f49..dcb25da 100644 (file)
@@ -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");
index 5a268ab..c30e91f 100644 (file)
@@ -38,6 +38,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
  * @param base The number base to use
index d55ab54..77b52a2 100644 (file)
@@ -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);
index 4b097fb..07c7ebe 100644 (file)
@@ -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);
index f596c8f..72a3b09 100644 (file)
@@ -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;
index 57d6216..72903a5 100644 (file)
@@ -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;
@@ -164,7 +169,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);
                }
        }
 
index 163af41..655b9cc 100644 (file)
@@ -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;
 
index c2a97d7..0da0e85 100644 (file)
@@ -128,7 +128,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);
@@ -241,7 +241,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) {
index 96ed5a4..f383ccc 100644 (file)
@@ -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 {
index b58f306..c2992a0 100644 (file)
--- 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);
 }
index 00ab7ca..5baf528 100644 (file)
@@ -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);
                        }
index 4c3b566..19f2c12 100644 (file)
@@ -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);