aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 10:48:12 -0700
committerTom Rini <trini@konsulko.com>2023-01-23 18:11:41 -0500
commit35ce14617edb6ee7c3004c396f19d2c451255358 (patch)
treee371ab4f9a66b4806c9e60be57c5e5c8ff4f1b33
parent43e89a306903117c8cb7105004f236acf1ec3d00 (diff)
downloadu-boot-35ce14617edb6ee7c3004c396f19d2c451255358.zip
u-boot-35ce14617edb6ee7c3004c396f19d2c451255358.tar.gz
u-boot-35ce14617edb6ee7c3004c396f19d2c451255358.tar.bz2
extension: Refactor to allow non-command usage
The current extension code is designed to be used from commands. We want to add a boot driver which uses it. To help with this, split the code into the command processing and a function which actually does the scan. Really the extension code should be in common/ or use driver model, but this is a start. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--cmd/extension_board.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/cmd/extension_board.c b/cmd/extension_board.c
index f94abd6..f7685d4 100644
--- a/cmd/extension_board.c
+++ b/cmd/extension_board.c
@@ -80,8 +80,7 @@ static int do_extension_list(struct cmd_tbl *cmdtp, int flag,
return CMD_RET_SUCCESS;
}
-static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
- int argc, char *const argv[])
+static int extension_scan(bool show)
{
struct extension *extension, *next;
int extension_num;
@@ -91,12 +90,23 @@ static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
free(extension);
}
extension_num = extension_board_scan(&extension_list);
+ if (show && extension_num >= 0)
+ printf("Found %d extension board(s).\n", extension_num);
+
+ /* either the number of extensions, or -ve for error */
+ return extension_num;
+}
+
+static int do_extension_scan(struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
+{
+ int extension_num;
+
+ extension_num = extension_scan(true);
if (extension_num < 0)
return CMD_RET_FAILURE;
- printf("Found %d extension board(s).\n", extension_num);
-
return CMD_RET_SUCCESS;
}