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

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

msm: lmh_lite: check intensity value before enabling interrupt



Update the driver to check the last read intensity
value for all sensors before enabling the interrupt.
Also clear the last read value before getting the
intensity value from trustzone. This will cover the
cases, where the trustzone read errored out.

Change-Id: Iac22078c0ba92704e2448670248e99880e133d08
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent eb43795d
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -111,7 +111,10 @@ static int lmh_read(struct lmh_sensor_ops *ops, long *val)
	struct lmh_sensor_data *lmh_sensor = container_of(ops,
		       struct lmh_sensor_data, ops);

	mutex_lock(&lmh_sensor_read);
	*val = lmh_sensor->last_read_value;
	mutex_unlock(&lmh_sensor_read);

	return 0;
}

@@ -183,6 +186,7 @@ enable_exit:
static int lmh_reset(struct lmh_sensor_ops *ops)
{
	int ret = 0;
	struct lmh_sensor_data *lmh_iter_sensor = NULL;
	struct lmh_sensor_data *lmh_sensor = container_of(ops,
		       struct lmh_sensor_data, ops);

@@ -202,8 +206,25 @@ static int lmh_reset(struct lmh_sensor_ops *ops)
		goto reset_exit;
	}

	if (!lmh_data->intr_status_val) {
		/* Scan through the sensor list and abort the interrupt
		 * enable if any of the sensor is still throttling */
		list_for_each_entry(lmh_iter_sensor, &lmh_sensor_list,
			list_ptr) {
			if (lmh_iter_sensor->last_read_value) {
				pr_debug("Sensor:[%s] retrigger interrupt\n",
					lmh_iter_sensor->sensor_name);
				lmh_data->intr_status_val
					|= BIT(lmh_iter_sensor->sensor_sw_id);
				lmh_iter_sensor->state = LMH_ISR_POLLING;
				lmh_iter_sensor->ops.interrupt_notify(
					&lmh_iter_sensor->ops,
					lmh_iter_sensor->last_read_value);
			}
		}
		if (!lmh_data->intr_status_val)
			lmh_data->intr_state = LMH_ISR_MONITOR;
	}

reset_exit:
	up_write(&lmh_sensor_access);
@@ -232,6 +253,8 @@ static void lmh_read_and_update(struct lmh_driver_data *lmh_dat)


	mutex_lock(&lmh_sensor_read);
	list_for_each_entry(lmh_sensor, &lmh_sensor_list, list_ptr)
		lmh_sensor->last_read_value = 0;
	payload.count = 0;
	desc_arg.args[0] = cmd_buf.addr = SCM_BUFFER_PHYS(&payload);
	desc_arg.args[1] = cmd_buf.size
@@ -254,8 +277,6 @@ static void lmh_read_and_update(struct lmh_driver_data *lmh_dat)
		goto read_exit;
	}

	list_for_each_entry(lmh_sensor, &lmh_sensor_list, list_ptr)
		lmh_sensor->last_read_value = 0;
	for (idx = 0; idx < payload.count; idx++) {
		list_for_each_entry(lmh_sensor, &lmh_sensor_list, list_ptr) {