diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2021-07-18 07:13:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-07-18 07:13:14 +0200 |
commit | 889612fab092ec20463c886513b5cfde14cc8cb0 (patch) | |
tree | 069cb22123290fd999f4d03aa19a73be344c9ffb /common | |
parent | 8a5144d02a0146c4f0ec577232c0a102d12c8ee7 (diff) | |
parent | 8751ea38a38e2dd81c6a80848be760cc4d0aca2b (diff) | |
download | barebox-889612fab092ec20463c886513b5cfde14cc8cb0.tar.gz barebox-889612fab092ec20463c886513b5cfde14cc8cb0.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/bbu.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/common/bbu.c b/common/bbu.c index 1a1edda96b..cd7bdc40b7 100644 --- a/common/bbu.c +++ b/common/bbu.c @@ -4,6 +4,9 @@ * * Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix */ + +#define pr_fmt(fmt) "bbu: " fmt + #include <common.h> #include <bbu.h> #include <linux/list.h> @@ -32,12 +35,32 @@ static void append_bbu_entry(struct bbu_handler *handler, struct file_list *file free(name); } +static bool bbu_handler_is_available(struct bbu_handler *handler) +{ + struct stat s; + int ret; + + device_detect_by_name(devpath_to_name(handler->devicefile)); + + ret = stat(handler->devicefile, &s); + if (ret) + return false; + + return true; +} + void bbu_append_handlers_to_file_list(struct file_list *files) { struct bbu_handler *handler; - list_for_each_entry(handler, &bbu_image_handlers, list) - append_bbu_entry(handler, files); + list_for_each_entry(handler, &bbu_image_handlers, list) { + if (bbu_handler_is_available(handler)) { + append_bbu_entry(handler, files); + } else { + pr_info("Skipping unavailable handler bbu-%s\n", + handler->name); + } + } } int bbu_force(struct bbu_data *data, const char *fmt, ...) |