diff mbox series

ARM: imx8m: support env in fat and ext4

Message ID 20211020191626.3648540-1-ricardo@foundries.io
State Accepted
Commit 89ca5a7ee1899eec5b2bb7dcfd3ff9cb78231885
Delegated to: Stefano Babic
Headers show
Series ARM: imx8m: support env in fat and ext4 | expand

Commit Message

Ricardo Salveti Oct. 20, 2021, 7:16 p.m. UTC
Change boot device logic to also allow environment stored in fat and in
ext4 when booting from SD or from eMMC.

As the boot device check for SD and for eMMC was depending on
ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location
to use IS_ENABLED instead for all modes, returning NOWHERE when no valid
mode is found.

Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
---
 arch/arm/mach-imx/imx8m/soc.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

Comments

Oleksandr Suvorov Oct. 21, 2021, 8:38 a.m. UTC | #1
On Wed, Oct 20, 2021 at 10:17 PM Ricardo Salveti <ricardo@foundries.io> wrote:
>
> Change boot device logic to also allow environment stored in fat and in
> ext4 when booting from SD or from eMMC.
>
> As the boot device check for SD and for eMMC was depending on
> ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location
> to use IS_ENABLED instead for all modes, returning NOWHERE when no valid
> mode is found.
>
> Signed-off-by: Ricardo Salveti <ricardo@foundries.io>

Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>

> ---
>  arch/arm/mach-imx/imx8m/soc.c | 35 +++++++++++++++--------------------
>  1 file changed, 15 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index f2ddc834d4b..a3ce517a104 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -1306,40 +1306,35 @@ void do_error(struct pt_regs *pt_regs, unsigned int esr)
>  enum env_location env_get_location(enum env_operation op, int prio)
>  {
>         enum boot_device dev = get_boot_device();
> -       enum env_location env_loc = ENVL_UNKNOWN;
>
>         if (prio)
> -               return env_loc;
> +               return ENVL_UNKNOWN;
>
>         switch (dev) {
> -#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
>         case QSPI_BOOT:
> -               env_loc = ENVL_SPI_FLASH;
> -               break;
> -#endif
> -#ifdef CONFIG_ENV_IS_IN_NAND
> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
> +                       return ENVL_SPI_FLASH;
> +               return ENVL_NOWHERE;
>         case NAND_BOOT:
> -               env_loc = ENVL_NAND;
> -               break;
> -#endif
> -#ifdef CONFIG_ENV_IS_IN_MMC
> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
> +                       return ENVL_NAND;
> +               return ENVL_NOWHERE;
>         case SD1_BOOT:
>         case SD2_BOOT:
>         case SD3_BOOT:
>         case MMC1_BOOT:
>         case MMC2_BOOT:
>         case MMC3_BOOT:
> -               env_loc =  ENVL_MMC;
> -               break;
> -#endif
> +               if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
> +                       return ENVL_MMC;
> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4))
> +                       return ENVL_EXT4;
> +               else if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
> +                       return ENVL_FAT;
> +               return ENVL_NOWHERE;
>         default:
> -#if defined(CONFIG_ENV_IS_NOWHERE)
> -               env_loc = ENVL_NOWHERE;
> -#endif
> -               break;
> +               return ENVL_NOWHERE;
>         }
> -
> -       return env_loc;
>  }
>
>  #ifndef ENV_IS_EMBEDDED
> --
> 2.33.0
>
Fabio Estevam Jan. 15, 2022, 2:02 p.m. UTC | #2
On Wed, Oct 20, 2021 at 4:16 PM Ricardo Salveti <ricardo@foundries.io> wrote:
>
> Change boot device logic to also allow environment stored in fat and in
> ext4 when booting from SD or from eMMC.
>
> As the boot device check for SD and for eMMC was depending on
> ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location
> to use IS_ENABLED instead for all modes, returning NOWHERE when no valid
> mode is found.
>
> Signed-off-by: Ricardo Salveti <ricardo@foundries.io>

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Stefano Babic Feb. 5, 2022, 4:39 p.m. UTC | #3
> Change boot device logic to also allow environment stored in fat and in
> ext4 when booting from SD or from eMMC.
> As the boot device check for SD and for eMMC was depending on
> ENV_IS_IN_MMC being defined, change the ifdef blocks at env_get_location
> to use IS_ENABLED instead for all modes, returning NOWHERE when no valid
> mode is found.
> Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
> Reviewed-by: Fabio Estevam <festevam@gmail.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index f2ddc834d4b..a3ce517a104 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -1306,40 +1306,35 @@  void do_error(struct pt_regs *pt_regs, unsigned int esr)
 enum env_location env_get_location(enum env_operation op, int prio)
 {
 	enum boot_device dev = get_boot_device();
-	enum env_location env_loc = ENVL_UNKNOWN;
 
 	if (prio)
-		return env_loc;
+		return ENVL_UNKNOWN;
 
 	switch (dev) {
-#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
 	case QSPI_BOOT:
-		env_loc = ENVL_SPI_FLASH;
-		break;
-#endif
-#ifdef CONFIG_ENV_IS_IN_NAND
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+			return ENVL_SPI_FLASH;
+		return ENVL_NOWHERE;
 	case NAND_BOOT:
-		env_loc = ENVL_NAND;
-		break;
-#endif
-#ifdef CONFIG_ENV_IS_IN_MMC
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
+			return ENVL_NAND;
+		return ENVL_NOWHERE;
 	case SD1_BOOT:
 	case SD2_BOOT:
 	case SD3_BOOT:
 	case MMC1_BOOT:
 	case MMC2_BOOT:
 	case MMC3_BOOT:
-		env_loc =  ENVL_MMC;
-		break;
-#endif
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
+			return ENVL_MMC;
+		else if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4))
+			return ENVL_EXT4;
+		else if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
+			return ENVL_FAT;
+		return ENVL_NOWHERE;
 	default:
-#if defined(CONFIG_ENV_IS_NOWHERE)
-		env_loc = ENVL_NOWHERE;
-#endif
-		break;
+		return ENVL_NOWHERE;
 	}
-
-	return env_loc;
 }
 
 #ifndef ENV_IS_EMBEDDED