iio: adc: ad7606: rework available attributes for SW channels
authorAlexandru Ardelean <aardelean@baylibre.com>
Thu, 19 Sep 2024 13:04:40 +0000 (16:04 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 30 Sep 2024 08:21:04 +0000 (09:21 +0100)
commit94aab7a0f5c77f1ee9be87fab3524807d78cf560
treee9c0d6101d7c2deaa626e7ca82b775bf5d1f048d
parentbbd478f2cb0e3352c0af9078ea51643c0a497fa8
iio: adc: ad7606: rework available attributes for SW channels

For SW mode, the oversampling and scales attributes are always present.
So, they can be implemented via a 'read_avail' hook in iio_info.

For HW mode, it's a bit tricky, as these attributes get assigned based on
GPIO definitions.

So, for SW mode, we define a separate AD7606_SW_CHANNEL() macro, and use
that for the SW channels.
And 'ad7606_info_os_range_and_debug' can be renamed to
'ad7606_info_sw_mode' as it is only used for SW mode.

For the 'read_avail' hook, we'll need to allocate the SW scales, so that
they are just returned userspace without any extra processing.
The allocation will happen when then ad7606_state struct is allocated.
The oversampling available parameters don't need any extra processing; they
can just be passed back to userspace (as they are).

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240919130444.2100447-6-aardelean@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_spi. [new file with mode: 0644]