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-
140139int 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 );
223216sensor_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}
237231EXPORT_SYMBOL_GPL (st_thermal_unregister );
238232
0 commit comments