From 473da9de5b9b5e0266767c1bdf5fc8882fb43a16 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Wed, 17 Feb 2016 12:28:17 +0100 Subject: bbu: Add barebox_update search by device bbu_data includes a devicefile information. Add the possibility to make an update based on the given devicefile. This is in addition to the normal search for a barebox update handler by its name. Signed-off-by: Markus Pargmann Signed-off-by: Sascha Hauer --- common/bbu.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'common/bbu.c') diff --git a/common/bbu.c b/common/bbu.c index 4d71fa4a87..bf3790d13f 100644 --- a/common/bbu.c +++ b/common/bbu.c @@ -97,6 +97,20 @@ static struct bbu_handler *bbu_find_handler(const char *name) return NULL; } +static struct bbu_handler *bbu_find_handler_by_device(const char *devicepath) +{ + struct bbu_handler *handler; + + if (!devicepath) + return NULL; + + list_for_each_entry(handler, &bbu_image_handlers, list) + if (!strcmp(handler->devicefile, devicepath)) + return handler; + + return NULL; +} + /* * do a barebox update with data from *data */ @@ -105,7 +119,11 @@ int barebox_update(struct bbu_data *data) struct bbu_handler *handler; int ret; - handler = bbu_find_handler(data->handler_name); + handler = bbu_find_handler_by_device(data->devicefile); + + if (!handler) + handler = bbu_find_handler(data->handler_name); + if (!handler) return -ENODEV; -- cgit v1.2.3 From 7290110f1a6f4643beb7695ba7d26e472f8290c6 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Wed, 17 Feb 2016 12:28:18 +0100 Subject: bbu: Add function to check if an update handler exists This adds a function to check for the existence of an update handler based on the supplied bbu_data. Signed-off-by: Markus Pargmann Signed-off-by: Sascha Hauer --- common/bbu.c | 14 ++++++++++++++ include/bbu.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'common/bbu.c') diff --git a/common/bbu.c b/common/bbu.c index bf3790d13f..a7f6b4b851 100644 --- a/common/bbu.c +++ b/common/bbu.c @@ -111,6 +111,20 @@ static struct bbu_handler *bbu_find_handler_by_device(const char *devicepath) return NULL; } +bool barebox_update_handler_exists(struct bbu_data *data) +{ + struct bbu_handler *handler; + + handler = bbu_find_handler_by_device(data->devicefile); + if (handler) + return true; + + if (!data->handler_name) + return false; + + return !bbu_find_handler(data->handler_name); +} + /* * do a barebox update with data from *data */ diff --git a/include/bbu.h b/include/bbu.h index 7277911718..0fe7a1a9bc 100644 --- a/include/bbu.h +++ b/include/bbu.h @@ -36,6 +36,8 @@ int bbu_confirm(struct bbu_data *); int barebox_update(struct bbu_data *); +bool barebox_update_handler_exists(struct bbu_data *); + void bbu_handlers_list(void); #ifdef CONFIG_BAREBOX_UPDATE -- cgit v1.2.3