diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2012-05-16 18:22:03 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-16 13:26:35 -0700 |
commit | 0462e2bb4e04f2facb32bc13611c7ca91c1c4468 (patch) | |
tree | 1ee44479126909ce87764a8c91df2a86e22792cd | |
parent | 5cdd9b75bf58422659d824d7aabf46bdb6a8e18c (diff) | |
download | linux-0462e2bb4e04f2facb32bc13611c7ca91c1c4468.tar.bz2 |
staging: iio: fix access to hmc5843 private data
i2c_get_clientdata(client) points to iio_dev, not hmc5843_data; fixes
issue similar to 62d2feb9803f18c4e3c8a1a2c7e30a54df8a1d72
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/iio/magnetometer/hmc5843.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index e3e65eabf85c..9eac2f11c1e6 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -250,7 +250,8 @@ static IIO_DEVICE_ATTR(operating_mode, static s32 hmc5843_set_meas_conf(struct i2c_client *client, u8 meas_conf) { - struct hmc5843_data *data = i2c_get_clientdata(client); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct hmc5843_data *data = iio_priv(indio_dev); u8 reg_val; reg_val = (meas_conf & MEAS_CONF_MASK) | (data->rate << RATE_OFFSET); return i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_A, reg_val); @@ -272,7 +273,7 @@ static ssize_t hmc5843_set_measurement_configuration(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct i2c_client *client = to_i2c_client(indio_dev->dev.parent); - struct hmc5843_data *data = i2c_get_clientdata(client); + struct hmc5843_data *data = iio_priv(indio_dev); unsigned long meas_conf = 0; int error = strict_strtoul(buf, 10, &meas_conf); if (error) @@ -314,7 +315,8 @@ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("0.5 1 2 5 10 20 50"); static s32 hmc5843_set_rate(struct i2c_client *client, u8 rate) { - struct hmc5843_data *data = i2c_get_clientdata(client); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct hmc5843_data *data = iio_priv(indio_dev); u8 reg_val; reg_val = (data->meas_conf) | (rate << RATE_OFFSET); @@ -600,8 +602,12 @@ static int hmc5843_suspend(struct device *dev) static int hmc5843_resume(struct device *dev) { - struct hmc5843_data *data = i2c_get_clientdata(to_i2c_client(dev)); - hmc5843_configure(to_i2c_client(dev), data->operating_mode); + struct i2c_client *client = to_i2c_client(dev); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct hmc5843_data *data = iio_priv(indio_dev); + + hmc5843_configure(client, data->operating_mode); + return 0; } |