From: Armin Wolf <W_Armin@gmx.de>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
"Sebastian Reichel" <sre@kernel.org>,
"Hans de Goede" <hdegoede@redhat.com>,
"Thomas Weißschuh" <thomas@weissschuh.net>,
"Benson Leung" <bleung@chromium.org>,
"Guenter Roeck" <groeck@chromium.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
chrome-platform@lists.linux.dev,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: Re: [PATCH v4 3/9] power: supply: core: introduce power_supply_has_property()
Date: Sun, 24 Nov 2024 18:51:40 +0100 [thread overview]
Message-ID: <0d56a09d-59a4-4574-9fb7-635f627f5657@gmx.de> (raw)
In-Reply-To: <20241111-power-supply-extensions-v4-3-7240144daa8e@weissschuh.net>
Am 11.11.24 um 22:40 schrieb Thomas Weißschuh:
> Introduce a helper to check if a power supply implements a certain
> property. It will be used by the sysfs and hwmon code to remove similar
> open-coded checks.
> It also paves the way for the extension API to hook into.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/power/supply/power_supply.h | 2 ++
> drivers/power/supply/power_supply_core.c | 12 ++++++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
> index 7434a6f2477504ee6c0a3c7420e1444387b41180..5dabbd895538003096b62d03fdd0201b82b090e6 100644
> --- a/drivers/power/supply/power_supply.h
> +++ b/drivers/power/supply/power_supply.h
> @@ -15,6 +15,8 @@ struct power_supply;
>
> extern int power_supply_property_is_writeable(struct power_supply *psy,
> enum power_supply_property psp);
> +extern bool power_supply_has_property(struct power_supply *psy,
> + enum power_supply_property psp);
>
> #ifdef CONFIG_SYSFS
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 2f61f6b90b99f40ee04a6d63ebc20036f0447102..502b07468b93dfb7f5a6c2092588d931a7d015f2 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -1196,6 +1196,18 @@ static bool psy_desc_has_property(const struct power_supply_desc *psy_desc,
> return found;
> }
>
> +bool power_supply_has_property(struct power_supply *psy,
> + enum power_supply_property psp)
> +{
> + 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;
> +}
> +
> int power_supply_get_property(struct power_supply *psy,
> enum power_supply_property psp,
> union power_supply_propval *val)
>
next prev parent reply other threads:[~2024-11-24 17:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-11 21:40 [PATCH v4 0/9] power: supply: extension API Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 1/9] power: supply: sysfs: print single value in uevent for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR Thomas Weißschuh
2024-11-24 17:47 ` Armin Wolf
2024-11-24 17:55 ` Thomas Weißschuh
2024-11-24 18:01 ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 2/9] power: supply: core: rename psy_has_property() to psy_desc_has_property() Thomas Weißschuh
2024-11-24 17:48 ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 3/9] power: supply: core: introduce power_supply_has_property() Thomas Weißschuh
2024-11-24 17:51 ` Armin Wolf [this message]
2024-11-11 21:40 ` [PATCH v4 4/9] power: supply: hwmon: prepare for power supply extensions Thomas Weißschuh
2024-11-24 17:53 ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 5/9] power: supply: sysfs: " Thomas Weißschuh
2024-11-24 17:57 ` Armin Wolf
2024-11-25 8:59 ` Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 6/9] power: supply: sysfs: rework uevent property loop Thomas Weißschuh
2024-11-24 18:00 ` Armin Wolf
2024-11-11 21:40 ` [PATCH v4 7/9] power: supply: core: implement extension API Thomas Weißschuh
2024-11-24 18:15 ` Armin Wolf
2024-11-25 9:22 ` Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 8/9] power: supply: test-power: implement a power supply extension Thomas Weißschuh
2024-11-11 21:40 ` [PATCH v4 9/9] power: supply: cros_charge-control: use power_supply extensions Thomas Weißschuh
2024-12-05 1:36 ` (subset) [PATCH v4 0/9] power: supply: extension API Sebastian Reichel
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=0d56a09d-59a4-4574-9fb7-635f627f5657@gmx.de \
--to=w_armin@gmx.de \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=sebastian.reichel@collabora.com \
--cc=sre@kernel.org \
--cc=thomas@weissschuh.net \
/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