summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ad7091r5.c
diff options
context:
space:
mode:
authorMarcelo Schmitt <marcelo.schmitt@analog.com>2023-12-19 21:29:30 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2023-12-26 16:42:24 +0100
commit8eb5976abfc5990367ca660ce8e222bba6f812c3 (patch)
treee8e44e4142dd449becfc2209765c4198ac7882f7 /drivers/iio/adc/ad7091r5.c
parentiio: adc: ad7091r: Set device mode through chip_info callback (diff)
downloadlinux-8eb5976abfc5990367ca660ce8e222bba6f812c3.tar.xz
linux-8eb5976abfc5990367ca660ce8e222bba6f812c3.zip
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 '')
-rw-r--r--drivers/iio/adc/ad7091r5.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/iio/adc/ad7091r5.c b/drivers/iio/adc/ad7091r5.c
index e1163b42609c..a75837334157 100644
--- a/drivers/iio/adc/ad7091r5.c
+++ b/drivers/iio/adc/ad7091r5.c
@@ -54,11 +54,17 @@ static int ad7091r5_set_mode(struct ad7091r_state *st, enum ad7091r_mode mode)
return 0;
}
+static unsigned int ad7091r5_reg_result_chan_id(unsigned int val)
+{
+ return AD7091R5_REG_RESULT_CH_ID(val);
+}
+
static const struct ad7091r_chip_info ad7091r5_chip_info_irq = {
.name = "ad7091r-5",
.channels = ad7091r5_channels_irq,
.num_channels = ARRAY_SIZE(ad7091r5_channels_irq),
.vref_mV = 2500,
+ .reg_result_chan_id = &ad7091r5_reg_result_chan_id,
.set_mode = &ad7091r5_set_mode,
};
@@ -67,6 +73,7 @@ static const struct ad7091r_chip_info ad7091r5_chip_info_noirq = {
.channels = ad7091r5_channels_noirq,
.num_channels = ARRAY_SIZE(ad7091r5_channels_noirq),
.vref_mV = 2500,
+ .reg_result_chan_id = &ad7091r5_reg_result_chan_id,
.set_mode = &ad7091r5_set_mode,
};