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

* Re: [PATCH] iio: pressure: bmp280: Fix incorrect pointer access in PM callbacks
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2016-08-12 12:21 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: linux-iio@vger.kernel.org, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler

On Fri, Aug 12, 2016 at 1:44 PM, Jarkko Nikula
<jarkko.nikula@linux.intel.com> wrote:

> 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.

Sent a fix for this already two weeks ago:
http://marc.info/?l=linux-iio&m=146965159217655&w=2

Just waiting for it to be picked up and merged.

Yours,
Linus Walleij

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

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

On 08/12/2016 03:21 PM, Linus Walleij wrote:
> On Fri, Aug 12, 2016 at 1:44 PM, Jarkko Nikula
> <jarkko.nikula@linux.intel.com> wrote:
>
>> 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.
>
> Sent a fix for this already two weeks ago:
> http://marc.info/?l=linux-iio&m=146965159217655&w=2
>
> Just waiting for it to be picked up and merged.
>
Ok, please feel free to add my tested by to your patch then

Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>

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

* Re: [PATCH] iio: pressure: bmp280: Fix incorrect pointer access in PM callbacks
  2016-08-12 12:36   ` Jarkko Nikula
@ 2016-08-15 14:46     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2016-08-15 14:46 UTC (permalink / raw)
  To: Jarkko Nikula, Linus Walleij
  Cc: linux-iio@vger.kernel.org, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler

On 12/08/16 13:36, Jarkko Nikula wrote:
> On 08/12/2016 03:21 PM, Linus Walleij wrote:
>> On Fri, Aug 12, 2016 at 1:44 PM, Jarkko Nikula
>> <jarkko.nikula@linux.intel.com> wrote:
>>
>>> 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.
>>
>> Sent a fix for this already two weeks ago:
>> http://marc.info/?l=linux-iio&m=146965159217655&w=2
>>
>> Just waiting for it to be picked up and merged.
>>
> Ok, please feel free to add my tested by to your patch then
> 
> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Added.

^ permalink raw reply	[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).