diff mbox series

[RESEND,2/2] power_supply: Use of-thermal cdev registration API

Message ID 20220531183054.6476-2-quic_manafm@quicinc.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series [RESEND,1/2] power_supply: Register cooling device outside of probe | expand

Commit Message

Manaf Meethalavalappu Pallikunhi May 31, 2022, 6:30 p.m. UTC
With thermal frameworks of-thermal interface, thermal zone parameters can
be defined in devicetree. This includes cooling device mitigation levels
for a thermal zone. To take advantage of this, cooling device should use
the thermal_of_cooling_device_register API to register a cooling device.

Use thermal_of_cooling_device_register API to register the power supply
cooling device. This enables power supply cooling device be included in the
thermal zone parameter in devicetree.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
---
 drivers/power/supply/power_supply_core.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Sebastian Reichel June 9, 2022, 10:17 p.m. UTC | #1
Hi,

On Wed, Jun 01, 2022 at 12:00:54AM +0530, Manaf Meethalavalappu Pallikunhi wrote:
> With thermal frameworks of-thermal interface, thermal zone parameters can
> be defined in devicetree. This includes cooling device mitigation levels
> for a thermal zone. To take advantage of this, cooling device should use
> the thermal_of_cooling_device_register API to register a cooling device.
> 
> Use thermal_of_cooling_device_register API to register the power supply
> cooling device. This enables power supply cooling device be included in the
> thermal zone parameter in devicetree.
> 
> Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
> ---
>
>  drivers/power/supply/power_supply_core.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 74623c4977db..4593450920a4 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -1157,9 +1157,15 @@ static int psy_register_cooler(struct power_supply *psy)
>  	for (i = 0; i < psy->desc->num_properties; i++) {
>  		if (psy->desc->properties[i] ==
>  				POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT) {
> -			psy->tcd = thermal_cooling_device_register(
> -							(char *)psy->desc->name,
> -							psy, &psy_tcd_ops);
> +			if (psy->dev.parent)
> +				psy->tcd = thermal_of_cooling_device_register(
> +						dev_of_node(psy->dev.parent),
> +						(char *)psy->desc->name,
> +						psy, &psy_tcd_ops);

if (psy->of_node)
    psy->tcd = thermal_of_cooling_device_register(psy->of_node, ...);
else
    psy->tcd = thermal_cooling_device_register(...);

--- Sebastian

> +			else
> +				psy->tcd = thermal_cooling_device_register(
> +						(char *)psy->desc->name,
> +						psy, &psy_tcd_ops);
>  			return PTR_ERR_OR_ZERO(psy->tcd);
>  		}
>  	}
diff mbox series

Patch

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 74623c4977db..4593450920a4 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -1157,9 +1157,15 @@  static int psy_register_cooler(struct power_supply *psy)
 	for (i = 0; i < psy->desc->num_properties; i++) {
 		if (psy->desc->properties[i] ==
 				POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT) {
-			psy->tcd = thermal_cooling_device_register(
-							(char *)psy->desc->name,
-							psy, &psy_tcd_ops);
+			if (psy->dev.parent)
+				psy->tcd = thermal_of_cooling_device_register(
+						dev_of_node(psy->dev.parent),
+						(char *)psy->desc->name,
+						psy, &psy_tcd_ops);
+			else
+				psy->tcd = thermal_cooling_device_register(
+						(char *)psy->desc->name,
+						psy, &psy_tcd_ops);
 			return PTR_ERR_OR_ZERO(psy->tcd);
 		}
 	}