mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 10/12] usbgadget: fastboot: Allow to automatically export the bbu handlers
Date: Wed, 27 Sep 2017 14:09:08 +0200	[thread overview]
Message-ID: <20170927120910.10516-11-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170927120910.10516-1-s.hauer@pengutronix.de>

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>
---
 drivers/usb/gadget/f_fastboot.c | 18 ++++++++++++++++++
 drivers/usb/gadget/multi.c      |  1 +
 include/usb/fastboot.h          |  7 +++++++
 3 files changed, 26 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 0f2c02ee47..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)
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 6eeeb4e982..44969be0c9 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 dab5a9a299..ced890c9ab 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 */
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-09-27 12:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 12:08 usbgadget: fastboot: Allow to automatically export " Sascha Hauer
2017-09-27 12:08 ` [PATCH 01/12] file_list: Add function to add an entry to the list Sascha Hauer
2017-09-27 12:09 ` [PATCH 02/12] file_list: Add function to get entry by its name Sascha Hauer
2017-09-27 12:09 ` [PATCH 03/12] file_list: Allow only unique names on list Sascha Hauer
2017-09-27 12:09 ` [PATCH 04/12] file_list: Fix memory leak in failure path Sascha Hauer
2017-09-27 12:09 ` [PATCH 05/12] file_list: Add GPL header to file Sascha Hauer
2017-09-27 12:09 ` [PATCH 06/12] file_list: Add error messages Sascha Hauer
2017-09-27 12:09 ` [PATCH 07/12] usbgadget: fastboot: Use function to find file_list entry by name Sascha Hauer
2017-09-27 12:09 ` [PATCH 08/12] bbu: Add function to iterate over registered handlers Sascha Hauer
2017-09-27 12:09 ` [PATCH 09/12] usbgadget command: catch errors when parsing the file list Sascha Hauer
2017-09-27 12:09 ` Sascha Hauer [this message]
2017-09-27 12:09 ` [PATCH 11/12] fastboot command: Add -b option to export bbu handlers Sascha Hauer
2017-09-27 12:09 ` [PATCH 12/12] usbgadget autostart: add usbgadget.fastboot_bbu to automatically " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170927120910.10516-11-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox