summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-10-07 23:35:16 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-10-08 10:07:12 +0200
commitc4ed3b223126e69d697fbf482ab60e125bbe3d43 (patch)
treea4147091bdb2051dbb331aaedb987106cf978079 /commands
parent76b44a34fc00772319395a84e67b8f816804f5bc (diff)
downloadbarebox-c4ed3b223126e69d697fbf482ab60e125bbe3d43.tar.gz
bbu: Add "handler" parameter to barebox_update()
Add "handler" parameter to barebox_update() and remove the code that was respondible for header lookup before. With this change finding appropriate handler is caller's responsibility, which makes it possible to implement custom handler lookup/existence check, chache it, and then re-use it without calling handler_find_by_* functions for the second time. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/barebox-update.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/commands/barebox-update.c b/commands/barebox-update.c
index 84798ab..903b406 100644
--- a/commands/barebox-update.c
+++ b/commands/barebox-update.c
@@ -28,6 +28,7 @@ static int do_barebox_update(int argc, char *argv[])
{
int opt, ret, repair = 0;
struct bbu_data data = {};
+ struct bbu_handler *handler;
void *image = NULL;
while ((opt = getopt(argc, argv, "t:yf:ld:r")) > 0) {
@@ -69,7 +70,15 @@ static int do_barebox_update(int argc, char *argv[])
return COMMAND_ERROR_USAGE;
}
- ret = barebox_update(&data);
+ handler = bbu_find_handler_by_device(data.devicefile);
+
+ if (!handler)
+ handler = bbu_find_handler_by_name(data.handler_name);
+
+ if (!handler)
+ return COMMAND_ERROR_USAGE;
+
+ ret = barebox_update(&data, handler);
free(image);