Linux Power Management development
 help / color / mirror / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.com>
To: "Uwe Kleine-König (The Capable Hub)"
	<u.kleine-koenig@baylibre.com>,
	"Sebastian Reichel" <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] power: supply: surface_{battery,charger}: Consistently define ssam_device_ids using named initializers
Date: Sun, 21 Jun 2026 15:32:45 +0200	[thread overview]
Message-ID: <19647fe8-c520-4160-bf74-d398c6b642b4@gmail.com> (raw)
In-Reply-To: <bc8eff03b2f36c82af5a75fc7114c277228921db.1781526433.git.u.kleine-koenig@baylibre.com>

Am 15.06.2026 um 14:51 schrieb Uwe Kleine-König (The Capable Hub):
> 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.
> 
> While touching these arrays, also drop the comma after the list
> terminators.
> 
> 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@baylibre.com>
> ---
> Hello,
> 
> the mentioned change to ssam_device_id is similar to
> https://lore.kernel.org/all/cover.1779878004.git.u.kleine-koenig@baylibre.com/.
> 
> 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.

As in the prior patch: I assume that will be a separate change or am I missing something in this patch?

> But IMHO the improved readability alone also justifies this change.
> 
> Best regards
> Uwe

Looks good to me.

Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>

> 
>   drivers/power/supply/surface_battery.c | 11 ++++++++---
>   drivers/power/supply/surface_charger.c |  7 +++++--
>   2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/power/supply/surface_battery.c b/drivers/power/supply/surface_battery.c
> index c759add4df49..1273b6082311 100644
> --- a/drivers/power/supply/surface_battery.c
> +++ b/drivers/power/supply/surface_battery.c
> @@ -852,9 +852,14 @@ static const struct spwr_psy_properties spwr_psy_props_bat2_sb3 = {
>   };
>   
>   static const struct ssam_device_id surface_battery_match[] = {
> -	{ SSAM_SDEV(BAT, SAM, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat1     },
> -	{ SSAM_SDEV(BAT, KIP, 0x01, 0x00), (unsigned long)&spwr_psy_props_bat2_sb3 },
> -	{ },
> +	{
> +		SSAM_SDEV(BAT, SAM, 0x01, 0x00),
> +		.driver_data = (unsigned long)&spwr_psy_props_bat1,
> +	}, {
> +		SSAM_SDEV(BAT, KIP, 0x01, 0x00),
> +		.driver_data = (unsigned long)&spwr_psy_props_bat2_sb3,
> +	},
> +	{ }
>   };
>   MODULE_DEVICE_TABLE(ssam, surface_battery_match);
>   
> diff --git a/drivers/power/supply/surface_charger.c b/drivers/power/supply/surface_charger.c
> index 90b823848c99..d4bba6b41794 100644
> --- a/drivers/power/supply/surface_charger.c
> +++ b/drivers/power/supply/surface_charger.c
> @@ -260,8 +260,11 @@ static const struct spwr_psy_properties spwr_psy_props_adp1 = {
>   };
>   
>   static const struct ssam_device_id surface_ac_match[] = {
> -	{ SSAM_SDEV(BAT, SAM, 0x01, 0x01), (unsigned long)&spwr_psy_props_adp1 },
> -	{ },
> +	{
> +		SSAM_SDEV(BAT, SAM, 0x01, 0x01),
> +		.driver_data = (unsigned long)&spwr_psy_props_adp1,
> +	},
> +	{ }
>   };
>   MODULE_DEVICE_TABLE(ssam, surface_ac_match);
>   
> 
> base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b


  reply	other threads:[~2026-06-21 13:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 12:51 [PATCH v1] power: supply: surface_{battery,charger}: Consistently define ssam_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
2026-06-21 13:32 ` Maximilian Luz [this message]
2026-06-22  9:37   ` Uwe Kleine-König (The Capable Hub)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19647fe8-c520-4160-bf74-d398c6b642b4@gmail.com \
    --to=luzmaximilian@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox