barebox update: fix finding default handler
It was not possible to register another handler when already a default handler is registered. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
cf425e1615
commit
d5af695a87
13
common/bbu.c
13
common/bbu.c
|
@ -71,13 +71,13 @@ int bbu_confirm(struct bbu_data *data)
|
||||||
return -EINTR;
|
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;
|
struct bbu_handler *handler;
|
||||||
|
|
||||||
list_for_each_entry(handler, &bbu_image_handlers, list) {
|
list_for_each_entry(handler, &bbu_image_handlers, list) {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
if (flags & BBU_HANDLER_FLAG_DEFAULT)
|
if (handler->flags & BBU_HANDLER_FLAG_DEFAULT)
|
||||||
return handler;
|
return handler;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,13 @@ int barebox_update(struct bbu_data *data)
|
||||||
struct bbu_handler *handler;
|
struct bbu_handler *handler;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
handler = bbu_find_handler(data->handler_name, data->flags);
|
handler = bbu_find_handler(data->handler_name);
|
||||||
if (!handler)
|
if (!handler)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
if (!data->handler_name)
|
||||||
|
data->handler_name = handler->name;
|
||||||
|
|
||||||
if (!data->devicefile)
|
if (!data->devicefile)
|
||||||
data->devicefile = handler->devicefile;
|
data->devicefile = handler->devicefile;
|
||||||
|
|
||||||
|
@ -137,11 +140,11 @@ void bbu_handlers_list(void)
|
||||||
*/
|
*/
|
||||||
int bbu_register_handler(struct bbu_handler *handler)
|
int bbu_register_handler(struct bbu_handler *handler)
|
||||||
{
|
{
|
||||||
if (bbu_find_handler(handler->name, 0))
|
if (bbu_find_handler(handler->name))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
if (handler->flags & BBU_HANDLER_FLAG_DEFAULT &&
|
if (handler->flags & BBU_HANDLER_FLAG_DEFAULT &&
|
||||||
bbu_find_handler(NULL, BBU_HANDLER_FLAG_DEFAULT))
|
bbu_find_handler(NULL))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
list_add_tail(&handler->list, &bbu_image_handlers);
|
list_add_tail(&handler->list, &bbu_image_handlers);
|
||||||
|
|
Loading…
Reference in New Issue