Skip to content

Commit 2e766a1

Browse files
committed
modpost: fix acpi MODULE_DEVICE_TABLE built with mismatched endianness
When CONFIG_SATA_AHCI_PLATFORM=m, modpost outputs incorect acpi MODULE_ALIAS() if the endianness of the target and the build machine do not match. When the endianness of the target kernel and the build machine match, the output is correct: $ grep 'MODULE_ALIAS("acpi' drivers/ata/ahci_platform.mod.c MODULE_ALIAS("acpi*:APMC0D33:*"); MODULE_ALIAS("acpi*:010601:*"); However, when building a little-endian kernel on a big-endian machine (or vice versa), the output is incorrect: $ grep 'MODULE_ALIAS("acpi' drivers/ata/ahci_platform.mod.c MODULE_ALIAS("acpi*:APMC0D33:*"); MODULE_ALIAS("acpi*:0601??:*"); The 'cls' and 'cls_msk' fields are 32-bit. DEF_FIELD() must be used instead of DEF_FIELD_ADDR() to correctly handle endianness of these 32-bit fields. The check 'if (cls)' was unnecessary; it never became NULL, as it was the pointer to 'symval' plus the offset to the 'cls' field. Fixes: 26095a0 ("ACPI / scan: Add support for ACPI _CLS device matching") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent d01661e commit 2e766a1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/mod/file2alias.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,23 +567,23 @@ static int do_acpi_entry(const char *filename,
567567
void *symval, char *alias)
568568
{
569569
DEF_FIELD_ADDR(symval, acpi_device_id, id);
570-
DEF_FIELD_ADDR(symval, acpi_device_id, cls);
571-
DEF_FIELD_ADDR(symval, acpi_device_id, cls_msk);
570+
DEF_FIELD(symval, acpi_device_id, cls);
571+
DEF_FIELD(symval, acpi_device_id, cls_msk);
572572

573573
if (id && strlen((const char *)*id))
574574
sprintf(alias, "acpi*:%s:*", *id);
575-
else if (cls) {
575+
else {
576576
int i, byte_shift, cnt = 0;
577577
unsigned int msk;
578578

579579
sprintf(&alias[cnt], "acpi*:");
580580
cnt = 6;
581581
for (i = 1; i <= 3; i++) {
582582
byte_shift = 8 * (3-i);
583-
msk = (*cls_msk >> byte_shift) & 0xFF;
583+
msk = (cls_msk >> byte_shift) & 0xFF;
584584
if (msk)
585585
sprintf(&alias[cnt], "%02x",
586-
(*cls >> byte_shift) & 0xFF);
586+
(cls >> byte_shift) & 0xFF);
587587
else
588588
sprintf(&alias[cnt], "??");
589589
cnt += 2;

0 commit comments

Comments
 (0)