[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d56a09d-59a4-4574-9fb7-635f627f5657@gmx.de>
Date: Sun, 24 Nov 2024 18:51:40 +0100
From: Armin Wolf <W_Armin@....de>
To: Thomas Weißschuh <linux@...ssschuh.net>,
Sebastian Reichel <sre@...nel.org>, Hans de Goede <hdegoede@...hat.com>,
Thomas Weißschuh <thomas@...ssschuh.net>,
Benson Leung <bleung@...omium.org>, Guenter Roeck <groeck@...omium.org>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
chrome-platform@...ts.linux.dev,
Sebastian Reichel <sebastian.reichel@...labora.com>
Subject: Re: [PATCH v4 3/9] power: supply: core: introduce
power_supply_has_property()
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@....de>
> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
> Reviewed-by: Hans de Goede <hdegoede@...hat.com>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@...labora.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)
>
Powered by blists - more mailing lists