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>
This commit is contained in:
parent
7ea98f70c7
commit
9326167058
2 changed files with 4 additions and 24 deletions
|
@ -288,28 +288,6 @@ static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
|
|
||||||
int temp)
|
|
||||||
{
|
|
||||||
struct __thermal_zone *data = tz->devdata;
|
|
||||||
|
|
||||||
if (trip >= tz->num_trips || trip < 0)
|
|
||||||
return -EDOM;
|
|
||||||
|
|
||||||
if (data->ops && data->ops->set_trip_temp) {
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* thermal framework should take care of data->mask & (1 << trip) */
|
|
||||||
tz->trips[trip].temperature = temp;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
|
static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip,
|
||||||
int *hyst)
|
int *hyst)
|
||||||
{
|
{
|
||||||
|
@ -350,7 +328,6 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
|
||||||
static struct thermal_zone_device_ops of_thermal_ops = {
|
static struct thermal_zone_device_ops of_thermal_ops = {
|
||||||
.get_trip_type = of_thermal_get_trip_type,
|
.get_trip_type = of_thermal_get_trip_type,
|
||||||
.get_trip_temp = of_thermal_get_trip_temp,
|
.get_trip_temp = of_thermal_get_trip_temp,
|
||||||
.set_trip_temp = of_thermal_set_trip_temp,
|
|
||||||
.get_trip_hyst = of_thermal_get_trip_hyst,
|
.get_trip_hyst = of_thermal_get_trip_hyst,
|
||||||
.set_trip_hyst = of_thermal_set_trip_hyst,
|
.set_trip_hyst = of_thermal_set_trip_hyst,
|
||||||
.get_crit_temp = of_thermal_get_crit_temp,
|
.get_crit_temp = of_thermal_get_crit_temp,
|
||||||
|
|
|
@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
|
||||||
int temperature, hyst = 0;
|
int temperature, hyst = 0;
|
||||||
enum thermal_trip_type type;
|
enum thermal_trip_type type;
|
||||||
|
|
||||||
if (!tz->ops->set_trip_temp)
|
if (!tz->ops->set_trip_temp && !tz->trips)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1)
|
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,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (tz->trips)
|
||||||
|
tz->trips[trip].temperature = temperature;
|
||||||
|
|
||||||
if (tz->ops->get_trip_hyst) {
|
if (tz->ops->get_trip_hyst) {
|
||||||
ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
|
ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
Loading…
Add table
Reference in a new issue