drivers/hwmon/acpi_power_meter.c | 4 ++-- drivers/hwmon/asus_atk0110.c | 4 ++-- drivers/hwmon/pt5161l.c | 4 ++-- drivers/hwmon/xgene-hwmon.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-)
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@thegoodpenguin.co.uk>
---
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@baylibre.com/
---
Changes in v2:
- Fixed commit title.
- Link to v1: https://patch.msgid.link/20260915-acpi-hwmon-v1-1-20747f6fd218@thegoodpenguin.co.uk
---
drivers/hwmon/acpi_power_meter.c | 4 ++--
drivers/hwmon/asus_atk0110.c | 4 ++--
drivers/hwmon/pt5161l.c | 4 ++--
drivers/hwmon/xgene-hwmon.c | 6 +++---
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" },
+ { }
};
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_V1},
- {"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@thegoodpenguin.co.uk>
On Tue, Sep 15, 2026 at 02:48:20PM +0100, 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@thegoodpenguin.co.uk> Applied. Thanks, Guenter
On 9/15/26 06:48, 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. > It also replaces pointers to empty strings with NULL pointers, which is a functional change and still neither documented nor explained. Guenter
> It also replaces pointers to empty strings with NULL pointers, > which is a functional change and still neither documented nor explained. Please note that the 'id' here is an __u8[] array, not a const char * and that the generated .o objects are equal pre/post the patch as both methods just initialize the array to 0s. So I think the commit message explains what the patch is doing, perhaps it might be worth mentioning that the 'id' field is a byte array in the message.
On 9/16/26 07:33, Pawel Zalewski wrote: >> It also replaces pointers to empty strings with NULL pointers, >> which is a functional change and still neither documented nor explained. > > Please note that the 'id' here is an __u8[] array, not a const char * > and that the generated .o objects are equal pre/post the patch as both > methods just initialize the array to 0s. So I think the commit message > explains what the patch is doing, perhaps it might be worth mentioning > that the 'id' field is a byte array in the message. Thanks for the information. I accepted the patch as-is. Guenter
© 2016 - 2026 Red Hat, Inc.