mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: i.MX: romapi: Hide using NULL pointers from gcc
@ 2022-11-07 10:33 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2022-11-07 10:33 UTC (permalink / raw)
  To: Barebox List

The i.MX ROM API lies in the NULL page. Accessing that results in
compiler warnings like:

include/asm-generic/io.h:27:51: warning: array subscript 0 is outside array bounds of 'volatile unsigned char[0]' [-Warray-bounds]

Use OPTIMIZER_HIDE_VAR() to hide using NULL pointers from the compiler.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/include/mach/imx8mq.h | 7 +++++--
 arch/arm/mach-imx/romapi.c              | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/imx8mq.h b/arch/arm/mach-imx/include/mach/imx8mq.h
index d02c5f23cf..e58a3935f7 100644
--- a/arch/arm/mach-imx/include/mach/imx8mq.h
+++ b/arch/arm/mach-imx/include/mach/imx8mq.h
@@ -58,10 +58,13 @@ static inline int imx8mq_cpu_revision(void)
 {
 	void __iomem *anatop = IOMEM(MX8MQ_ANATOP_BASE_ADDR);
 	void __iomem *ocotp = IOMEM(MX8MQ_OCOTP_BASE_ADDR);
+	void __iomem *rom = IOMEM(0x0);
 	uint32_t revision = FIELD_GET(DIGPROG_MINOR,
 				      readl(anatop + MX8MQ_ANATOP_DIGPROG));
 	uint32_t rom_version;
 
+	OPTIMIZER_HIDE_VAR(rom);
+
 	if (revision != IMX_CHIP_REV_1_0)
 		return revision;
 	/*
@@ -74,9 +77,9 @@ static inline int imx8mq_cpu_revision(void)
 	 * For B0 chip, the DIGPROG is not updated, still TO1.0.
 	 * we have to check ROM version further
 	 */
-	rom_version = readb(IOMEM(IMX8MQ_ROM_VERSION_A0));
+	rom_version = readb(IOMEM(rom + IMX8MQ_ROM_VERSION_A0));
 	if (rom_version != IMX_CHIP_REV_1_0) {
-		rom_version = readb(IOMEM(IMX8MQ_ROM_VERSION_B0));
+		rom_version = readb(IOMEM(rom + IMX8MQ_ROM_VERSION_B0));
 		if (rom_version >= IMX_CHIP_REV_2_0)
 			revision = IMX_CHIP_REV_2_0;
 	}
diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
index 5d00d71154..56bf7e135f 100644
--- a/arch/arm/mach-imx/romapi.c
+++ b/arch/arm/mach-imx/romapi.c
@@ -35,6 +35,8 @@ int imx8mp_bootrom_load_image(void)
 {
 	struct rom_api *rom_api = (void *)0x980;
 
+	OPTIMIZER_HIDE_VAR(rom_api);
+
 	return imx8m_bootrom_load_image(rom_api);
 }
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-07 10:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 10:33 [PATCH] ARM: i.MX: romapi: Hide using NULL pointers from gcc Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox