iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw()
Subsystems (3)
PATCH 1/1 iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw()
admv1013_read_raw() switches on chan->channel instead of chan->channel2 when handling IIO_CHAN_INFO_CALIBBIAS. The channel field only ever holds 0 or 1 (see ADMV1013_CHAN_CALIB()), while the IIO_MOD_I / IIO_MOD_Q modifiers are stored in channel2. As a result, the switch always falls through to the default case and calibbias reads always fail with -EINVAL, even though the corresponding admv1013_write_raw() path correctly uses channel2 and works as expected.
Fix the read path to switch on chan->channel2, matching the write path and the actual channel_spec definition.
--- drivers/iio/frequency/admv1013.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/frequency/admv1013.c +1 -1
@@ -195,7 +195,7 @@ static int admv1013_read_raw(struct iio_dev *indio_dev,switch (info) {case IIO_CHAN_INFO_CALIBBIAS : -switch (chan->channel) { +switch (chan->channel2) {case IIO_MOD_I : addr =ADMV1013_REG_OFFSET_ADJUST_I ;break ;
Signature · 1 line
2.43.0
Quoted 9 lines · On Wed, 19 Aug 2026 18:51:19 +0100 Salah Triki <[email protected]> wrote:
admv1013_read_raw()switches onchan->channelinstead ofchan->channel2when handlingIIO_CHAN_INFO_CALIBBIAS. The channel field only ever holds 0 or 1 (seeADMV1013_CHAN_CALIB()), while theIIO_MOD_I/IIO_MOD_Qmodifiers are stored in channel2. As a result, the switch always falls through to the default case and calibbias reads always fail with-EINVAL, even though the correspondingadmv1013_write_raw()path correctly uses channel2 and works as expected.
Quoted 5 lines
Fix the read path to switch on
chan->channel2, matching the write path and the actualchannel_specdefinition.Fixes da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")Signed-off-by Salah Triki <[email protected]>
This one is 'obviously correct' enough that I'll not wait long to apply it
Applied to the fixes-togreg branch of iio.git
Thanks
Jonathan
Quoted 17 lines
--- drivers/iio/frequency/admv1013.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/frequency/admv1013.c +1
-1@@ -195,7 +195,7 @@ static int admv1013_read_raw(struct iio_dev *indio_dev,switch (info) {case IIO_CHAN_INFO_CALIBBIAS : -switch (chan->channel) { +switch (chan->channel2) {case IIO_MOD_I : addr =ADMV1013_REG_OFFSET_ADJUST_I ;break ;