Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca0bb24b authored by Manaf Meethalavalappu Pallikunhi's avatar Manaf Meethalavalappu Pallikunhi
Browse files

drivers: thermal: Notify only thermal zones whose trips are violated



Whenever sensor driver event notification happens, of thermal
framework notifies all thermal zones associated to that sensor for
thermal re-evaluation. In this case, thermal zones whose trips are
not violated are also forced to re-evaluate.

Check if any trip of a thermal zone is violated, then notify that
zone for thermal re-evaluation and ignore other thermal zones
whose trips are not violated.

Change-Id: I3bed9738edc4c1ef4cd3b9748c2b50256941dc7d
Signed-off-by: default avatarManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
parent 692654ff
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -569,6 +569,46 @@ static int of_thermal_aggregate_trip_types(struct thermal_zone_device *tz,
	return 0;
}

static bool of_thermal_is_trips_triggered(struct thermal_zone_device *tz,
		int temp)
{
	int tt, th, trip, last_temp;
	struct __thermal_zone *data = tz->devdata;
	bool triggered = false;

	mutex_lock(&tz->lock);
	last_temp = tz->last_temperature;
	for (trip = 0; trip < data->ntrips; trip++) {

		if (!tz->tzp->tracks_low) {
			tt = data->trips[trip].temperature;
			if (temp >= tt && last_temp < tt) {
				triggered = true;
				break;
			}
			th = tt - data->trips[trip].hysteresis;
			if (temp <= th && last_temp > th) {
				triggered = true;
				break;
			}
		} else {
			tt = data->trips[trip].temperature;
			if (temp <= tt && last_temp > tt) {
				triggered = true;
				break;
			}
			th = tt + data->trips[trip].hysteresis;
			if (temp >= th && last_temp < th) {
				triggered = true;
				break;
			}
		}
	}
	mutex_unlock(&tz->lock);

	return triggered;
}

/*
 * of_thermal_aggregate_trip - aggregate trip temperatures across sibling
 *				thermal zones.
@@ -605,6 +645,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
			thermal_zone_device_update(zone,
				THERMAL_EVENT_UNSPECIFIED);
		} else {
			if (!of_thermal_is_trips_triggered(zone, trip_temp))
				continue;
			thermal_zone_device_update_temp(zone,
				THERMAL_EVENT_UNSPECIFIED, trip_temp);
		}