[PATCH] mtd: cfi: Replace env_get_f() with env_get_yesno()

Marek Vasut via U-Boot <[email protected]> Tue, 4 Aug 2026 01:17:31 +0200
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <[email protected]>
Simplify the code, replace env_get_f() with env_get_yesno(). The
env_get_yesno() internally calls env_get() which may fall back to
env_get_f() if the environment access is not initialized yet.

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Stefan Roese <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
---
 drivers/mtd/cfi_flash.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e50502824ac..cf52abf1554 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -2407,13 +2407,6 @@ unsigned long flash_init(void)
 	unsigned long size = 0;
 	int i;
 
-#ifdef CONFIG_SYS_FLASH_PROTECTION
-	/* read environment from EEPROM */
-	char s[64];
-
-	env_get_f("unlock", s, sizeof(s));
-#endif
-
 #ifdef CONFIG_CFI_FLASH /* for driver model */
 	cfi_flash_init_dm();
 #endif
@@ -2438,7 +2431,7 @@ unsigned long flash_init(void)
 #endif /* CONFIG_SYS_FLASH_QUIET_TEST */
 		}
 #ifdef CONFIG_SYS_FLASH_PROTECTION
-		else if (strcmp(s, "yes") == 0) {
+		else if (env_get_yesno("unlock")) {
 			/*
 			 * Only the U-Boot image and it's environment
 			 * is protected, all other sectors are
-- 
2.53.0