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

Commit 383ac33a authored by Jeff Bernard's avatar Jeff Bernard Committed by Shiju Mathew
Browse files

thermal-core: Add a lock to tz_notify_trip()



Lock the sensor threshold list during notifications so it
isn't updated until notifications are sent out nor can
something else update thresholds until all notifications
are sent out.

Change-Id: Iafce75fa7fceda3de867044861e4a2e3eef47c95
Signed-off-by: default avatarJeff Bernard <jbernard@codeaurora.org>
parent ac6c6499
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ static void sensor_update_work(struct work_struct *work)
	mutex_unlock(&sensor->lock);
}

/* May be called in an interrupt context.
/* Should not be called in an interrupt context.
 * Do NOT call sensor_set_trip from this function
 */
int thermal_sensor_trip(struct thermal_zone_device *tz,
@@ -308,6 +308,8 @@ int thermal_sensor_trip(struct thermal_zone_device *tz,
	if (list_empty(&tz->sensor.threshold_list))
		return 0;

	mutex_lock(&tz->sensor.lock);

	list_for_each_entry_safe(pos, var, &tz->sensor.threshold_list, list) {
		if ((pos->trip != trip) || (!pos->active))
			continue;
@@ -326,6 +328,8 @@ int thermal_sensor_trip(struct thermal_zone_device *tz,
		}
	}

	mutex_unlock(&tz->sensor.lock);

	schedule_work(&tz->sensor.work);

	return ret;