[PATCH 1/4] barebox update: fix finding default handler
Sascha Hauer
s.hauer at pengutronix.de
Thu Nov 29 14:01:21 EST 2012
It was not possible to register another handler when already
a default handler is registered. Fix this.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/bbu.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/common/bbu.c b/common/bbu.c
index 92f8d2b..e31f645 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -71,13 +71,13 @@ int bbu_confirm(struct bbu_data *data)
return -EINTR;
}
-static struct bbu_handler *bbu_find_handler(const char *name, unsigned long flags)
+static struct bbu_handler *bbu_find_handler(const char *name)
{
struct bbu_handler *handler;
list_for_each_entry(handler, &bbu_image_handlers, list) {
if (!name) {
- if (flags & BBU_HANDLER_FLAG_DEFAULT)
+ if (handler->flags & BBU_HANDLER_FLAG_DEFAULT)
return handler;
continue;
}
@@ -97,10 +97,13 @@ int barebox_update(struct bbu_data *data)
struct bbu_handler *handler;
int ret;
- handler = bbu_find_handler(data->handler_name, data->flags);
+ handler = bbu_find_handler(data->handler_name);
if (!handler)
return -ENODEV;
+ if (!data->handler_name)
+ data->handler_name = handler->name;
+
if (!data->devicefile)
data->devicefile = handler->devicefile;
@@ -137,11 +140,11 @@ void bbu_handlers_list(void)
*/
int bbu_register_handler(struct bbu_handler *handler)
{
- if (bbu_find_handler(handler->name, 0))
+ if (bbu_find_handler(handler->name))
return -EBUSY;
if (handler->flags & BBU_HANDLER_FLAG_DEFAULT &&
- bbu_find_handler(NULL, BBU_HANDLER_FLAG_DEFAULT))
+ bbu_find_handler(NULL))
return -EBUSY;
list_add_tail(&handler->list, &bbu_image_handlers);
--
1.7.10.4
More information about the barebox
mailing list