diff mbox series

[RESEND,7/7] fastboot: Implement generic fastboot_set_reboot_flag

Message ID 56991dc2a425578649ae5dcbc02901cba800294d.1603442753.git.roman.kovalivskyi@globallogic.com
State Changes Requested
Delegated to: Lukasz Majewski
Headers show
Series Refactor generic fastboot_set_reboot_flag implementation | expand

Commit Message

Roman Kovalivskyi Oct. 23, 2020, 8:52 a.m. UTC
It is possible to implement fastboot_set_reboot_flag in a generic way
if BCB commands are turned on for a target. Using
bcb_set_reboot_reason allows to do this by simply passing string with
correct reboot reason that should be handled during next boot process.

If BCB are turned off, then bcb_set_reboot_reason would simply return
error, so it won't introduce any new behaviour for such targets.

Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
---
 drivers/fastboot/fb_common.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Lukasz Majewski Jan. 23, 2021, 3:11 p.m. UTC | #1
Hi Roman,

> It is possible to implement fastboot_set_reboot_flag in a generic way
> if BCB commands are turned on for a target. Using
> bcb_set_reboot_reason allows to do this by simply passing string with
> correct reboot reason that should be handled during next boot process.
> 
> If BCB are turned off, then bcb_set_reboot_reason would simply return
> error, so it won't introduce any new behaviour for such targets.
> 
> Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
> ---
>  drivers/fastboot/fb_common.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/fastboot/fb_common.c
> b/drivers/fastboot/fb_common.c index 736ce1cd024f..005dccf3c967 100644
> --- a/drivers/fastboot/fb_common.c
> +++ b/drivers/fastboot/fb_common.c
> @@ -10,6 +10,7 @@
>   * Rob Herring <robh@kernel.org>
>   */
>  
> +#include <bcb.h>
>  #include <common.h>
>  #include <command.h>
>  #include <env.h>
> @@ -90,7 +91,16 @@ void fastboot_okay(const char *reason, char
> *response) */
>  int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason
> reason) {
> -	return -ENOSYS;
> +	static const char * const boot_cmds[] = {
> +		[FASTBOOT_REBOOT_REASON_BOOTLOADER] =
> "bootonce-bootloader",
> +		[FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot",
> +		[FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery"
> +	};
> +
> +	if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
> +		return -EINVAL;
> +
> +	return
> bcb_write_reboot_reason(CONFIG_FASTBOOT_FLASH_MMC_DEV, "misc",
> boot_cmds[reason]); } 
>  /**

This patch causes build breaks when I run the CI on azzure. If it is
still needed, please rebase it and resend.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff mbox series

Patch

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 736ce1cd024f..005dccf3c967 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -10,6 +10,7 @@ 
  * Rob Herring <robh@kernel.org>
  */
 
+#include <bcb.h>
 #include <common.h>
 #include <command.h>
 #include <env.h>
@@ -90,7 +91,16 @@  void fastboot_okay(const char *reason, char *response)
  */
 int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
 {
-	return -ENOSYS;
+	static const char * const boot_cmds[] = {
+		[FASTBOOT_REBOOT_REASON_BOOTLOADER] = "bootonce-bootloader",
+		[FASTBOOT_REBOOT_REASON_FASTBOOTD] = "boot-fastboot",
+		[FASTBOOT_REBOOT_REASON_RECOVERY] = "boot-recovery"
+	};
+
+	if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
+		return -EINVAL;
+
+	return bcb_write_reboot_reason(CONFIG_FASTBOOT_FLASH_MMC_DEV, "misc", boot_cmds[reason]);
 }
 
 /**