thermal: of: implement .set_trips for device tree thermal zones
[firefly-linux-kernel-4.4.55.git] / drivers / thermal / of-thermal.c
index 57828841b6e6ac03c1ed5773d9281b07638fbf0f..27f078ce137f561a80d889b91ed930980417caba 100644 (file)
@@ -101,6 +101,17 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
        return data->ops->get_temp(data->sensor_data, temp);
 }
 
+static int of_thermal_set_trips(struct thermal_zone_device *tz,
+                               int low, int high)
+{
+       struct __thermal_zone *data = tz->devdata;
+
+       if (!data->ops || !data->ops->set_trips)
+               return -ENOSYS;
+
+       return data->ops->set_trips(data->sensor_data, low, high);
+}
+
 /**
  * of_thermal_get_ntrips - function to export number of available trip
  *                        points.
@@ -427,6 +438,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 
        tzd->ops->get_temp = of_thermal_get_temp;
        tzd->ops->get_trend = of_thermal_get_trend;
+       tzd->ops->set_trips = of_thermal_set_trips;
        tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
        mutex_unlock(&tzd->lock);