From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] ARM: i.MX: romapi: Hide using NULL pointers from gcc
Date: Mon, 7 Nov 2022 11:33:40 +0100 [thread overview]
Message-ID: <20221107103340.3913098-1-s.hauer@pengutronix.de> (raw)
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
reply other threads:[~2022-11-07 10:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221107103340.3913098-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox