From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, bifangknt@qq.com,
nicokessler@icloud.com, linux-pm@vger.kernel.org,
wse@tuxedocomputers.com
Subject: Re: [PATCH v2 1/9] power: supply: core: Add power_supply_has_property_direct()
Date: Mon, 30 Nov 2026 19:10:28 +0100 [thread overview]
Message-ID: <aw279RWhAA-Qbh8l@venus> (raw)
In-Reply-To: <20261110165318.631010-2-W_Armin@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 3063 bytes --]
Hi,
On Tue, Nov 10, 2026 at 05:50:02PM +0100, Armin Wolf wrote:
> Providers of power supply extensions might want to check if a given
> power supply supports a given property in order to select a suitable
> extension to load.
>
> Add power_supply_has_property_direct() to enable such use cases.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Greetings,
-- Sebastian
> drivers/power/supply/power_supply_core.c | 26 ++++++++++++++++++++----
> include/linux/power_supply.h | 1 +
> 2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 1cc203f2780b..75b53aec5db4 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -1367,17 +1367,35 @@ bool power_supply_ext_has_property(const struct power_supply_ext *psy_ext,
> return false;
> }
>
> -bool power_supply_has_property(struct power_supply *psy,
> - enum power_supply_property psp)
> +/**
> + * power_supply_has_property_direct - Check if a power supply property exists without checking
> + * for extensions
> + * @psy: The power supply
> + * @psp: The power supply property to check
> + *
> + * Check if a given power supply support a given power supply property without taking into account
> + * any power supply extesions registered on said power supply. This is mostly useful for determining
> + * if a power supply extension should be registered for the power supply or not.
> + */
> +bool power_supply_has_property_direct(struct power_supply *psy, enum power_supply_property psp)
> {
> - struct power_supply_ext_registration *reg;
> -
> if (psy_desc_has_property(psy->desc, psp))
> return true;
>
> if (power_supply_battery_info_has_prop(psy->battery_info, psp))
> return true;
>
> + return false;
> +}
> +EXPORT_SYMBOL_GPL(power_supply_has_property_direct);
> +
> +bool power_supply_has_property(struct power_supply *psy, enum power_supply_property psp)
> +{
> + struct power_supply_ext_registration *reg;
> +
> + if (power_supply_has_property_direct(psy, psp))
> + return true;
> +
> power_supply_for_each_extension(reg, psy) {
> if (power_supply_ext_has_property(reg->ext, psp))
> return true;
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index cce61137aef4..73bcb127d0fc 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -934,6 +934,7 @@ extern int power_supply_is_system_supplied(void);
> static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
> #endif
>
> +bool power_supply_has_property_direct(struct power_supply *psy, enum power_supply_property psp);
> extern int power_supply_get_property(struct power_supply *psy,
> enum power_supply_property psp,
> union power_supply_propval *val);
> --
> 2.56.0
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-11-30 18:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 16:50 [PATCH v2 0/9] platform/x86: uniwill-laptop: Complete battery support Armin Wolf
2026-11-10 16:50 ` [PATCH v2 1/9] power: supply: core: Add power_supply_has_property_direct() Armin Wolf
2026-11-30 18:10 ` Sebastian Reichel [this message]
2026-11-10 16:50 ` [PATCH v2 2/9] power: supply: Enable struct power_supply_ext to be construct dynamically Armin Wolf
2026-11-30 18:11 ` Sebastian Reichel
2026-11-10 16:50 ` [PATCH v2 3/9] platform/x86: uniwill-laptop: Report battery cycle count Armin Wolf
2026-11-10 16:50 ` [PATCH v2 4/9] platform/x86: uniwill-laptop: Expose battery health and cycle count on all devices Armin Wolf
2026-11-10 16:50 ` [PATCH v2 5/9] platform/x86: uniwill-laptop: Expose raw battery capacity to userspace Armin Wolf
2026-11-10 16:50 ` [PATCH v2 6/9] platform/x86: uniwill-laptop: Mark sysfs attributes as const Armin Wolf
2026-11-10 16:50 ` [PATCH v2 7/9] platform/x86: uniwill-laptop: Add support for MECHREVO Yilong15Pro Armin Wolf
2026-11-10 16:50 ` [PATCH v2 8/9] platform/x86: uniwill-laptop: Add MECHREVO JIAOLONG Series-X6xR55xK Armin Wolf
2026-11-10 16:50 ` [PATCH v2 9/9] platform/x86: uniwill-laptop: Add support for XMG EVO 14 (E25) Armin Wolf
2026-11-20 20:53 ` [PATCH v2 0/9] platform/x86: uniwill-laptop: Complete battery support Armin Wolf
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=aw279RWhAA-Qbh8l@venus \
--to=sebastian.reichel@collabora.com \
--cc=W_Armin@gmx.de \
--cc=bifangknt@qq.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nicokessler@icloud.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=wse@tuxedocomputers.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