diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-06-22 10:26:16 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-06-25 09:31:03 +0200 |
commit | a62e5d2f3350bffb7be52397066f9900e1908348 (patch) | |
tree | a31ee922bd2926f4ab42ad3a05f167d89fea4f65 /commands | |
parent | aa649b826c535810b59a107a67cc90079a0681e5 (diff) | |
download | barebox-a62e5d2f3350bffb7be52397066f9900e1908348.tar.gz barebox-a62e5d2f3350bffb7be52397066f9900e1908348.tar.xz |
usbgadget: refactor usbgadget_register to accept array
usbgadget_register currently takes 6 arguments. Instead of increasing
them to 8 to support the new usb mass storage gadget, rewrite it to
accept a pointer to a struct with all the options instead.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210622082617.18011-8-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/usbgadget.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/commands/usbgadget.c b/commands/usbgadget.c index 3b115f147d..07094026db 100644 --- a/commands/usbgadget.c +++ b/commands/usbgadget.c @@ -18,26 +18,25 @@ static int do_usbgadget(int argc, char *argv[]) { + struct usbgadget_funcs funcs = {}; int opt; - bool acm = false, dfu = false, fastboot = false, export_bbu = false; - const char *fastboot_opts = NULL, *dfu_opts = NULL; while ((opt = getopt(argc, argv, "asdA::D::b")) > 0) { switch (opt) { case 'a': case 's': - acm = true; + funcs.flags |= USBGADGET_ACM; break; case 'D': - dfu = true; - dfu_opts = optarg; + funcs.flags |= USBGADGET_DFU; + funcs.dfu_opts = optarg; break; case 'A': - fastboot = true; - fastboot_opts = optarg; + funcs.flags |= USBGADGET_FASTBOOT; + funcs.fastboot_opts = optarg; break; case 'b': - export_bbu = true; + funcs.flags |= USBGADGET_EXPORT_BBU; break; case 'd': usb_multi_unregister(); @@ -47,8 +46,8 @@ static int do_usbgadget(int argc, char *argv[]) } } - return usbgadget_register(dfu, dfu_opts, fastboot, fastboot_opts, acm, - export_bbu); + + return usbgadget_register(&funcs); } BAREBOX_CMD_HELP_START(usbgadget) |