aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-05-25 03:40:26 -0400
committerJonathan Cameron <jic23@kernel.org>2016-05-29 14:50:56 -0400
commit13c27e946ddc0e19f3d8b307b14cd8053fcb4844 (patch)
treedd35e04a7bcf46282005fb10cc87634974d53e9b
parent09bc0ddaab6cab0fa95a67d5535ec772e2671193 (diff)
iio: bh1780: dereference the client properly
The code in runtime_[suspend|resume] was assuming that the i2c client data was the bh1780 state container, but it contains the IIO device. So first dereference the IIO device from the i2c client, then get the state container using the iio_priv() call. Fixes: 1f0477f18306 ("iio: light: new driver for the ROHM BH1780") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/light/bh1780.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
index f83595334ff1..5fd432df2c8f 100644
--- a/drivers/iio/light/bh1780.c
+++ b/drivers/iio/light/bh1780.c
@@ -226,7 +226,8 @@ static int bh1780_remove(struct i2c_client *client)
226static int bh1780_runtime_suspend(struct device *dev) 226static int bh1780_runtime_suspend(struct device *dev)
227{ 227{
228 struct i2c_client *client = to_i2c_client(dev); 228 struct i2c_client *client = to_i2c_client(dev);
229 struct bh1780_data *bh1780 = i2c_get_clientdata(client); 229 struct iio_dev *indio_dev = i2c_get_clientdata(client);
230 struct bh1780_data *bh1780 = iio_priv(indio_dev);
230 int ret; 231 int ret;
231 232
232 ret = bh1780_write(bh1780, BH1780_REG_CONTROL, BH1780_POFF); 233 ret = bh1780_write(bh1780, BH1780_REG_CONTROL, BH1780_POFF);
@@ -241,7 +242,8 @@ static int bh1780_runtime_suspend(struct device *dev)
241static int bh1780_runtime_resume(struct device *dev) 242static int bh1780_runtime_resume(struct device *dev)
242{ 243{
243 struct i2c_client *client = to_i2c_client(dev); 244 struct i2c_client *client = to_i2c_client(dev);
244 struct bh1780_data *bh1780 = i2c_get_clientdata(client); 245 struct iio_dev *indio_dev = i2c_get_clientdata(client);
246 struct bh1780_data *bh1780 = iio_priv(indio_dev);
245 int ret; 247 int ret;
246 248
247 ret = bh1780_write(bh1780, BH1780_REG_CONTROL, BH1780_PON); 249 ret = bh1780_write(bh1780, BH1780_REG_CONTROL, BH1780_PON);