[RFC PATCH 15/26] power: supply: core: Migrate to thermal_zone_device_register()

From: AngeloGioacchino Del Regno
Date: Thu Dec 21 2023 - 07:52:47 EST


The thermal API has a new thermal_zone_device_register() function which
is deprecating the older thermal_zone_device_register_with_trips() and
thermal_tripless_zone_device_register().

Migrate to the new thermal zone device registration function.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
---
drivers/power/supply/power_supply_core.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 73265001dd4b..d656a2e39157 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -1297,6 +1297,12 @@ static struct thermal_zone_device_ops psy_tzd_ops = {

static int psy_register_thermal(struct power_supply *psy)
{
+ struct thermal_zone_device_params tzdp = {
+ /* Prefer our hwmon device and avoid duplicates */
+ .tzp = { .no_hwmon = IS_ENABLED(CONFIG_POWER_SUPPLY_HWMON) },
+ .ops = &psy_tzd_ops,
+ .devdata = psy
+ };
int ret;

if (psy->desc->no_thermal)
@@ -1304,12 +1310,8 @@ static int psy_register_thermal(struct power_supply *psy)

/* Register battery zone device psy reports temperature */
if (psy_has_property(psy->desc, POWER_SUPPLY_PROP_TEMP)) {
- /* Prefer our hwmon device and avoid duplicates */
- struct thermal_zone_params tzp = {
- .no_hwmon = IS_ENABLED(CONFIG_POWER_SUPPLY_HWMON)
- };
- psy->tzd = thermal_tripless_zone_device_register(psy->desc->name,
- psy, &psy_tzd_ops, &tzp);
+ tzdp.name = psy->desc->name;
+ psy->tzd = thermal_zone_device_register(&tzdp);
if (IS_ERR(psy->tzd))
return PTR_ERR(psy->tzd);
ret = thermal_zone_device_enable(psy->tzd);
--
2.43.0