summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-09-27 12:56:30 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-09-27 14:02:21 +0200
commit470ac4a7ba37dc1c09f2d59ba0f7bf7519d45d92 (patch)
tree11d2a70f30857d80e8a849126bdd2e3204b7b798
parent02ade8d921def6b826163302afe6914a3543d175 (diff)
downloadbarebox-470ac4a7ba37dc1c09f2d59ba0f7bf7519d45d92.tar.gz
usbgadget: fastboot: Allow to automatically export the bbu handlers
We have a list of registered handlers which take a barebox update. Do the next step and allow to automatically export them via fastboot so that barebox can be updated via fastboot without manually exporting the partition. Since this may not be desirable in all cases this behaviour is configurable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/usb/gadget/f_fastboot.c18
-rw-r--r--drivers/usb/gadget/multi.c1
-rw-r--r--include/usb/fastboot.h7
3 files changed, 26 insertions, 0 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 0f2c02e..85c64c0 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)
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 6eeeb4e..44969be 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -128,6 +128,7 @@ static int multi_bind_fastboot(struct usb_composite_dev *cdev)
opts = container_of(fi_fastboot, struct f_fastboot_opts, func_inst);
opts->files = gadget_multi_opts->fastboot_opts.files;
+ opts->export_bbu = gadget_multi_opts->fastboot_opts.export_bbu;
f_fastboot = usb_get_function(fi_fastboot);
if (IS_ERR(f_fastboot)) {
diff --git a/include/usb/fastboot.h b/include/usb/fastboot.h
index dab5a9a..ced890c 100644
--- a/include/usb/fastboot.h
+++ b/include/usb/fastboot.h
@@ -5,9 +5,16 @@
#include <file-list.h>
#include <usb/composite.h>
+/**
+ * struct f_fastboot_opts - options to configure the fastboot gadget
+ * @func_inst: The USB function instance to register on
+ * @files: A file_list containing the files (partitions) to export via fastboot
+ * @export_bbu: Automatically include the partitions provided by barebox update (bbu)
+ */
struct f_fastboot_opts {
struct usb_function_instance func_inst;
struct file_list *files;
+ bool export_bbu;
};
#endif /* _USB_FASTBOOT_H */