[RFC PATCH v3 1/5] cmd: fuse: Remove custom string functions
Harsha Vardhan V M
h-vm at ti.com
Tue Mar 18 11:50:43 CET 2025
Remove custom string functions and replace them with normal string
functions. Remove the custom strtou32 and replace it with
simple_strtoul.
Signed-off-by: Harsha Vardhan V M <h-vm at ti.com>
---
cmd/fuse.c | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/cmd/fuse.c b/cmd/fuse.c
index 598ef496a43..9825477c8da 100644
--- a/cmd/fuse.c
+++ b/cmd/fuse.c
@@ -15,17 +15,6 @@
#include <vsprintf.h>
#include <linux/errno.h>
-static int strtou32(const char *str, unsigned int base, u32 *result)
-{
- char *ep;
-
- *result = simple_strtoul(str, &ep, base);
- if (ep == str || *ep != '\0')
- return -EINVAL;
-
- return 0;
-}
-
static int confirm_prog(void)
{
puts("Warning: Programming fuses is an irreversible operation!\n"
@@ -54,14 +43,18 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
argc -= 2 + confirmed;
argv += 2 + confirmed;
- if (argc < 2 || strtou32(argv[0], 0, &bank) ||
- strtou32(argv[1], 0, &word))
+ if (argc < 2)
return CMD_RET_USAGE;
+ bank = (u32)simple_strtoul(argv[0], NULL, 0);
+ word = (u32)simple_strtoul(argv[1], NULL, 0);
+
if (!strcmp(op, "read")) {
if (argc == 2)
cnt = 1;
- else if (argc != 3 || strtou32(argv[2], 0, &cnt))
+ else if (argc == 3)
+ cnt = (u32)simple_strtoul(argv[2], NULL, 0);
+ else
return CMD_RET_USAGE;
printf("Reading bank %u:\n", bank);
@@ -79,7 +72,9 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
} else if (!strcmp(op, "readm")) {
if (argc == 3)
cnt = 1;
- else if (argc != 4 || strtou32(argv[3], 0, &cnt))
+ else if (argc == 4)
+ cnt = (u32)simple_strtoul(argv[3], NULL, 0);
+ else
return CMD_RET_USAGE;
addr = simple_strtoul(argv[2], NULL, 16);
@@ -99,7 +94,9 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
unmap_sysmem(start);
} else if (!strcmp(op, "cmp")) {
- if (argc != 3 || strtou32(argv[2], 0, &cmp))
+ if (argc == 3)
+ cmp = (u32)simple_strtoul(argv[2], NULL, 0);
+ else
return CMD_RET_USAGE;
printf("Comparing bank %u:\n", bank);
@@ -119,7 +116,9 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
} else if (!strcmp(op, "sense")) {
if (argc == 2)
cnt = 1;
- else if (argc != 3 || strtou32(argv[2], 0, &cnt))
+ else if (argc == 3)
+ cnt = (u32)simple_strtoul(argv[2], NULL, 0);
+ else
return CMD_RET_USAGE;
printf("Sensing bank %u:\n", bank);
@@ -139,8 +138,7 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_USAGE;
for (i = 2; i < argc; i++, word++) {
- if (strtou32(argv[i], 16, &val))
- return CMD_RET_USAGE;
+ val = (u32)simple_strtoul(argv[i], NULL, 16);
printf("Programming bank %u word 0x%.8x to 0x%.8x...\n",
bank, word, val);
@@ -155,8 +153,7 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_USAGE;
for (i = 2; i < argc; i++, word++) {
- if (strtou32(argv[i], 16, &val))
- return CMD_RET_USAGE;
+ val = (u32)simple_strtoul(argv[i], NULL, 16);
printf("Overriding bank %u word 0x%.8x with "
"0x%.8x...\n", bank, word, val);
--
2.34.1
More information about the U-Boot
mailing list