summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/ad7091r-base.c
diff options
context:
space:
mode:
authorMarcelo Schmitt <marcelo.schmitt@analog.com>2023-12-19 23:29:30 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2023-12-26 18:42:24 +0300
commit8eb5976abfc5990367ca660ce8e222bba6f812c3 (patch)
treee8e44e4142dd449becfc2209765c4198ac7882f7 /drivers/iio/adc/ad7091r-base.c
parent7e3ebda32d6e8f10acbde2b204f6bf4020f7ef95 (diff)
downloadlinux-8eb5976abfc5990367ca660ce8e222bba6f812c3.tar.xz
iio: adc: ad7091r: Add chip_info callback to get conversion result channel
AD7091R-5 and AD7091R-2/-4/-8 have slightly different register field layout and due to that require different masks for getting the index of the channel associated with each read. Add a callback function so the base driver can get correct channel ID for each chip variant. Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Link: https://lore.kernel.org/r/1f7a40b4839b3a1c3f1a0654a1b329bea870feb6.1703013352.git.marcelo.schmitt1@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ad7091r-base.c')
-rw-r--r--drivers/iio/adc/ad7091r-base.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c
index a4ca2e21e023..665e930d67d0 100644
--- a/drivers/iio/adc/ad7091r-base.c
+++ b/drivers/iio/adc/ad7091r-base.c
@@ -16,10 +16,6 @@
#include "ad7091r-base.h"
-/* AD7091R_REG_RESULT */
-#define AD7091R_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3)
-#define AD7091R_REG_RESULT_CONV_RESULT(x) ((x) & 0xfff)
-
const struct iio_event_spec ad7091r_events[] = {
{
.type = IIO_EV_TYPE_THRESH,
@@ -74,7 +70,7 @@ static int ad7091r_read_one(struct iio_dev *iio_dev,
if (ret)
return ret;
- if (AD7091R_REG_RESULT_CH_ID(val) != channel)
+ if (st->chip_info->reg_result_chan_id(val) != channel)
return -EIO;
*read_val = AD7091R_REG_RESULT_CONV_RESULT(val);