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>
This commit is contained in:
Vlad Dogaru 2015-06-30 14:20:59 +03:00 committed by Jonathan Cameron
parent 498adaeb89
commit 0d1462de0b
1 changed files with 3 additions and 3 deletions

View File

@ -80,6 +80,7 @@
#define SX9500_COMPSTAT_MASK GENMASK(3, 0) #define SX9500_COMPSTAT_MASK GENMASK(3, 0)
#define SX9500_NUM_CHANNELS 4 #define SX9500_NUM_CHANNELS 4
#define SX9500_CHAN_MASK GENMASK(SX9500_NUM_CHANNELS - 1, 0)
struct sx9500_data { struct sx9500_data {
struct mutex mutex; struct mutex mutex;
@ -802,8 +803,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev)
unsigned int val; unsigned int val;
ret = regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0, ret = regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0,
GENMASK(SX9500_NUM_CHANNELS, 0), SX9500_CHAN_MASK, SX9500_CHAN_MASK);
GENMASK(SX9500_NUM_CHANNELS, 0));
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -823,7 +823,7 @@ static int sx9500_init_compensation(struct iio_dev *indio_dev)
out: out:
regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0, regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0,
GENMASK(SX9500_NUM_CHANNELS, 0), 0); SX9500_CHAN_MASK, 0);
return ret; return ret;
} }