From d290ee1e63164e6a3ce9bb606be5a50f5212750d Mon Sep 17 00:00:00 2001 From: Ram Chandrasekar Date: Wed, 22 Mar 2017 18:07:31 -0600 Subject: [PATCH] power_supply: Use of-thermal cdev registration API 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. Change-Id: I27d6043cf1d3121d97f8300bb89635204ae32955 Signed-off-by: Ram Chandrasekar --- drivers/power/supply/power_supply_core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 5c36c430ce8b..dc660df5d736 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -947,7 +947,7 @@ static const struct thermal_cooling_device_ops psy_tcd_ops = { .set_cur_state = ps_set_cur_charge_cntl_limit, }; -static int psy_register_cooler(struct power_supply *psy) +static int psy_register_cooler(struct device *dev, struct power_supply *psy) { int i; @@ -955,7 +955,13 @@ 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( + if (dev) + psy->tcd = thermal_of_cooling_device_register( + dev_of_node(dev), + (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); @@ -980,7 +986,7 @@ static void psy_unregister_thermal(struct power_supply *psy) { } -static int psy_register_cooler(struct power_supply *psy) +static int psy_register_cooler(struct device *dev, struct power_supply *psy) { return 0; } @@ -1063,7 +1069,7 @@ __power_supply_register(struct device *parent, if (rc) goto register_thermal_failed; - rc = psy_register_cooler(psy); + rc = psy_register_cooler(parent, psy); if (rc) goto register_cooler_failed;