Re: [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure
From: Andy Shevchenko
Date: Tue Mar 24 2026 - 08:25:04 EST
On Tue, Mar 24, 2026 at 03:13:28PM +0800, Carlos Jones Jr wrote:
> Introduce a chip_info structure to facilitate adding support for
> chip variants with different channel configurations and timing
> requirements.
>
> The chip_info structure contains:
> - Device name for proper sysfs identification
> - Channel specifications and count
> - Read delay timing for variants requiring settling time
>
> The ltc2309 struct is modified to store only the read_delay_us value
> rather than a pointer to the full chip_info, as this is the only
> runtime-accessed field after probe.
>
> This preparatory refactoring does not modify existing LTC2309
> functionality.
...
> #include <linux/bitfield.h>
> +#include <linux/delay.h>
> #include <linux/i2c.h>
> #include <linux/iio/iio.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/array_size.h>
It starts with 'a'...
...
> +struct ltc2309_chip_info {
> + const char *name;
> + unsigned int num_channels;
> + const struct iio_chan_spec *channels __counted_by_ptr(num_channels);
> + unsigned int read_delay_us;
Now on some architectures this might have gaps. Have you run `pahole`?
Even if it's fine, I would rather see
const char *name;
const struct iio_chan_spec *channels __counted_by_ptr(num_channels);
unsigned int num_channels;
unsigned int read_delay_us;
OR (if there are limitations of __counted_by_ptr() attribute)
const char *name;
unsigned int read_delay_us;
unsigned int num_channels;
const struct iio_chan_spec *channels __counted_by_ptr(num_channels);
> +};
...
> +static const struct ltc2309_chip_info ltc2309_chip_info = {
> + .name = "ltc2309",
> + .num_channels = ARRAY_SIZE(ltc2309_channels),
> + .channels = ltc2309_channels,
> +};
> +
> +
One blank line too many.
...
> static int ltc2309_probe(struct i2c_client *client)
> {
> struct iio_dev *indio_dev;
> struct ltc2309 *ltc2309;
> + const struct ltc2309_chip_info *chip_info;
Try to preserve reversed xmas tree order.
> int ret;
--
With Best Regards,
Andy Shevchenko