Skip to content

Commit 9326167

Browse files
Daniel Lezcanodlezcano
authored andcommitted
thermal/core: Move set_trip_temp ops to the sysfs code
Given the trip points can be set in the thermal zone structure, there is no need of a specific OF function to do that. Move the code in the place where it is generic, in the sysfs set_trip_temp storing function. Signed-off-by: Daniel Lezcano <daniel.lezcano@linexp.org> Link: https://lore.kernel.org/r/20220804224349.1926752-33-daniel.lezcano@linexp.org Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 7ea98f7 commit 9326167

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

drivers/thermal/thermal_of.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -288,28 +288,6 @@ static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
288288
return 0;
289289
}
290290

291-
static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
292-
int temp)
293-
{
294-
struct __thermal_zone *data = tz->devdata;
295-
296-
if (trip >= tz->num_trips || trip < 0)
297-
return -EDOM;
298-
299-
if (data->ops && data->ops->set_trip_temp) {
300-
int ret;
301-
302-
ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);
303-
if (ret)
304-
return ret;
305-
}
306-
307-
/* thermal framework should take care of data->mask & (1 << trip) */
308-
tz->trips[trip].temperature = temp;
309-
310-
return 0;
311-
}
312-
313291
static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
314292
int *hyst)
315293
{
@@ -350,7 +328,6 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
350328
static struct thermal_zone_device_ops of_thermal_ops = {
351329
.get_trip_type = of_thermal_get_trip_type,
352330
.get_trip_temp = of_thermal_get_trip_temp,
353-
.set_trip_temp = of_thermal_set_trip_temp,
354331
.get_trip_hyst = of_thermal_get_trip_hyst,
355332
.set_trip_hyst = of_thermal_set_trip_hyst,
356333
.get_crit_temp = of_thermal_get_crit_temp,

drivers/thermal/thermal_sysfs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
115115
int temperature, hyst = 0;
116116
enum thermal_trip_type type;
117117

118-
if (!tz->ops->set_trip_temp)
118+
if (!tz->ops->set_trip_temp && !tz->trips)
119119
return -EPERM;
120120

121121
if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1)
@@ -128,6 +128,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
128128
if (ret)
129129
return ret;
130130

131+
if (tz->trips)
132+
tz->trips[trip].temperature = temperature;
133+
131134
if (tz->ops->get_trip_hyst) {
132135
ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
133136
if (ret)

0 commit comments

Comments
 (0)