linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: pressure: bmp280: Fix incorrect pointer access in PM callbacks
@ 2016-08-12 11:44 Jarkko Nikula
  2016-08-12 12:21 ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Jarkko Nikula @ 2016-08-12 11:44 UTC (permalink / raw)
  To: linux-iio
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Linus Walleij, Jarkko Nikula

BMP280 runtime PM callbacks are incorrectly casting dev_get_drvdata() to
struct bmp280_data * while bmp280_common_probe() sets driver data to
struct iio_dev *. Fix this and get the struct bmp280_data * from private
data of struct iio_dev.

Fixes: 3d838118c6aa ("iio: pressure: bmp280: add power management")
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
For v4.8-rc.
---
 drivers/iio/pressure/bmp280-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6943688e66df..724fefd4af00 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
 #ifdef CONFIG_PM
 static int bmp280_runtime_suspend(struct device *dev)
 {
-	struct bmp280_data *data = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
 	ret = regulator_disable(data->vdda);
@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
 
 static int bmp280_runtime_resume(struct device *dev)
 {
-	struct bmp280_data *data = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
 	ret = regulator_enable(data->vddd);
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-15 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 11:44 [PATCH] iio: pressure: bmp280: Fix incorrect pointer access in PM callbacks Jarkko Nikula
2016-08-12 12:21 ` Linus Walleij
2016-08-12 12:36   ` Jarkko Nikula
2016-08-15 14:46     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).