Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7476: Conditionally call convstart

The ad7476 supports two IC variants which may have a 'convstart' -GPIO
for starting the conversion. Currently the driver calls a function which
tries to access the GPIO for all of the IC variants, whether they
support 'convstart' or not. This is not an error because this function
returns early if GPIO information is not populated.

We can do a tad better by calling this function only for the ICs which
have the 'convstart' by providing a function pointer to the convstart
function from the chip_info structure, and calling this function only
for the ICs which have the function pointer set.

This does also allow to support ICs which require different convstart
handling than the currently supported ICs.

Call convstart function only on the ICs which can support it and allow
IC-specific convstart functions for the ICs which require different
handling.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/9760cde888fac7335c17d7ab63d5fb2e7c59ac51.1754901948.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
27ec39c7 84977a7a

+7 -2
+7 -2
drivers/iio/adc/ad7476.c
··· 31 31 unsigned int int_vref_mv; 32 32 struct iio_chan_spec channel[2]; 33 33 void (*reset)(struct ad7476_state *); 34 + void (*conversion_pre_op)(struct ad7476_state *st); 34 35 bool has_vref; 35 36 bool has_vdrive; 36 37 }; ··· 71 70 struct ad7476_state *st = iio_priv(indio_dev); 72 71 int b_sent; 73 72 74 - ad7091_convst(st); 73 + if (st->chip_info->conversion_pre_op) 74 + st->chip_info->conversion_pre_op(st); 75 75 76 76 b_sent = spi_sync(st->spi, &st->msg); 77 77 if (b_sent < 0) ··· 96 94 { 97 95 int ret; 98 96 99 - ad7091_convst(st); 97 + if (st->chip_info->conversion_pre_op) 98 + st->chip_info->conversion_pre_op(st); 100 99 101 100 ret = spi_sync(st->spi, &st->msg); 102 101 if (ret) ··· 163 160 static const struct ad7476_chip_info ad7091_chip_info = { 164 161 .channel[0] = AD7091R_CHAN(12), 165 162 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), 163 + .conversion_pre_op = ad7091_convst, 166 164 .reset = ad7091_reset, 167 165 }; 168 166 169 167 static const struct ad7476_chip_info ad7091r_chip_info = { 170 168 .channel[0] = AD7091R_CHAN(12), 171 169 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), 170 + .conversion_pre_op = ad7091_convst, 172 171 .int_vref_mv = 2500, 173 172 .has_vref = true, 174 173 .reset = ad7091_reset,