usb: dwc_otg_310: remove unused configs
[firefly-linux-kernel-4.4.55.git] / drivers / thermal / of-thermal.c
index 5a515f8677ec5bb6699af73dd83df38467d94015..cd58efbacf8afe2a0722511b5acebd3b69c76682 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.
@@ -191,24 +202,15 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
                                enum thermal_trend *trend)
 {
        struct __thermal_zone *data = tz->devdata;
-       long dev_trend;
        int r;
 
        if (!data->ops->get_trend)
                return -EINVAL;
 
-       r = data->ops->get_trend(data->sensor_data, &dev_trend);
+       r = data->ops->get_trend(data->sensor_data, trip, trend);
        if (r)
                return r;
 
-       /* TODO: These intervals might have some thresholds, but in core code */
-       if (dev_trend > 0)
-               *trend = THERMAL_TREND_RAISING;
-       else if (dev_trend < 0)
-               *trend = THERMAL_TREND_DROPPING;
-       else
-               *trend = THERMAL_TREND_STABLE;
-
        return 0;
 }
 
@@ -331,6 +333,14 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
        if (trip >= data->ntrips || trip < 0)
                return -EDOM;
 
+       if (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) */
        data->trips[trip].temperature = temp;
 
@@ -419,6 +429,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);