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

Commit f9c169eb authored by Ram Chandrasekar's avatar Ram Chandrasekar Committed by Gerrit - the friendly Code Review server
Browse files

msm: limits: Bypass sensor poll disable if sensor throttling



Fix concurrency issues when a read and new throttling
intensity value updation happens simultaneously.

Added a new return value in interrupt reset API to notify
the caller that the particular sensor is still throttling.
On receiving this error, the lmh interface driver should
not reset interrupt but try again to read the throttling
intensity value later.

Change-Id: I883e4c6b9438ff73d9451acc897b623db9c677cf
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent 72a7aeac
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -303,7 +303,7 @@ static void lmh_interrupt_monitor(struct work_struct *work)
	struct lmh_mon_sensor_data *lmh_sensor = container_of(work,
				struct lmh_mon_sensor_data, isr_poll.work);

	down_read(&lmh_sensor->lock);
	down_write(&lmh_sensor->lock);
	ret = lmh_sensor->sensor_ops->read(lmh_sensor->sensor_ops, &val);
	if (ret) {
		pr_err("Error reading the sensor:[%s]. err:%d\n",
@@ -312,24 +312,25 @@ static void lmh_interrupt_monitor(struct work_struct *work)
	}
	lmh_evaluate_and_notify(lmh_sensor, val);
	if (val <= 0) {
		up_read(&lmh_sensor->lock);
		down_write(&lmh_sensor->lock);
		pr_debug("Rearm sensor:[%s] interrupt\n",
			lmh_sensor->sensor_name);
		lmh_sensor->state = LMH_ISR_MONITOR;
		ret = lmh_sensor->sensor_ops->reset_interrupt(
				lmh_sensor->sensor_ops);
		if (ret)
		if (ret == -EAGAIN)
			goto schedule_and_exit;
		else if (ret)
			pr_err("Sensor:[%s] interrupt reset failed. err:%d\n",
					lmh_sensor->sensor_name, ret);
		up_write(&lmh_sensor->lock);
		return;
		pr_debug("Rearm sensor:[%s] interrupt\n",
			lmh_sensor->sensor_name);
		lmh_sensor->state = LMH_ISR_MONITOR;
		goto exit_monitor;
	}

schedule_and_exit:
	schedule_delayed_work(&lmh_sensor->isr_poll,
		msecs_to_jiffies(lmh_poll_interval));

exit_monitor:
	up_read(&lmh_sensor->lock);
	up_write(&lmh_sensor->lock);
}

void lmh_interrupt_notify(struct lmh_sensor_ops *ops, long trip_val)