Linux Power Management development
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Armin Wolf" <W_Armin@gmx.de>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v3 2/9] power: supply: core: register thermal zone for battery
Date: Wed, 4 Sep 2024 21:56:42 +0200	[thread overview]
Message-ID: <c938ab4e-ad58-48f6-a612-1717557d2891@redhat.com> (raw)
In-Reply-To: <20240904-power-supply-extensions-v3-2-62efeb93f8ec@weissschuh.net>

Hi,

On 9/4/24 9:25 PM, Thomas Weißschuh wrote:
> power_supply_read_team() can also read the temperature from the battery.
> But currently when registering the thermal zone, the battery is not
> checked for POWER_SUPPLY_PROP_TEMP.
> Introduce a helper which can check both the desc and the battery info
> for property existence and use that.
> Export the helper to the rest of the psy core because it will also be
> used by different subcomponents.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans




> ---
>  drivers/power/supply/power_supply.h      |  3 +++
>  drivers/power/supply/power_supply_core.c | 14 +++++++++++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
> index 3cbafc58bdad..b01faeaf7827 100644
> --- a/drivers/power/supply/power_supply.h
> +++ b/drivers/power/supply/power_supply.h
> @@ -13,6 +13,9 @@ struct device;
>  struct device_type;
>  struct power_supply;
>  
> +extern bool power_supply_has_property(struct power_supply *psy,
> +				      enum power_supply_property psp);
> +
>  #ifdef CONFIG_SYSFS
>  
>  extern void power_supply_init_attrs(void);
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index cff68c4fd63c..dcb7e4853030 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -1199,6 +1199,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)
> @@ -1308,7 +1320,7 @@ static int psy_register_thermal(struct power_supply *psy)
>  		return 0;
>  
>  	/* Register battery zone device psy reports temperature */
> -	if (psy_desc_has_property(psy->desc, POWER_SUPPLY_PROP_TEMP)) {
> +	if (power_supply_has_property(psy, POWER_SUPPLY_PROP_TEMP)) {
>  		/* Prefer our hwmon device and avoid duplicates */
>  		struct thermal_zone_params tzp = {
>  			.no_hwmon = IS_ENABLED(CONFIG_POWER_SUPPLY_HWMON)
> 


  reply	other threads:[~2024-09-04 19:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 19:25 [PATCH RFC v3 0/9] power: supply: extension API Thomas Weißschuh
2024-09-04 19:25 ` [PATCH RFC v3 1/9] power: supply: core: rename psy_has_property() to psy_desc_has_property() Thomas Weißschuh
2024-09-04 19:56   ` Hans de Goede
2024-09-14  9:30   ` Sebastian Reichel
2024-09-04 19:25 ` [PATCH RFC v3 2/9] power: supply: core: register thermal zone for battery Thomas Weißschuh
2024-09-04 19:56   ` Hans de Goede [this message]
2024-09-14  9:29   ` Sebastian Reichel
2024-09-14  9:55     ` Thomas Weißschuh
2024-09-04 19:25 ` [PATCH RFC v3 3/9] power: supply: hwmon: register battery properties Thomas Weißschuh
2024-09-04 19:57   ` Hans de Goede
2024-09-14  9:35   ` Sebastian Reichel
2024-09-04 19:25 ` [PATCH RFC v3 4/9] power: supply: sysfs: " Thomas Weißschuh
2024-09-04 19:57   ` Hans de Goede
2024-09-14  9:43   ` Sebastian Reichel
2024-09-04 19:25 ` [PATCH RFC v3 5/9] power: supply: sysfs: rework uevent property loop Thomas Weißschuh
2024-09-04 19:58   ` Hans de Goede
2024-09-14  9:59   ` Sebastian Reichel
2024-09-04 19:25 ` [PATCH RFC v3 6/9] power: supply: core: implement extension API Thomas Weißschuh
2024-09-14 10:50   ` Sebastian Reichel
2024-09-14 14:25     ` Thomas Weißschuh
2024-09-16 10:58       ` Sebastian Reichel
2024-09-04 19:25 ` [PATCH RFC v3 7/9] power: supply: core: add locking around extension access Thomas Weißschuh
2024-09-04 19:25 ` [PATCH RFC v3 8/9] power: supply: test-power: implement a power supply extension Thomas Weißschuh
2024-09-04 19:25 ` [PATCH RFC v3 9/9] power: supply: cros_charge-control: use power_supply extensions Thomas Weißschuh

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=c938ab4e-ad58-48f6-a612-1717557d2891@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=W_Armin@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=sre@kernel.org \
    /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