]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: adc: ad7606: dynamically allocate channel info
authorDavid Lechner <dlechner@baylibre.com>
Tue, 18 Mar 2025 22:52:17 +0000 (17:52 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:09:54 +0000 (19:09 +0100)
commit3b5b55ca940733b7b533fe3137a307ceacb4fb90
tree03f0ff65a06d715976fdae6c11ff82ec3b77ca3e
parentc1f571c3ca17cf3ab3e32f33d773b8e04378c189
iio: adc: ad7606: dynamically allocate channel info

Refactor the ad7606 drivers to dynamically allocate the channel info.

The channel info was getting a bit unwieldy. In some cases, the
indio_dev->channels field was getting assigned up to 3 different times,
each in a different function, making it difficult to see where the info
was coming from. This problem stems from the number of permutations of
the channel array needed to support various modes of operation and data
buses. We already have 4 per chip (hardware mode, software mode, AXI ADC
backend and AXI ADC backend with software mode) and we intend to add two
more per chip when adding SPI offload support.

To make it easier to read and maintain, move all of the channel setup
to a single function that dynamically allocates and fills in the channel
info.

Additionally, this lets us remove some hacks where we had to compute an
offset due to the fact that sometimes there was a soft timestamp channel
at the start of the array. Now the timestamp channel is always at the
end of the array as is typical in other drivers.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-9-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7606.c
drivers/iio/adc/ad7606.h
drivers/iio/adc/ad7606_par.c
drivers/iio/adc/ad7606_spi.c