summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorEugeniu Rosca <erosca@de.adit-jv.com>2020-10-23 11:52:20 +0300
committerMarek Vasut <marex@denx.de>2021-01-31 16:08:56 +0300
commit02ebe6deae994c377dedafa7df4abd70fd2e3f44 (patch)
tree6862438598750b70dd8dd29c47c3c6d4292354c3 /cmd
parent24e85bbd6943a576f5a8451172f256f66471b0b2 (diff)
downloadu-boot-02ebe6deae994c377dedafa7df4abd70fd2e3f44.tar.xz
cmd: bcb: Extract '__bcb_set' from 'do_bcb_set' for internal needs
Enriching the functionality of U-Boot 'bcb' may assume using the existing sub-commands as building blocks for the next ones. A clean way to achive the above is to expose a number of static routines, each mapped to an existing user command (e.g. load/set/store), with a user/caller-friendly prototype (i.e. do not force the caller to wrap an integer into a string). This second patch makes '__bcb_set' available for internal needs. No functional change intended. Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bcb.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/cmd/bcb.c b/cmd/bcb.c
index 2ed8b801a3..113f04ffe6 100644
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -178,22 +178,21 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
return __bcb_load(devnum, argv[2]);
}
-static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
+static int __bcb_set(char *fieldp, char *valp)
{
int size, len;
char *field, *str, *found;
- if (bcb_field_get(argv[1], &field, &size))
+ if (bcb_field_get(fieldp, &field, &size))
return CMD_RET_FAILURE;
- len = strlen(argv[2]);
+ len = strlen(valp);
if (len >= size) {
printf("Error: sizeof('%s') = %d >= %d = sizeof(bcb.%s)\n",
- argv[2], len, size, argv[1]);
+ valp, len, size, fieldp);
return CMD_RET_FAILURE;
}
- str = argv[2];
+ str = valp;
field[0] = '\0';
while ((found = strsep(&str, ":"))) {
@@ -205,6 +204,12 @@ static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}
+static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ return __bcb_set(argv[1], argv[2]);
+}
+
static int do_bcb_clear(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{