Much of the fastboot code predates the introduction of Kconfig and
has quite a few #ifdefs in it which is unnecessary now that we can use
IS_ENABLED() et al.
Signed-off-by: Patrick Delaunay <patrick.delau...@foss.st.com>
---
cmd/fastboot.c | 35 +++++------
drivers/fastboot/fb_command.c | 104 ++++++++++++--------------------
drivers/fastboot/fb_common.c | 11 ++--
drivers/fastboot/fb_getvar.c | 49 ++++++---------
drivers/usb/gadget/f_fastboot.c | 7 +--
include/fastboot.h | 13 ----
net/fastboot.c | 8 +--
7 files changed, 82 insertions(+), 145 deletions(-)
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index b498e4b22bb3..b94dbd548843 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -19,8 +19,14 @@
static int do_fastboot_udp(int argc, char *const argv[],
uintptr_t buf_addr, size_t buf_size)
{
-#if CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)
- int err = net_loop(FASTBOOT);
+ int err;
+
+ if (!CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)) {
+ pr_err("Fastboot UDP not enabled\n");
+ return CMD_RET_FAILURE;
+ }
+
+ err = net_loop(FASTBOOT);
if (err < 0) {
printf("fastboot udp error: %d\n", err);
@@ -28,21 +34,21 @@ static int do_fastboot_udp(int argc, char *const
argv[],
}
return CMD_RET_SUCCESS;
-#else
- pr_err("Fastboot UDP not enabled\n");
- return CMD_RET_FAILURE;
-#endif
}
static int do_fastboot_usb(int argc, char *const argv[],
uintptr_t buf_addr, size_t buf_size)
{
-#if CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)
int controller_index;
char *usb_controller;
char *endp;
int ret;
+ if (!CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)) {
+ pr_err("Fastboot USB not enabled\n");
+ return CMD_RET_FAILURE;
+ }
+
if (argc < 2)
return CMD_RET_USAGE;
@@ -88,10 +94,6 @@ exit:
g_dnl_clear_detach();
return ret;
-#else
- pr_err("Fastboot USB not enabled\n");
- return CMD_RET_FAILURE;
-#endif
}
static int do_fastboot(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -148,17 +150,12 @@ NXTARG:
return do_fastboot_usb(argc, argv, buf_addr, buf_size);
}
-#ifdef CONFIG_SYS_LONGHELP
-static char fastboot_help_text[] =
+U_BOOT_CMD(
+ fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
+ "run as a fastboot usb or udp device",
"[-l addr] [-s size] usb <controller> | udp\n"
"\taddr - address of buffer used during data transfers ("
__stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
"\tsize - size of buffer used during data transfers ("
__stringify(CONFIG_FASTBOOT_BUF_SIZE) ")"
- ;
-#endif
-
-U_BOOT_CMD(
- fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
- "run as a fastboot usb or udp device", fastboot_help_text
);
diff --git a/drivers/fastboot/fb_command.c
b/drivers/fastboot/fb_command.c
index bdfdf262c8a3..f0fd605854da 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -31,27 +31,16 @@ static u32 fastboot_bytes_expected;
static void okay(char *, char *);
static void getvar(char *, char *);
static void download(char *, char *);
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
static void flash(char *, char *);
static void erase(char *, char *);
-#endif
static void reboot_bootloader(char *, char *);
static void reboot_fastbootd(char *, char *);
static void reboot_recovery(char *, char *);
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
static void oem_format(char *, char *);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
static void oem_partconf(char *, char *);
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
static void oem_bootbus(char *, char *);
-#endif
-
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
static void run_ucmd(char *, char *);
static void run_acmd(char *, char *);
-#endif
static const struct {
const char *command;
@@ -65,16 +54,14 @@ static const struct {
.command = "download",
.dispatch = download
},
-#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
[FASTBOOT_COMMAND_FLASH] = {
.command = "flash",
- .dispatch = flash
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (flash), (NULL))
},
[FASTBOOT_COMMAND_ERASE] = {
.command = "erase",
- .dispatch = erase
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (erase), (NULL))
},
-#endif
[FASTBOOT_COMMAND_BOOT] = {
.command = "boot",
.dispatch = okay
@@ -103,34 +90,26 @@ static const struct {
.command = "set_active",
.dispatch = okay
},
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
[FASTBOOT_COMMAND_OEM_FORMAT] = {
.command = "oem format",
- .dispatch = oem_format,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT,
(oem_format), (NULL))
},
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
[FASTBOOT_COMMAND_OEM_PARTCONF] = {
.command = "oem partconf",
- .dispatch = oem_partconf,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF,
(oem_partconf), (NULL))
},
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
[FASTBOOT_COMMAND_OEM_BOOTBUS] = {
.command = "oem bootbus",
- .dispatch = oem_bootbus,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS,
(oem_bootbus), (NULL))
},
-#endif
-#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
[FASTBOOT_COMMAND_UCMD] = {
.command = "UCmd",
- .dispatch = run_ucmd,
+ .dispatch =
CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPOR_______________________________________________
Uboot-stm32 mailing list
uboot-st...@st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
T, (run_ucmd), (NULL))
},
[FASTBOOT_COMMAND_ACMD] = {
.command = "ACmd",
- .dispatch = run_acmd,
+ .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT,
(run_acmd), (NULL))
},
-#endif