summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_fastboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_fastboot.c')
-rw-r--r--drivers/usb/gadget/f_fastboot.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 598637619d..85c64c05c8 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -283,6 +283,21 @@ out:
return ret;
}
+static int fastboot_add_bbu_variables(struct bbu_handler *handler, void *ctx)
+{
+ struct f_fastboot *f_fb = ctx;
+ char *name;
+ int ret;
+
+ name = basprintf("bbu-%s", handler->name);
+
+ ret = file_list_add_entry(f_fb->files, name, handler->devicefile, 0);
+
+ free(name);
+
+ return ret;
+}
+
static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
{
struct usb_composite_dev *cdev = c->cdev;
@@ -302,6 +317,9 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
var = fb_addvar(f_fb, "bootloader-version");
fb_setvar(var, release_string);
+ if (IS_ENABLED(CONFIG_BAREBOX_UPDATE) && opts->export_bbu)
+ bbu_handlers_iterate(fastboot_add_bbu_variables, f_fb);
+
file_list_for_each_entry(f_fb->files, fentry) {
ret = fastboot_add_partition_variables(f_fb, fentry);
if (ret)
@@ -679,18 +697,15 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
fastboot_tx_print(f_fb, "INFOCopying file to %s...", cmd);
- file_list_for_each_entry(f_fb->files, fentry) {
- if (!strcmp(cmd, fentry->name)) {
- filename = fentry->filename;
- break;
- }
- }
+ fentry = file_list_entry_by_name(f_fb->files, cmd);
- if (!filename) {
+ if (!fentry) {
fastboot_tx_print(f_fb, "FAILNo such partition: %s", cmd);
return;
}
+ filename = fentry->filename;
+
if (filetype == filetype_ubi) {
int fd;
struct mtd_info_user meminfo;