Skip to content

Commit 8e12f1f

Browse files
GallaisPoutinedlezcano
authored andcommitted
thermal/drivers/sti: Depend on THERMAL_OF subsystem
Switch to thermal_of_zone to handle thermal-zones. Replace thermal_zone_device_register() by devm_thermal_of_zone_register() and remove ops st_thermal_get_trip_type, st_thermal_get_trip_temp. Signed-off-by: Raphael Gallais-Pou <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 27fec3c commit 8e12f1f

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

drivers/thermal/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ source "drivers/thermal/samsung/Kconfig"
438438
endmenu
439439

440440
menu "STMicroelectronics thermal drivers"
441-
depends on (ARCH_STI || ARCH_STM32) && OF
441+
depends on (ARCH_STI || ARCH_STM32) && THERMAL_OF
442442
source "drivers/thermal/st/Kconfig"
443443
endmenu
444444

drivers/thermal/st/st_thermal.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/of_device.h>
1313

1414
#include "st_thermal.h"
15+
#include "../thermal_hwmon.h"
1516

1617
/* The Thermal Framework expects millidegrees */
1718
#define mcelsius(temp) ((temp) * 1000)
@@ -135,8 +136,6 @@ static struct thermal_zone_device_ops st_tz_ops = {
135136
.get_temp = st_thermal_get_temp,
136137
};
137138

138-
static struct thermal_trip trip;
139-
140139
int st_thermal_register(struct platform_device *pdev,
141140
const struct of_device_id *st_thermal_of_match)
142141
{
@@ -145,7 +144,6 @@ int st_thermal_register(struct platform_device *pdev,
145144
struct device_node *np = dev->of_node;
146145
const struct of_device_id *match;
147146

148-
int polling_delay;
149147
int ret;
150148

151149
if (!np) {
@@ -197,29 +195,24 @@ int st_thermal_register(struct platform_device *pdev,
197195
if (ret)
198196
goto sensor_off;
199197

200-
polling_delay = sensor->ops->register_enable_irq ? 0 : 1000;
201-
202-
trip.temperature = sensor->cdata->crit_temp;
203-
trip.type = THERMAL_TRIP_CRITICAL;
204-
205198
sensor->thermal_dev =
206-
thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, sensor,
207-
&st_tz_ops, NULL, 0, polling_delay);
199+
devm_thermal_of_zone_register(dev, 0, sensor, &st_tz_ops);
208200
if (IS_ERR(sensor->thermal_dev)) {
209-
dev_err(dev, "failed to register thermal zone device\n");
201+
dev_err(dev, "failed to register thermal of zone\n");
210202
ret = PTR_ERR(sensor->thermal_dev);
211203
goto sensor_off;
212204
}
213-
ret = thermal_zone_device_enable(sensor->thermal_dev);
214-
if (ret)
215-
goto tzd_unregister;
216205

217206
platform_set_drvdata(pdev, sensor);
218207

208+
/*
209+
* devm_thermal_of_zone_register() doesn't enable hwmon by default
210+
* Enable it here
211+
*/
212+
devm_thermal_add_hwmon_sysfs(dev, sensor->thermal_dev);
213+
219214
return 0;
220215

221-
tzd_unregister:
222-
thermal_zone_device_unregister(sensor->thermal_dev);
223216
sensor_off:
224217
st_thermal_sensor_off(sensor);
225218

@@ -232,7 +225,8 @@ void st_thermal_unregister(struct platform_device *pdev)
232225
struct st_thermal_sensor *sensor = platform_get_drvdata(pdev);
233226

234227
st_thermal_sensor_off(sensor);
235-
thermal_zone_device_unregister(sensor->thermal_dev);
228+
thermal_remove_hwmon_sysfs(sensor->thermal_dev);
229+
devm_thermal_of_zone_unregister(sensor->dev, sensor->thermal_dev);
236230
}
237231
EXPORT_SYMBOL_GPL(st_thermal_unregister);
238232

0 commit comments

Comments
 (0)