U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Harsha Vardhan V M <h-vm@ti.com>
To: <u-boot@lists.denx.de>
Cc: <trini@konsulko.com>, <vigneshr@ti.com>, <k-malarvizhi@ti.com>,
	<kamlesh@ti.com>
Subject: [RFC PATCH v2 1/5] cmd: fuse: Remove custom string functions
Date: Fri, 14 Mar 2025 19:27:02 +0530	[thread overview]
Message-ID: <20250314135706.184807-2-h-vm@ti.com> (raw)
In-Reply-To: <20250314135706.184807-1-h-vm@ti.com>

Remove custom string functions and replace them with normal string
functions. Remove the custom strtou32 and replace it with str2long.

Signed-off-by: Harsha Vardhan V M <h-vm@ti.com>
---
 cmd/fuse.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/cmd/fuse.c b/cmd/fuse.c
index 598ef496a43..9f489570634 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,14 @@ 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 || !(str2long(argv[0], (ulong *)&bank)) ||
+			!(str2long(argv[1], (ulong *)&word)))
 		return CMD_RET_USAGE;
 
 	if (!strcmp(op, "read")) {
 		if (argc == 2)
 			cnt = 1;
-		else if (argc != 3 || strtou32(argv[2], 0, &cnt))
+		else if (argc != 3 || !(str2long(argv[2], (ulong *)&cnt)))
 			return CMD_RET_USAGE;
 
 		printf("Reading bank %u:\n", bank);
@@ -79,7 +68,7 @@ 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 || !(str2long(argv[3], (ulong *)&cnt)))
 			return CMD_RET_USAGE;
 
 		addr = simple_strtoul(argv[2], NULL, 16);
@@ -99,7 +88,7 @@ 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 || !(str2long(argv[2], (ulong *)&cmp)))
 			return CMD_RET_USAGE;
 
 		printf("Comparing bank %u:\n", bank);
@@ -119,7 +108,7 @@ 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 || !(str2long(argv[2], (ulong *)&cnt)))
 			return CMD_RET_USAGE;
 
 		printf("Sensing bank %u:\n", bank);
@@ -139,7 +128,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))
+			if (!(str2long(argv[i], (ulong *)&val)))
 				return CMD_RET_USAGE;
 
 			printf("Programming bank %u word 0x%.8x to 0x%.8x...\n",
@@ -155,7 +144,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))
+			if (!(str2long(argv[i], (ulong *)&val)))
 				return CMD_RET_USAGE;
 
 			printf("Overriding bank %u word 0x%.8x with "
-- 
2.34.1


  reply	other threads:[~2025-03-14 13:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-14 13:57 [RFC PATCH v2 0/5] cmd: fuse: Introduce fuse writebuff sub-system and clean up Harsha Vardhan V M
2025-03-14 13:57 ` Harsha Vardhan V M [this message]
2025-03-14 13:57 ` [RFC PATCH v2 2/5] doc: cmd: add documentation for fuse command Harsha Vardhan V M
2025-03-14 16:38   ` Tom Rini
2025-03-17  9:04     ` Harsha Vardhan V M
2025-03-14 13:57 ` [RFC PATCH v2 3/5] cmd: fuse: Add fuse writebuff sub-system command Harsha Vardhan V M
2025-03-14 13:57 ` [RFC PATCH v2 4/5] drivers: k3_fuse: Add fuse sub-system func calls Harsha Vardhan V M
2025-03-14 13:57 ` [RFC PATCH v2 5/5] doc: cmd: add fuse writebuff cmd documentation Harsha Vardhan V M

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250314135706.184807-2-h-vm@ti.com \
    --to=h-vm@ti.com \
    --cc=k-malarvizhi@ti.com \
    --cc=kamlesh@ti.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox