cmd: fuse: Remove custom string functions
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@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:

committed by
Tom Rini

parent
ee82a5a0ed
commit
005eeda378
39
cmd/fuse.c
39
cmd/fuse.c
@@ -15,17 +15,6 @@
|
|||||||
#include <vsprintf.h>
|
#include <vsprintf.h>
|
||||||
#include <linux/errno.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)
|
static int confirm_prog(void)
|
||||||
{
|
{
|
||||||
puts("Warning: Programming fuses is an irreversible operation!\n"
|
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;
|
argc -= 2 + confirmed;
|
||||||
argv += 2 + confirmed;
|
argv += 2 + confirmed;
|
||||||
|
|
||||||
if (argc < 2 || strtou32(argv[0], 0, &bank) ||
|
if (argc < 2)
|
||||||
strtou32(argv[1], 0, &word))
|
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
bank = simple_strtoul(argv[0], NULL, 0);
|
||||||
|
word = simple_strtoul(argv[1], NULL, 0);
|
||||||
|
|
||||||
if (!strcmp(op, "read")) {
|
if (!strcmp(op, "read")) {
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
cnt = 1;
|
cnt = 1;
|
||||||
else if (argc != 3 || strtou32(argv[2], 0, &cnt))
|
else if (argc == 3)
|
||||||
|
cnt = simple_strtoul(argv[2], NULL, 0);
|
||||||
|
else
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
printf("Reading bank %u:\n", bank);
|
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")) {
|
} else if (!strcmp(op, "readm")) {
|
||||||
if (argc == 3)
|
if (argc == 3)
|
||||||
cnt = 1;
|
cnt = 1;
|
||||||
else if (argc != 4 || strtou32(argv[3], 0, &cnt))
|
else if (argc == 4)
|
||||||
|
cnt = simple_strtoul(argv[3], NULL, 0);
|
||||||
|
else
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
addr = simple_strtoul(argv[2], NULL, 16);
|
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);
|
unmap_sysmem(start);
|
||||||
} else if (!strcmp(op, "cmp")) {
|
} else if (!strcmp(op, "cmp")) {
|
||||||
if (argc != 3 || strtou32(argv[2], 0, &cmp))
|
if (argc == 3)
|
||||||
|
cmp = simple_strtoul(argv[2], NULL, 0);
|
||||||
|
else
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
printf("Comparing bank %u:\n", bank);
|
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")) {
|
} else if (!strcmp(op, "sense")) {
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
cnt = 1;
|
cnt = 1;
|
||||||
else if (argc != 3 || strtou32(argv[2], 0, &cnt))
|
else if (argc == 3)
|
||||||
|
cnt = simple_strtoul(argv[2], NULL, 0);
|
||||||
|
else
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
printf("Sensing bank %u:\n", bank);
|
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;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
for (i = 2; i < argc; i++, word++) {
|
for (i = 2; i < argc; i++, word++) {
|
||||||
if (strtou32(argv[i], 16, &val))
|
val = simple_strtoul(argv[i], NULL, 16);
|
||||||
return CMD_RET_USAGE;
|
|
||||||
|
|
||||||
printf("Programming bank %u word 0x%.8x to 0x%.8x...\n",
|
printf("Programming bank %u word 0x%.8x to 0x%.8x...\n",
|
||||||
bank, word, val);
|
bank, word, val);
|
||||||
@@ -155,8 +153,7 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
for (i = 2; i < argc; i++, word++) {
|
for (i = 2; i < argc; i++, word++) {
|
||||||
if (strtou32(argv[i], 16, &val))
|
val = simple_strtoul(argv[i], NULL, 16);
|
||||||
return CMD_RET_USAGE;
|
|
||||||
|
|
||||||
printf("Overriding bank %u word 0x%.8x with "
|
printf("Overriding bank %u word 0x%.8x with "
|
||||||
"0x%.8x...\n", bank, word, val);
|
"0x%.8x...\n", bank, word, val);
|
||||||
|
Reference in New Issue
Block a user