diff mbox series

env: mmc: print MMC device being read

Message ID 20240415-mmc-loadenv-dev-v1-1-4dd649e0c298@theobroma-systems.com
State Accepted
Commit 97b34f6ace539c9c16eb8565f8b58730848ba97a
Delegated to: Tom Rini
Headers show
Series env: mmc: print MMC device being read | expand

Commit Message

Quentin Schulz April 15, 2024, 12:43 p.m. UTC
From: Quentin Schulz <quentin.schulz@theobroma-systems.com>

This prints the MMC device being read similar to how we print the MMC
device we write to when e.g. calling saveenv.

One of the side effects is that the boot log now shows from which MMC
device the env was loaded:

Loading Environment from MMC... Reading from MMC(1)... OK

This is useful to identify which MMC device the environment was loaded
from for boards where there are more than one (e.g. eMMC and SD card)
without adding some debug messages manually.

Sadly, there's no way to know which of the default or redundant
environment is being read from env_mmc_load before env_import_redund is
called so it is printing a bit later (and possibly after error/warning
messages).

Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
---
 env/mmc.c | 3 +++
 1 file changed, 3 insertions(+)


---
base-commit: b03b49046af5dfca599d2ce8f0aafed89b97aa91
change-id: 20240415-mmc-loadenv-dev-ced678171e98

Best regards,

Comments

Tom Rini April 16, 2024, 12:36 a.m. UTC | #1
On Mon, Apr 15, 2024 at 02:43:57PM +0200, Quentin Schulz wrote:

> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> 
> This prints the MMC device being read similar to how we print the MMC
> device we write to when e.g. calling saveenv.
> 
> One of the side effects is that the boot log now shows from which MMC
> device the env was loaded:
> 
> Loading Environment from MMC... Reading from MMC(1)... OK
> 
> This is useful to identify which MMC device the environment was loaded
> from for boards where there are more than one (e.g. eMMC and SD card)
> without adding some debug messages manually.
> 
> Sadly, there's no way to know which of the default or redundant
> environment is being read from env_mmc_load before env_import_redund is
> called so it is printing a bit later (and possibly after error/warning
> messages).
> 
> Cc: Quentin Schulz <foss+uboot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Dragan Simic April 16, 2024, 5:28 a.m. UTC | #2
On 2024-04-15 14:43, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> 
> This prints the MMC device being read similar to how we print the MMC
> device we write to when e.g. calling saveenv.
> 
> One of the side effects is that the boot log now shows from which MMC
> device the env was loaded:
> 
> Loading Environment from MMC... Reading from MMC(1)... OK
> 
> This is useful to identify which MMC device the environment was loaded
> from for boards where there are more than one (e.g. eMMC and SD card)
> without adding some debug messages manually.
> 
> Sadly, there's no way to know which of the default or redundant
> environment is being read from env_mmc_load before env_import_redund is
> called so it is printing a bit later (and possibly after error/warning
> messages).
> 
> Cc: Quentin Schulz <foss+uboot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>

Looking great to me.

Reviewed-by: Dragan Simic <dsimic@manjaro.org>

> ---
>  env/mmc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/env/mmc.c b/env/mmc.c
> index da84cddd74f..7afb733e890 100644
> --- a/env/mmc.c
> +++ b/env/mmc.c
> @@ -436,6 +436,7 @@ static int env_mmc_load(void)
> 
>  	ret = env_import_redund((char *)tmp_env1, read1_fail, (char 
> *)tmp_env2,
>  				read2_fail, H_EXTERNAL);
> +	printf("Reading from %sMMC(%d)... ", gd->env_valid == ENV_REDUND ?
> "redundant " : "", dev);
> 
>  fini:
>  	fini_mmc_for_env(mmc);
> @@ -475,6 +476,8 @@ static int env_mmc_load(void)
>  		goto fini;
>  	}
> 
> +	printf("Reading from MMC(%d)... ", dev);
> +
>  	ret = env_import(buf, 1, H_EXTERNAL);
>  	if (!ret) {
>  		ep = (env_t *)buf;
> 
> ---
> base-commit: b03b49046af5dfca599d2ce8f0aafed89b97aa91
> change-id: 20240415-mmc-loadenv-dev-ced678171e98
> 
> Best regards,
Tom Rini April 19, 2024, 1:58 a.m. UTC | #3
On Mon, 15 Apr 2024 14:43:57 +0200, Quentin Schulz wrote:

> This prints the MMC device being read similar to how we print the MMC
> device we write to when e.g. calling saveenv.
> 
> One of the side effects is that the boot log now shows from which MMC
> device the env was loaded:
> 
> Loading Environment from MMC... Reading from MMC(1)... OK
> 
> [...]

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/env/mmc.c b/env/mmc.c
index da84cddd74f..7afb733e890 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -436,6 +436,7 @@  static int env_mmc_load(void)
 
 	ret = env_import_redund((char *)tmp_env1, read1_fail, (char *)tmp_env2,
 				read2_fail, H_EXTERNAL);
+	printf("Reading from %sMMC(%d)... ", gd->env_valid == ENV_REDUND ? "redundant " : "", dev);
 
 fini:
 	fini_mmc_for_env(mmc);
@@ -475,6 +476,8 @@  static int env_mmc_load(void)
 		goto fini;
 	}
 
+	printf("Reading from MMC(%d)... ", dev);
+
 	ret = env_import(buf, 1, H_EXTERNAL);
 	if (!ret) {
 		ep = (env_t *)buf;