Skip to content

v7.2-ogc4: ayn-ec fails to build with -Werror, local DEVICE_ATTR_*_NAMED macros now collide with device.h #98

Description

@ahmedadan

We build the OGC kernel for Dakota's gaming variants with -Werror, and v7.2-ogc4 fails to compile in drivers/platform/x86/ayn-ec.c with macro redefinition errors for DEVICE_ATTR_RW_NAMED and DEVICE_ATTR_RO_NAMED. Builds of the v7.1 series were fine.

Tracing it back: upstream added DEVICE_ATTR_RW_NAMED and DEVICE_ATTR_RO_NAMED to include/linux/device.h in 1b891f4c8528 (new in 7.2), so the local definitions the ayn-ec patch carries now redefine the kernel's own macros. The upstream macros have identical semantics (same modes, same show/store wiring), so the driver can just use them.

The fix is deleting the two local macro definitions. We are carrying exactly that as a patch in Dakota (patches/linux-ogc/0001-platform-x86-ayn-ec-drop-local-DEVICE_ATTR_-_NAMED-m.patch) and will drop it once your tree has it:

--- a/drivers/platform/x86/ayn-ec.c
+++ b/drivers/platform/x86/ayn-ec.c
@@ -117,19 +117,6 @@ static struct thermal_sensor thermal_sensors[] = {
 	{}
 };
 
-#define DEVICE_ATTR_RW_NAMED(_name, _attrname)               \
-	struct device_attribute dev_attr_##_name = {         \
-		.attr = { .name = _attrname, .mode = 0644 }, \
-		.show = _name##_show,                        \
-		.store = _name##_store,                      \
-	}
-
-#define DEVICE_ATTR_RO_NAMED(_name, _attrname)               \
-	struct device_attribute dev_attr_##_name = {         \
-		.attr = { .name = _attrname, .mode = 0444 }, \
-		.show = _name##_show,                        \
-	}
-
 /* Handle ACPI lock mechanism */
 #define ACPI_LOCK_DELAY_MS 500

To reproduce: build v7.2-ogc4 with CONFIG_WERROR=y (or any -Werror toolchain setup) and ayn-ec enabled. Kernels without -Werror still build but warn on the redefinition.

Happy to send this as a PR against your tree instead if that's easier for you, just let me know which branch you take fixes on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions