aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-07-27 16:32:58 -0400
committerJonathan Cameron <jic23@kernel.org>2016-08-15 10:46:06 -0400
commit31f453eac56bdc41f434126bc2d5933b9fb720ec (patch)
tree9fb75478c35db4ccd381e17125349568e8e2effe
parent193e2d4fd91c5e5d563395f9577621dac4f4df31 (diff)
iio: pressure: bmp280: fix runtime suspend/resume crash
In commit 3d838118c6aa ("iio: pressure: bmp280: add power management") For some reason the code in the runtime suspend/resume hooks got wrong (I suspect in the ambition to cut down boilerplate) and it seems it was tested without CONFIG_PM and crashes like so for me: Unable to handle kernel NULL pointer dereference at virtual address 0000000c pgd = c0204000 [0000000c] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 1 PID: 89 Comm: kworker/1:2 Not tainted 4.7.0-03348-g90dc3680458a-dirty #99 Hardware name: Generic DT based system Workqueue: pm pm_runtime_work task: df3c6300 ti: dec8a000 task.ti: dec8a000 PC is at regulator_disable+0x0/0x6c LR is at bmp280_runtime_suspend+0x3c/0xa4 Dereferencing the BMP280 state container properly fixes the problem, sorry for screwing up. Fixes: 3d838118c6aa ("iio: pressure: bmp280: add power management") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/pressure/bmp280-core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 94e27b2600f3..e5a533cbd53f 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
1079#ifdef CONFIG_PM 1079#ifdef CONFIG_PM
1080static int bmp280_runtime_suspend(struct device *dev) 1080static int bmp280_runtime_suspend(struct device *dev)
1081{ 1081{
1082 struct bmp280_data *data = dev_get_drvdata(dev); 1082 struct iio_dev *indio_dev = dev_get_drvdata(dev);
1083 struct bmp280_data *data = iio_priv(indio_dev);
1083 int ret; 1084 int ret;
1084 1085
1085 ret = regulator_disable(data->vdda); 1086 ret = regulator_disable(data->vdda);
@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
1090 1091
1091static int bmp280_runtime_resume(struct device *dev) 1092static int bmp280_runtime_resume(struct device *dev)
1092{ 1093{
1093 struct bmp280_data *data = dev_get_drvdata(dev); 1094 struct iio_dev *indio_dev = dev_get_drvdata(dev);
1095 struct bmp280_data *data = iio_priv(indio_dev);
1094 int ret; 1096 int ret;
1095 1097
1096 ret = regulator_enable(data->vddd); 1098 ret = regulator_enable(data->vddd);