Skip to contentSkip to conversation

common: spl: spl_nand: make CONFIG_SYS_NAND_U_BOOT_OFFS optional in spl_nand_get_uboot_raw_page()

PATCH In review Weijie Gao 2 participants 3 messages Apr 10 – Apr 13

lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

PATCH 1/1 common: spl: spl_nand: make CONFIG_SYS_NAND_U_BOOT_OFFS optional in spl_nand_get_uboot_raw_page()

As spl_nand_get_uboot_raw_page() is a weak function, when a board wants to override it, the CONFIG_SYS_NAND_U_BOOT_OFFS becomes meaningless within this function.

This patch allows spl_nand_get_uboot_raw_page() being compiled without CONFIG_SYS_NAND_U_BOOT_OFFS being defined.

Note: this is available only when both CONFIG_SPL_NAND_RAW_ONLY and CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND are not defined.

---
 common/spl/spl_nand.c | 4 ++++
 1 file changed, 4 insertions(+)
common/spl/spl_nand.c +4 -0
index f449b31f594..74c114d8e30 100644
@@ -18,7 +18,11 @@
 
 uint32_t __weak spl_nand_get_uboot_raw_page(void)
 {
+#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS
 	return CONFIG_SYS_NAND_U_BOOT_OFFS;
+#else
+	return 0;
+#endif
 }
 
 #if defined(CONFIG_SPL_NAND_RAW_ONLY)
Signature · 1 line
2.17.0
#1 lore raw
Quoted 7 lines · Weijie Gao

As spl_nand_get_uboot_raw_page() is a weak function, when a board wants to override it, the CONFIG_SYS_NAND_U_BOOT_OFFS becomes meaningless within this function.

This patch allows spl_nand_get_uboot_raw_page() being compiled without CONFIG_SYS_NAND_U_BOOT_OFFS being defined.

Quoted 7 lines

Note: this is available only when both CONFIG_SPL_NAND_RAW_ONLY and CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND are not defined.

---
 common/spl/spl_nand.c | 4 ++++
 1 file changed, 4 insertions(+)

I think the bug here is that when SYS_NAND_U_BOOT_LOCATIONS isn't defined, we should still be able to override spl_nand_get_uboot_raw_page (with an implementation that does not use CONFIG_SYS_NAND_U_BOOT_OFFS). Can you please re-examine the code with that in mind? Thanks!

Signature · 1 line
Tom
author
#2 lore raw

Hi Tom,

Quoted 20 lines · Tom Rini
Quoted 10 lines · Weijie Gao

As spl_nand_get_uboot_raw_page() is a weak function, when a board wants to
override it, the CONFIG_SYS_NAND_U_BOOT_OFFS becomes meaningless within
this function.

This patch allows spl_nand_get_uboot_raw_page() being compiled without
CONFIG_SYS_NAND_U_BOOT_OFFS being defined.

Quoted 7 lines

Note: this is available only when both CONFIG_SPL_NAND_RAW_ONLY and CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND are not defined.

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

I think the bug here is that when SYS_NAND_U_BOOT_LOCATIONS isn't defined, we should still be able to override spl_nand_get_uboot_raw_page
(with an implementation that does not use CONFIG_SYS_NAND_U_BOOT_OFFS).
Can you please re-examine the code with that in mind? Thanks!

So I come up with the following idea:
1. With my current path, replace all reference to CONFIG_SYS_NAND_U_BOOT_OFFS with spl_nand_get_uboot_raw_page()
2. Add a new weak function, spl_nand_get_uboot_raw_page_redund(), to wrap the CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND macro, and do the same modification as spl_nand_get_uboot_raw_page() do.

I'll send new patch later

Weijie