Re: [PATCH] hwmon: acpi_power_meter: use named initializers for acpi_device_id
From: Guenter Roeck
Date: Tue Sep 15 2026 - 10:55:59 EST
On 9/15/26 06:40, Pawel Zalewski wrote:
Use a designated initializer for the acpi_device_id fields which makes the
code more readable and consistent with how lists are initialized in the
rest of the kernel code base. Also drop explicitly setting fields to 0
where it is redundant.
Unify the list terminator to have a single space between the brackets and
no trailing comma.
Signed-off-by: Pawel Zalewski <pzalewski@xxxxxxxxxxxxxxxxxxxx>
---
This series is converting lists that contain the acpi_device_id struct,
which is defined in the include/linux/device-id/acpi.h to make use of named
initializers (which they do not use currently). This work is part of the on
going effort in the kernel associated with device-ids [1]
The plan is to convert acpi_device_id::driver_data to have an anonymous
union, similarly to what was introduced for PCI and I2C device ID tables.
The goal is to increase type-safety (most of the existing casts are gone),
to improve readability and to make use intent a bit more clear:
```
union {
kernel_ulong_t driver_data;
const void *driver_data_ptr;
}
```
But for that to work all lists containing the structs need to use named
initializers first to avoid triggering -Wmissing-braces. I already have
patches that implement this and touching a lot of kernel subsystmes that
use the acpi_device_id struct and that list keeps on growing. Therefore,
I have decided to split the series per every subsystem into:
- pre-clean-ups that convert the lists to use named initializers
(which is this series)
- actual implementations that make some of the modules use the new
driver_data_ptr member
That way the task can be fragmented into manageable and independent chunks
of work and makes this effort easier to review.
Tested builds on x86-64 in Yocto using 7.3-rc3.
[1] https://lore.kernel.org/all/cover.1780048925.git.u.kleine-koenig@xxxxxxxxxxxx/
---
drivers/hwmon/acpi_power_meter.c | 4 ++--
drivers/hwmon/asus_atk0110.c | 4 ++--
drivers/hwmon/pt5161l.c | 4 ++--
drivers/hwmon/xgene-hwmon.c | 6 +++---
The subject and patch description fail to mention that it touches four
drivers and not just acpi_power_meter. Do not sneak in undocumented changes,
please.
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 8a539e8d1334..d8e871509405 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -54,8 +54,8 @@ static int can_cap_in_hardware(void)
}
static const struct acpi_device_id power_meter_ids[] = {
- {"ACPI000D", 0},
- {"", 0},
+ { .id = "ACPI000D" },
+ { }
This is a functional change. It replaces a pointer to an empty string
with a NULL pointer. I don't know ACPI expectations (drivers use both),
but the change needs to be explained.
};
MODULE_DEVICE_TABLE(acpi, power_meter_ids);
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 92afb64c09df..868c4e14d26a 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -141,8 +141,8 @@ typedef ssize_t (*sysfs_show_func)(struct device *dev,
struct device_attribute *attr, char *buf);
static const struct acpi_device_id atk_ids[] = {
- {ATK_HID, 0},
- {"", 0},
+ { .id = ATK_HID },
+ { }
};
MODULE_DEVICE_TABLE(acpi, atk_ids);
diff --git a/drivers/hwmon/pt5161l.c b/drivers/hwmon/pt5161l.c
index 2b408a69b085..1638f54f8eae 100644
--- a/drivers/hwmon/pt5161l.c
+++ b/drivers/hwmon/pt5161l.c
@@ -611,8 +611,8 @@ static const struct of_device_id __maybe_unused pt5161l_of_match[] = {
MODULE_DEVICE_TABLE(of, pt5161l_of_match);
static const struct acpi_device_id __maybe_unused pt5161l_acpi_match[] = {
- { "PT5161L", 0 },
- {},
+ { .id = "PT5161L" },
+ { }
};
MODULE_DEVICE_TABLE(acpi, pt5161l_acpi_match);
diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
index 38b140c23c88..eebbb741deac 100644
--- a/drivers/hwmon/xgene-hwmon.c
+++ b/drivers/hwmon/xgene-hwmon.c
@@ -595,9 +595,9 @@ static void xgene_hwmon_tx_done(struct mbox_client *cl, void *msg, int ret)
#ifdef CONFIG_ACPI
static const struct acpi_device_id xgene_hwmon_acpi_match[] = {
- {"APMC0D29", XGENE_HWMON_V 1},
- {"APMC0D8A", XGENE_HWMON_V2},
- {},
+ { .id = "APMC0D29", .driver_data = XGENE_HWMON_V1 },
+ { .id = "APMC0D8A", .driver_data = XGENE_HWMON_V2 },
+ { }
};
MODULE_DEVICE_TABLE(acpi, xgene_hwmon_acpi_match);
#endif
---
base-commit: 587858367581b9c55c3690f4e63382ad622719d4
change-id: 20260915-acpi-hwmon-12061c767bc7
Best regards,
--
Pawel Zalewski <pzalewski@xxxxxxxxxxxxxxxxxxxx>