Re: [PATCH v4 5/8] iio: adc: ad7606: Add compatibility to fw_nodes

From: Guillaume Stols
Date: Wed Oct 09 2024 - 10:54:46 EST



On 10/9/24 16:39, Nuno Sá wrote:
On Wed, 2024-10-09 at 09:19 +0000, Guillaume Stols wrote:
On the parallel version, the current implementation is only compatible
with id tables and won't work with fw_nodes, this commit intends to fix
it.

Doing so required to declare ad7606_chip_info structures in the .h file
so to make them accessible to all the driver files that can set a
pointer to the corresponding chip as the driver data.

Signed-off-by: Guillaume Stols <gstols@xxxxxxxxxxxx>
---
 drivers/iio/adc/ad7606.c     | 283 ++++++++++++++++++++++++-------------------
 drivers/iio/adc/ad7606.h     |  32 +++--
 drivers/iio/adc/ad7606_par.c |  30 +++--
 drivers/iio/adc/ad7606_spi.c |  96 +++++++++------
 4 files changed, 254 insertions(+), 187 deletions(-)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 5b276d087ec3..dfbdea8c28ba 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -78,6 +78,155 @@ static const unsigned int ad7616_oversampling_avail[8] = {

...

+const struct ad7606_chip_info ad7616_info = {
+ .channels = ad7616_channels,
+ .init_delay_ms = 15,
+ .name = "ad7616",
+ .num_channels = 17,
+ .oversampling_avail = ad7616_oversampling_avail,
+ .oversampling_num = ARRAY_SIZE(ad7616_oversampling_avail),
+ .os_req_reset = true,
+ .scale_setup_cb = ad7606_16bit_chan_scale_setup,
+};
+EXPORT_SYMBOL_NS_GPL(ad7616_info, IIO_AD7606);

Maybe my eyes are tricking me but I'm not seeing any MODULE_IMPORT_NS() in the
drivers?

Hi Nuno,

The ad7606_spi.c and ad7606_par.c use MODULE_IMPORT_NS(IIO_AD7606).

Chip infos are used in the "coupling" structures, e.g:

 static const struct ad7606_bus_info ad7616_bus_info = {
     .chip_info = &ad7616_info,¬
     .bops = &ad7616_spi_bops,¬
 };¬

Guillaume

- Nuno Sá