Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw()
@ 2026-08-19 17:51 Salah Triki
  2026-08-23  1:04 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Salah Triki @ 2026-08-19 17:51 UTC (permalink / raw)
  To: Nuno Sá, Michael Hennerich, Antoniu Miclaus,
	Jonathan Cameron, David Lechner, Andy Shevchenko
  Cc: linux, linux-iio, linux-kernel, Salah Triki

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.

Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/iio/frequency/admv1013.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/frequency/admv1013.c b/drivers/iio/frequency/admv1013.c
index b823adfb0f70..bb06a94ccc50 100644
--- a/drivers/iio/frequency/admv1013.c
+++ b/drivers/iio/frequency/admv1013.c
@@ -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;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw()
  2026-08-19 17:51 [PATCH] iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw() Salah Triki
@ 2026-08-23  1:04 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-08-23  1:04 UTC (permalink / raw)
  To: Salah Triki
  Cc: Nuno Sá, Michael Hennerich, Antoniu Miclaus, David Lechner,
	Andy Shevchenko, linux, linux-iio, linux-kernel

On Wed, 19 Aug 2026 18:51:19 +0100
Salah Triki <salah.triki@gmail.com> wrote:

> 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.
> 
> Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013")
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
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

> ---
>  drivers/iio/frequency/admv1013.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/frequency/admv1013.c b/drivers/iio/frequency/admv1013.c
> index b823adfb0f70..bb06a94ccc50 100644
> --- a/drivers/iio/frequency/admv1013.c
> +++ b/drivers/iio/frequency/admv1013.c
> @@ -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;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-23  1:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 17:51 [PATCH] iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw() Salah Triki
2026-08-23  1:04 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox