From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/2] USB: gadget: fastboot: allow exporting only barebox update handler
Date: Sat, 30 Jul 2022 11:46:15 +0200 [thread overview]
Message-ID: <20220730094615.1762042-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220730094615.1762042-1-a.fatoum@pengutronix.de>
Exporting only the bbu handler and nothing else over fastboot
via usbgadget -A '' -b used to work. Restore this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/fastboot.c | 2 ++
drivers/usb/gadget/multi.c | 15 ++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/common/fastboot.c b/common/fastboot.c
index 330a06f5a32f..72e6ba3c402a 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -171,6 +171,8 @@ int fastboot_generic_init(struct fastboot *fb, bool export_bbu)
if (!fb->tempname)
return -ENOMEM;
+ if (!fb->files)
+ fb->files = file_list_new();
if (export_bbu)
bbu_append_handlers_to_file_list(fb->files);
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 102d8714f86d..6225e9a313a1 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -137,6 +137,12 @@ static int multi_bind_fastboot(struct usb_composite_dev *cdev)
return usb_add_function(&config, f_fastboot);
}
+static bool fastboot_has_exports(struct f_multi_opts *opts)
+{
+ return !file_list_empty(opts->fastboot_opts.files) ||
+ opts->fastboot_opts.export_bbu;
+}
+
static int multi_bind_ums(struct usb_composite_dev *cdev)
{
int ret;
@@ -179,7 +185,7 @@ static int multi_unbind(struct usb_composite_dev *cdev)
usb_put_function_instance(fi_dfu);
}
- if (gadget_multi_opts->fastboot_opts.files) {
+ if (fastboot_has_exports(gadget_multi_opts)) {
usb_put_function(f_fastboot);
usb_put_function_instance(fi_fastboot);
}
@@ -219,7 +225,7 @@ static int multi_bind(struct usb_composite_dev *cdev)
if (ret)
return ret;
- if (gadget_multi_opts->fastboot_opts.files) {
+ if (fastboot_has_exports(gadget_multi_opts)) {
printf("%s: creating Fastboot function\n", __func__);
ret = multi_bind_fastboot(cdev);
if (ret)
@@ -259,7 +265,7 @@ unbind_dfu:
if (gadget_multi_opts->dfu_opts.files)
usb_put_function_instance(fi_dfu);
unbind_fastboot:
- if (gadget_multi_opts->fastboot_opts.files)
+ if (fastboot_has_exports(gadget_multi_opts))
usb_put_function_instance(fi_fastboot);
return ret;
@@ -312,8 +318,7 @@ unsigned usb_multi_count_functions(struct f_multi_opts *opts)
{
unsigned count = 0;
- count += !file_list_empty(opts->fastboot_opts.files) ||
- opts->fastboot_opts.export_bbu;
+ count += fastboot_has_exports(opts);
count += !file_list_empty(opts->dfu_opts.files);
count += !file_list_empty(opts->ums_opts.files);
count += opts->create_acm;
--
2.30.2
next prev parent reply other threads:[~2022-07-30 9:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-30 9:46 [PATCH master 1/2] file_list: factor out file_list_new Ahmad Fatoum
2022-07-30 9:46 ` Ahmad Fatoum [this message]
2022-08-08 13:13 ` 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=20220730094615.1762042-2-a.fatoum@pengutronix.de \
--to=a.fatoum@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