diff options
author | Jules Maselbas <jmaselbas@kalray.eu> | 2021-09-10 12:29:31 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-10-05 13:51:12 +0200 |
commit | 096c889c7502fc87f446388493f5673656fffa31 (patch) | |
tree | d067d89ed93202d2c332f757f71ab25e48152329 /commands | |
parent | 5a5e67910d2e9e2584a2103c34c86eddaa43868c (diff) | |
download | barebox-096c889c7502fc87f446388493f5673656fffa31.tar.gz barebox-096c889c7502fc87f446388493f5673656fffa31.tar.xz |
usb: gadget: dfu: Rework dfu command to use usbgadget
The dfu command now uses the composite multi gadget to register the usb
functionality. This allows the removal of the usb composite driver from
dfu.c
As the dfu command is blocking the command slice must be released while
the dfu gadget is running in order to do operations on the file system.
The usb_dfu_register() function is replaced with usb_dfu_detached() for
the dfu command to return a different value depending on if it has been
interrupted with CTRL-C or if the gadget has been detached.
Tested-by: Anže Lešnik <anze.lesnik@norik.com>
Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
Link: https://lore.barebox.org/20210910102931.26078-1-jmaselbas@kalray.eu
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/dfu.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/commands/dfu.c b/commands/dfu.c index 3132a7479d..1734947fe0 100644 --- a/commands/dfu.c +++ b/commands/dfu.c @@ -11,6 +11,7 @@ #include <fs.h> #include <xfuncs.h> #include <usb/dfu.h> +#include <usb/gadget-multi.h> #include <linux/err.h> /* dfu /dev/self0(bootloader)sr,/dev/nand0.root.bb(root) @@ -20,28 +21,28 @@ */ static int do_dfu(int argc, char *argv[]) { - struct f_dfu_opts opts; - char *argstr; - struct usb_dfu_dev *dfu_alts = NULL; + struct usbgadget_funcs funcs = {}; int ret; if (argc != optind + 1) return COMMAND_ERROR_USAGE; - argstr = argv[optind]; + funcs.flags |= USBGADGET_DFU; + funcs.dfu_opts = argv[optind]; + ret = usbgadget_register(&funcs); + if (ret) + return ret; - opts.files = file_list_parse(argstr); - if (IS_ERR(opts.files)) { - ret = PTR_ERR(opts.files); - goto out; + command_slice_release(); + while (!usb_dfu_detached()) { + if (ctrlc()) { + ret = -EINTR; + break; + } } + command_slice_acquire(); - ret = usb_dfu_register(&opts); - - file_list_free(opts.files); -out: - - free(dfu_alts); + usb_multi_unregister(); return ret; } |