[PATCH] edac: use named initializers for acpi_device_id

Pawel Zalewski posted 1 patch 3 weeks ago
drivers/edac/bluefield_edac.c | 4 ++--
drivers/edac/loongson_edac.c  | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
[PATCH] edac: use named initializers for acpi_device_id
Posted by Pawel Zalewski 3 weeks ago
Use a named 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.

While we are at it - 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 (as 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 (this series)
- actual implementations that make some of the modules use the new driver_data_ptr

That way the task can be fragmented into manageable and independent
chunks of work and makes this effort easier to review.

Tested builds on a64 in Yocto using 7.3-rc1.

[1] https://lore.kernel.org/all/cover.1780048925.git.u.kleine-koenig@baylibre.com/
---
 drivers/edac/bluefield_edac.c | 4 ++--
 drivers/edac/loongson_edac.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/bluefield_edac.c b/drivers/edac/bluefield_edac.c
index ae3bb7afa103e..472fc87627788 100644
--- a/drivers/edac/bluefield_edac.c
+++ b/drivers/edac/bluefield_edac.c
@@ -472,8 +472,8 @@ static void bluefield_edac_mc_remove(struct platform_device *pdev)
 }
 
 static const struct acpi_device_id bluefield_mc_acpi_ids[] = {
-	{"MLNXBF08", 0},
-	{}
+	{ .id = "MLNXBF08" },
+	{ }
 };
 
 MODULE_DEVICE_TABLE(acpi, bluefield_mc_acpi_ids);
diff --git a/drivers/edac/loongson_edac.c b/drivers/edac/loongson_edac.c
index 38745800ed01d..3ed4d34a33680 100644
--- a/drivers/edac/loongson_edac.c
+++ b/drivers/edac/loongson_edac.c
@@ -137,8 +137,8 @@ static void edac_remove(struct platform_device *pdev)
 }
 
 static const struct acpi_device_id loongson_edac_acpi_match[] = {
-	{"LOON0010", 0},
-	{}
+	{ .id = "LOON0010" },
+	{ }
 };
 MODULE_DEVICE_TABLE(acpi, loongson_edac_acpi_match);
 

---
base-commit: bc35965f6940a9bf834d54187b6088b8eb09206d
change-id: 20260904-acpi-edac-b5d71efc08d7

Best regards,
--  
Pawel Zalewski <pzalewski@thegoodpenguin.co.uk>
Re: [PATCH] edac: use named initializers for acpi_device_id
Posted by Borislav Petkov 1 week, 6 days ago
On Fri, Sep 04, 2026 at 03:41:43PM +0100, Pawel Zalewski wrote:
> Use a named 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.
> 
> While we are at it - 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 (as 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 (this series)
> - actual implementations that make some of the modules use the new driver_data_ptr
> 
> That way the task can be fragmented into manageable and independent
> chunks of work and makes this effort easier to review.
> 
> Tested builds on a64 in Yocto using 7.3-rc1.
> 
> [1] https://lore.kernel.org/all/cover.1780048925.git.u.kleine-koenig@baylibre.com/
> ---
>  drivers/edac/bluefield_edac.c | 4 ++--
>  drivers/edac/loongson_edac.c  | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH] edac: use named initializers for acpi_device_id
Posted by Qunqin Zhao 2 weeks ago
在 2026/9/4 22:41, Pawel Zalewski 写道:
> Use a named 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.
>
> While we are at it - 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>

Acked-by: Qunqin Zhao <zhaoqunqin@loongson.cn>

Thanks.