diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-06-22 10:26:17 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-25 09:31:03 +0200 |
commit | 57313f83e83e1fac87c1a9088175f12ebd3577a0 (patch) | |
tree | 482524b18f1763b804cc039fd433420f85ce2264 /common | |
parent | a62e5d2f3350bffb7be52397066f9900e1908348 (diff) | |
download | barebox-57313f83e83e1fac87c1a9088175f12ebd3577a0.tar.gz barebox-57313f83e83e1fac87c1a9088175f12ebd3577a0.tar.xz |
usbgadget: add support for USB mass storage gadget
This driver is based on the f_mass_storage drivers in Linux v5.11 and
U-Boot v2021.01.
Unlike the U-Boot version, it runs asynchronously without blocking the
bootloader from doing other tasks, like exporting other USB gadgets at
the same time or enabling shell access.
With pollers and workqueues, enabling this would need a large rework
of the code to be completely callback based, whenever the original
Linux code sleeps waiting for events. With the new bthread support,
we can actually sleep and handover control to other bthreads until
there is actual work to do.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210622082617.18011-9-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/usbgadget.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/usbgadget.c b/common/usbgadget.c index 9bbaa4ea12..34a685234b 100644 --- a/common/usbgadget.c +++ b/common/usbgadget.c @@ -66,6 +66,14 @@ int usbgadget_register(const struct usbgadget_funcs *funcs) } } + if (flags & USBGADGET_MASS_STORAGE) { + opts->ums_opts.files = parse(funcs->ums_opts); + if (IS_ENABLED(CONFIG_USB_GADGET_MASS_STORAGE) && file_list_empty(opts->ums_opts.files)) { + file_list_free(opts->ums_opts.files); + opts->ums_opts.files = system_partitions_get(); + } + } + if (flags & USBGADGET_FASTBOOT) { opts->fastboot_opts.files = parse(funcs->fastboot_opts); if (IS_ENABLED(CONFIG_FASTBOOT_BASE) && file_list_empty(opts->fastboot_opts.files)) { @@ -122,7 +130,7 @@ static int usbgadget_autostart_set(struct param_d *param, void *ctx) if (acm) funcs.flags |= USBGADGET_ACM; - funcs.flags |= USBGADGET_DFU | USBGADGET_FASTBOOT; + funcs.flags |= USBGADGET_DFU | USBGADGET_FASTBOOT | USBGADGET_MASS_STORAGE; err = usbgadget_register(&funcs); if (!err) |