From c4ed3b223126e69d697fbf482ab60e125bbe3d43 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sun, 7 Oct 2018 23:35:16 -0700 Subject: 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 Signed-off-by: Sascha Hauer --- commands/barebox-update.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'commands') diff --git a/commands/barebox-update.c b/commands/barebox-update.c index 84798ab0d9..903b4068df 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); -- cgit v1.2.3