diff options
author | Vlad Dogaru <vlad.dogaru@intel.com> | 2015-06-30 13:20:59 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-07-19 12:48:15 +0200 |
commit | 0d1462de0b24fd09284411a3753f24a3d7c67577 (patch) | |
tree | 000a2ff347c33cb7cb498ba602af5d4fa1d245e2 | |
parent | iio: sx9500: rework error handling of raw readings (diff) | |
download | linux-0d1462de0b24fd09284411a3753f24a3d7c67577.tar.xz linux-0d1462de0b24fd09284411a3753f24a3d7c67577.zip |
iio: sx9500: fix bug in compensation code
The initial compensation was mistakingly toggling an extra bit in the
control register. Fix this and make sure it's less likely to happen by
introducing an additional macro.
Reported-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/proximity/sx9500.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index 21eaa167a784..d260509d6000 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -80,6 +80,7 @@ #define SX9500_COMPSTAT_MASK GENMASK(3, 0) #define SX9500_NUM_CHANNELS 4 +#define SX9500_CHAN_MASK GENMASK(SX9500_NUM_CHANNELS - 1, 0) struct sx9500_data { struct mutex mutex; @@ -802,8 +803,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev) unsigned int val; ret = regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0, - GENMASK(SX9500_NUM_CHANNELS, 0), - GENMASK(SX9500_NUM_CHANNELS, 0)); + SX9500_CHAN_MASK, SX9500_CHAN_MASK); if (ret < 0) return ret; @@ -823,7 +823,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev) out: regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0, - GENMASK(SX9500_NUM_CHANNELS, 0), 0); + SX9500_CHAN_MASK, 0); return ret; } |