Skip to contentSkip to conversation

env_nand: use nand_spl_load_image for readenv if SPL

PATCH New Tim Harvey 3 participants 3 messages May 14, 2015 – May 19, 2015

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH 1/1 env_nand: use nand_spl_load_image for readenv if SPL

The readenv() implementation of env_nand uses the mtd layer which is unnecessary overhead in SPL when we already have a nand_spl_load_image() function that doesn't need it. Using this instead eliminates the need to provide a mtd_read for SPL env as well as reduces code (4KB savings in IMX6 SPL).

---
 common/env_nand.c | 7 +++++++
 1 file changed, 7 insertions(+)
common/env_nand.c +7 -0
index 7fc7558..bab89fd 100644
@@ -260,6 +260,12 @@ int saveenv(void)
 }
 #endif /* CMD_SAVEENV */
 
+#if defined(CONFIG_SPL_BUILD)
+static int readenv(size_t offset, u_char *buf)
+{
+	return nand_spl_load_image(offset, CONFIG_ENV_SIZE, buf);
+}
+#else
 static int readenv(size_t offset, u_char *buf)
 {
 	size_t end = offset + CONFIG_ENV_RANGE;
@@ -295,6 +301,7 @@ static int readenv(size_t offset, u_char *buf)
 
 	return 0;
 }
+#endif /* #if defined(CONFIG_SPL_BUILD) */
 
 #ifdef CONFIG_ENV_OFFSET_OOB
 int get_nand_env_oob(nand_info_t *nand, unsigned long *result)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 env_nand: use nand_spl_load_image for readenv if SPL

Quoted 10 lines · Tim Harvey

The readenv() implementation of env_nand uses the mtd layer which is unnecessary overhead in SPL when we already have a nand_spl_load_image() function that doesn't need it. Using this instead eliminates the need to provide a mtd_read for SPL env as well as reduces code (4KB savings in IMX6 SPL).

---
 common/env_nand.c | 7 +++++++
 1 file changed, 7 insertions(+)

-Scott

#2 lore raw

PATCH 1/1 env_nand: use nand_spl_load_image for readenv if SPL

Hi Tim,

Quoted 7 lines · Scott Wood
Quoted 6 lines · Tim Harvey

The readenv() implementation of env_nand uses the mtd layer which is unnecessary overhead in SPL when we already have a nand_spl_load_image() function that doesn't need it. Using this instead eliminates the need to provide a mtd_read for SPL env as well as reduces code (4KB savings in IMX6 SPL).

Quoted 7 lines
Quoted 4 lines
---
 common/env_nand.c | 7 +++++++
 1 file changed, 7 insertions(+)

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================