summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-22 10:26:16 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-25 09:31:03 +0200
commita62e5d2f3350bffb7be52397066f9900e1908348 (patch)
treea31ee922bd2926f4ab42ad3a05f167d89fea4f65 /commands
parentaa649b826c535810b59a107a67cc90079a0681e5 (diff)
downloadbarebox-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.c19
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)