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

Commit 12ef9356 authored by Oliver Wang's avatar Oliver Wang Committed by Gerrit - the friendly Code Review server
Browse files

input: sensors: fix batching can't be disabled issue



Batching should be disabled after writing 0 to max_latency sysfs
node. Fix it by correct the batching activation logic.

Change-Id: Idbdc883fcbb9d4ad4042512068becf69725f4650
Signed-off-by: default avatarOliver Wang <mengmeng@codeaurora.org>
parent cb6af3ac
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1738,6 +1738,7 @@ static int lis3dh_latency_set(struct sensors_classdev *cdev,
	struct lis3dh_acc_data *acc = container_of(cdev,
		struct lis3dh_acc_data, cdev);
	struct i2c_client *client = acc->client;
	int ret;

	/* Does not support batch in while interrupt is not enabled */
	if (!acc->pdata->enable_int) {
@@ -1745,8 +1746,16 @@ static int lis3dh_latency_set(struct sensors_classdev *cdev,
			"Cannot set batch mode, interrupt is not enabled!\n");
		return -EPERM;
	}
	acc->use_batch = max_latency ? true : false;

	acc->fifo_timeout_ms = max_latency;
	acc->use_batch = max_latency ? true : false;

	ret = lis3dh_acc_enable_batch(acc, max_latency);
	if (ret) {
		dev_err(&client->dev, "enable batch:%d failed\n", max_latency);
		return ret;
	}

	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ static ssize_t sensors_max_latency_store(struct device *dev,
	}

	/* Disable batching for this sensor */
	if (latency < sensors_cdev->delay_msec) {
	if ((latency < sensors_cdev->delay_msec) && (latency != 0)) {
		dev_err(dev, "max_latency is less than delay_msec\n");
		return -EINVAL;
	}