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

Commit cca00cb0 authored by Oliver Wang's avatar Oliver Wang
Browse files

input: sensor: fix data polling continues even resume fails



The data polling would continues if device resume fails. The
previous logic will free the input device in this condition.
But the polling thread used it without checking and this will
cause the kernel crash.

CRs-fixed: 575581
Change-Id: I88f862e2447b808fecab70d32599c68eceec90eb
Signed-off-by: default avatarOliver Wang <mengmeng@codeaurora.org>
parent 76ccdc74
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -673,15 +673,7 @@ static int lightsensor_enable(struct cm36283_info *lpi)
	unsigned int delay;

	mutex_lock(&als_enable_mutex);

	if (lpi->als_enable) {
		dev_err(&lpi->i2c_client->dev, "%s: already enabled\n",
			       __func__);
		ret = 0;
	} else {
	ret = control_and_report(lpi, CONTROL_ALS, 1, 0);
	}
	
	mutex_unlock(&als_enable_mutex);

	delay = atomic_read(&lpi->ls_poll_delay);
@@ -1975,27 +1967,40 @@ static int cm36283_suspend(struct device *dev)
	struct cm36283_info *lpi = lp_info;

	if (lpi->als_enable) {
		lightsensor_disable(lpi);
		if (lightsensor_disable(lpi))
			goto out;
		lpi->als_enable = 1;
	}
	cm36283_power_set(lpi, 0);
	if (cm36283_power_set(lpi, 0))
		goto out;

	return 0;

out:
	dev_err(&lpi->i2c_client->dev, "%s:failed during resume operation.\n",
			__func__);
	return -EIO;
}

static int cm36283_resume(struct device *dev)
{
	struct cm36283_info *lpi = lp_info;

	cm36283_power_set(lpi, 1);
	if (cm36283_power_set(lpi, 1))
		goto out;

	if (lpi->als_enable) {
		cm36283_setup(lpi);
		lightsensor_setup(lpi);
		psensor_setup(lpi);
		lightsensor_enable(lpi);
		ls_initial_cmd(lpi);
		psensor_initial_cmd(lpi);
		if (lightsensor_enable(lpi))
			goto out;
	}
	return 0;

out:
	dev_err(&lpi->i2c_client->dev, "%s:failed during resume operation.\n",
			__func__);
	return -EIO;
}
#endif