mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 4/6] acpi: fix compilation for 32-bit
Date: Wed, 14 Aug 2024 11:24:22 +0200	[thread overview]
Message-ID: <20240814092424.39878-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240814092424.39878-1-a.fatoum@pengutronix.de>

Build test on x86 fails due to pointer cast and because of forcing the
bigger alignment on the flexible array.

The problematic pointer cast is for the XSDT, which is 64-bit-only, so
let's fix the cast and return an error if we somehow see an XSDT on
32-bit.

For the flexible array, the first struct member is already packed, so we
should arrive at the same result by just dropping the packed from the
second member, so they get normal alignment.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/bus/acpi.c | 6 ++++--
 include/acpi.h     | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/acpi.c b/drivers/bus/acpi.c
index 593617073345..61178db0c8db 100644
--- a/drivers/bus/acpi.c
+++ b/drivers/bus/acpi.c
@@ -174,10 +174,12 @@ static int acpi_register_devices(struct bus_type *bus)
 		sig = "RSDT";
 		root = (struct acpi_rsdt *)(unsigned long)rsdp->rsdt_addr;
 		entry_count = (root->sdt.len - sizeof(struct acpi_rsdt)) / sizeof(u32);
-	} else {
+	} else if (sizeof(void *) == 8) {
 		sig = "XSDT";
-		root = (struct acpi_rsdt *)((struct acpi2_rsdp *)rsdp)->xsdt_addr;
+		root = (struct acpi_rsdt *)(uintptr_t)((struct acpi2_rsdp *)rsdp)->xsdt_addr;
 		entry_count = (root->sdt.len - sizeof(struct acpi_rsdt)) / sizeof(u64);
+	} else {
+		return -EIO;
 	}
 
 	if (acpi_sigcmp(sig, root->sdt.signature)) {
diff --git a/include/acpi.h b/include/acpi.h
index 0756f94501cc..837476424664 100644
--- a/include/acpi.h
+++ b/include/acpi.h
@@ -113,9 +113,9 @@ struct __packed acpi_sdt { /* system description table header */
 	u32		creator_revision;
 };
 
-struct __packed acpi_rsdt { /* system description table header */
+struct acpi_rsdt { /* system description table header */
 	struct acpi_sdt	sdt;
-	struct acpi_sdt	* __aligned(8) entries[];
+	struct acpi_sdt	*entries[];
 };
 
 struct acpi_driver {
-- 
2.39.2




  parent reply	other threads:[~2024-08-14  9:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14  9:24 [PATCH 1/6] common: pe: fix use of undefined macro for ARMv7 Ahmad Fatoum
2024-08-14  9:24 ` [PATCH 2/6] efi: fs: fix determination of read-only files Ahmad Fatoum
2024-08-14  9:24 ` [PATCH 3/6] filetype: fix else clause indentation Ahmad Fatoum
2024-08-14  9:24 ` Ahmad Fatoum [this message]
2024-08-14  9:24 ` [PATCH 5/6] i2c: efi: avoid 64-bit division Ahmad Fatoum
2024-08-15  5:53   ` Tomas Marek
2024-08-15  6:57     ` Ahmad Fatoum
2024-08-19  6:16       ` Sascha Hauer
2024-08-14  9:24 ` [PATCH 6/6] net: fsl_enetc: fix compilation for 32-bit Ahmad Fatoum
2024-08-14 11:08 ` [PATCH 1/6] common: pe: fix use of undefined macro for ARMv7 Sascha Hauer

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=20240814092424.39878-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@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