[PATCH v1] platform/surface: aggregator: Consistently define ssam_device_ids using named initializers
From: Uwe Kleine-König (The Capable Hub)
Date: Mon Jun 15 2026 - 07:30:15 EST
The .driver_data member of the the two struct ssam_device_id arrays were
initialized by list expressions. This isn't easily readable if you don't
work with the Surface System Aggregator core regularily. Using named
initializers is more explicit and thus easier to parse and also more
robust to changes of the struct definition. This robustness is relevant
for a planned change to struct ssam_device_id replacing .driver_data
by an anonymous union.
This change doesn't introduce changes to the compiled ssam_device_id
arrays.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx>
---
Hello,
the mentioned change to ssam_device_id is similar to
https://lore.kernel.org/all/cover.1779878004.git.u.kleine-koenig@xxxxxxxxxxxx/.
That allows to get rid of the casts in these two drivers and thus
benefits a bit more of the (admittedly weak) type safety of C.
But IMHO the improved readability alone also justifies this change.
Best regards
uwe
drivers/platform/surface/surface_aggregator_hub.c | 9 +++++++--
drivers/platform/surface/surface_aggregator_tabletsw.c | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c
index 8b8b80228c14..541e9180f976 100644
--- a/drivers/platform/surface/surface_aggregator_hub.c
+++ b/drivers/platform/surface/surface_aggregator_hub.c
@@ -348,8 +348,13 @@ static const struct ssam_hub_desc kip_hub = {
/* -- Driver registration. -------------------------------------------------- */
static const struct ssam_device_id ssam_hub_match[] = {
- { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub },
- { SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub },
+ {
+ SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_KIP, 0x00),
+ .driver_data = (unsigned long)&kip_hub,
+ }, {
+ SSAM_VDEV(HUB, SAM, SSAM_SSH_TC_BAS, 0x00),
+ .driver_data = (unsigned long)&base_hub,
+ },
{ }
};
MODULE_DEVICE_TABLE(ssam, ssam_hub_match);
diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
index ffa36ed92897..13031c329553 100644
--- a/drivers/platform/surface/surface_aggregator_tabletsw.c
+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
@@ -622,8 +622,13 @@ static const struct ssam_tablet_sw_desc ssam_pos_sw_desc = {
/* -- Driver registration. -------------------------------------------------- */
static const struct ssam_device_id ssam_tablet_sw_match[] = {
- { SSAM_SDEV(KIP, SAM, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc },
- { SSAM_SDEV(POS, SAM, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc },
+ {
+ SSAM_SDEV(KIP, SAM, 0x00, 0x01),
+ .driver_data = (unsigned long)&ssam_kip_sw_desc,
+ }, {
+ SSAM_SDEV(POS, SAM, 0x00, 0x01),
+ .driver_data = (unsigned long)&ssam_pos_sw_desc,
+ },
{ },
};
MODULE_DEVICE_TABLE(ssam, ssam_tablet_sw_match);
base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b
--
2.47.3