usb: dwc_otg_310: remove unused configs
[firefly-linux-kernel-4.4.55.git] / drivers / thermal / of-thermal.c
index 8eed2015038f2546bce895ebca73e0f37d09833d..cd58efbacf8afe2a0722511b5acebd3b69c76682 100644 (file)
@@ -60,8 +60,6 @@ struct __thermal_bind_params {
  * @polling_delay: zone polling interval
  * @slope: slope of the temperature adjustment curve
  * @offset: offset of the temperature adjustment curve
- * @prev_low_trip: previous low trip point temperature
- * @prev_high_trip: previous high trip point temperature
  * @ntrips: number of trip points
  * @trips: an array of trip points (0..ntrips - 1)
  * @num_tbps: number of thermal bind params
@@ -76,7 +74,6 @@ struct __thermal_zone {
        int polling_delay;
        int slope;
        int offset;
-       int prev_low_trip, prev_high_trip;
 
        /* trip data */
        int ntrips;
@@ -91,63 +88,28 @@ struct __thermal_zone {
        const struct thermal_zone_of_device_ops *ops;
 };
 
-/***   Automatic trip handling   ***/
-
-static int of_thermal_set_trips(struct thermal_zone_device *tz, int temp)
-{
-       struct __thermal_zone *data = tz->devdata;
-       int low = INT_MIN, high = INT_MAX;
-       int i;
-
-       /* Hardware trip points not supported */
-       if (!data->ops->set_trips)
-               return 0;
-
-       /* No need to change trip points */
-       if (temp > data->prev_low_trip && temp < data->prev_high_trip)
-               return 0;
-
-       for (i = 0; i < data->ntrips; ++i) {
-               struct thermal_trip *trip = data->trips + i;
-               int trip_low = trip->temperature - trip->hysteresis;
-
-               if (trip_low < temp && trip_low > low)
-                       low = trip_low;
-
-               if (trip->temperature > temp && trip->temperature < high)
-                       high = trip->temperature;
-       }
-
-       dev_dbg(&tz->device,
-               "temperature %d, updating trip points to %d, %d\n",
-               temp, low, high);
-
-       data->prev_low_trip = low;
-       data->prev_high_trip = high;
-
-       return data->ops->set_trips(data->sensor_data, low, high);
-}
-
 /***   DT thermal zone device callbacks   ***/
 
 static int of_thermal_get_temp(struct thermal_zone_device *tz,
                               int *temp)
 {
        struct __thermal_zone *data = tz->devdata;
-       int err;
 
        if (!data->ops->get_temp)
                return -EINVAL;
 
-       err = data->ops->get_temp(data->sensor_data, temp);
-       if (err)
-               return err;
+       return data->ops->get_temp(data->sensor_data, temp);
+}
 
-       err = of_thermal_set_trips(tz, *temp);
-       if (err)
-               return err;
+static int of_thermal_set_trips(struct thermal_zone_device *tz,
+                               int low, int high)
+{
+       struct __thermal_zone *data = tz->devdata;
 
-       return 0;
+       if (!data->ops || !data->ops->set_trips)
+               return -ENOSYS;
+
+       return data->ops->set_trips(data->sensor_data, low, high);
 }
 
 /**
@@ -240,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;
 }
 
@@ -346,22 +299,6 @@ static int of_thermal_set_mode(struct thermal_zone_device *tz,
        return 0;
 }
 
-static int of_thermal_update_trips(struct thermal_zone_device *tz)
-{
-       int temp;
-       int err;
-
-       err = of_thermal_get_temp(tz, &temp);
-       if (err)
-               return err;
-
-       err = of_thermal_set_trips(tz, temp);
-       if (err)
-               return err;
-
-       return 0;
-}
-
 static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
                                    enum thermal_trip_type *type)
 {
@@ -392,7 +329,6 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
                                    int temp)
 {
        struct __thermal_zone *data = tz->devdata;
-       int err;
 
        if (trip >= data->ntrips || trip < 0)
                return -EDOM;
@@ -408,10 +344,6 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
        /* thermal framework should take care of data->mask & (1 << trip) */
        data->trips[trip].temperature = temp;
 
-       err = of_thermal_update_trips(tz);
-       if (err)
-               return err;
-
        return 0;
 }
 
@@ -432,7 +364,6 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
                                    int hyst)
 {
        struct __thermal_zone *data = tz->devdata;
-       int err;
 
        if (trip >= data->ntrips || trip < 0)
                return -EDOM;
@@ -440,10 +371,6 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
        /* thermal framework should take care of data->mask & (1 << trip) */
        data->trips[trip].hysteresis = hyst;
 
-       err = of_thermal_update_trips(tz);
-       if (err)
-               return err;
-
        return 0;
 }
 
@@ -500,10 +427,9 @@ thermal_zone_of_add_sensor(struct device_node *zone,
        tz->ops = ops;
        tz->sensor_data = data;
 
-       of_thermal_update_trips(tzd);
-
        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);
 
@@ -940,9 +866,6 @@ thermal_of_build_thermal_zone(struct device_node *np)
        /* trips */
        child = of_get_child_by_name(np, "trips");
 
-       tz->prev_high_trip = INT_MIN;
-       tz->prev_low_trip = INT_MAX;
-
        /* No trips provided */
        if (!child)
                goto finish;