[PATCH] iio: adc: ad9467: Fix the "don't allow reading vref if not available" case

From: Christophe JAILLET
Date: Thu Dec 05 2024 - 15:57:15 EST


The commit in Fixes add a special case when only one possible scale is
available.
If several scales are available, it sets the .read_avail field of the
struct iio_info to ad9467_read_avail().

However, this field already holds this function pointer, so the code is a
no-op.

Update ad9467_info to actually reflect the intent described in the commit
message. Keep .read_avail to NULL, unless it is changed to
ad9467_read_avail() in the probe at runtime.

Fixes: b92f94f74826 ("iio: adc: ad9467: don't allow reading vref if not available")
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
This patch is compile tested only and is completely speculative.

Another solution would be to keep ad9467_info as a const struct as it was
before and add a new ad9467_info_no_read structure.
This way, instead of writing in the structure itself, we would choose at
runtime which version to use. The main benefit would be keep this structure
with function pointer const.
---
drivers/iio/adc/ad9467.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
index d358958ab310..356637677524 100644
--- a/drivers/iio/adc/ad9467.c
+++ b/drivers/iio/adc/ad9467.c
@@ -900,7 +900,6 @@ static struct iio_info ad9467_info = {
.write_raw = ad9467_write_raw,
.update_scan_mode = ad9467_update_scan_mode,
.debugfs_reg_access = ad9467_reg_access,
- .read_avail = ad9467_read_avail,
};

static int ad9467_scale_fill(struct ad9467_state *st)
--
2.47.1