Skip to content

Commit

Permalink
global: Convert simple_strtoul() with decimal to dectoul()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjg20 authored and trini committed Aug 2, 2021
1 parent 7e5f460 commit 0b1284e
Show file tree
Hide file tree
Showing 111 changed files with 255 additions and 230 deletions.
2 changes: 1 addition & 1 deletion arch/arm/cpu/armv8/fsl-layerscape/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/cmd_dek.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/cmd_mfgprot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/imx8/snvs_security_sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/mach-keystone/cmd_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-kirkwood/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-nexell/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/cpu/mpc83xx/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion board/Arcturus/ucp1020/ucp1020.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions board/BuS/eb_cpu5282/eb_cpu5282.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion board/atmel/common/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 12 additions & 12 deletions board/cavium/thunderx/atf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion board/compulab/common/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion board/compulab/common/omap3_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion board/davinci/da8xxevm/da850evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions board/freescale/common/pixis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion board/freescale/common/sys_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions board/gateworks/gw_ventana/gsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion board/gateworks/gw_ventana/gw_ventana.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion board/gateworks/venice/gsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
16 changes: 8 additions & 8 deletions board/gdsys/common/cmd_ioloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion board/samsung/common/exynos5-dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 0b1284e

Please sign in to comment.