diff options
author | Jeff Bernard <jbernard@codeaurora.org> | 2014-12-09 22:09:48 -0500 |
---|---|---|
committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 11:08:24 -0700 |
commit | 5059c6fe7118762ed970fab9463d9885f1a1ca04 (patch) | |
tree | f0fbcfc8fd59b575bf100a38136ef01d9e4562e2 | |
parent | c6fb5b4539d58817df13b2010815ca6aff5d6224 (diff) |
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: Jeff Bernard <jbernard@codeaurora.org>
-rw-r--r-- | drivers/thermal/thermal_core.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 7dc77bdb29d0..db0164459bbe 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -368,7 +368,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, @@ -384,6 +384,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; @@ -402,6 +404,8 @@ int thermal_sensor_trip(struct thermal_zone_device *tz, } } + mutex_unlock(&tz->sensor.lock); + schedule_work(&tz->sensor.work); return ret; |