Re: [PATCH v3 1/4] iio: accel: adxl372: introduce chip_info structure

From: Andy Shevchenko

Date: Fri Mar 13 2026 - 10:02:51 EST


On Fri, Mar 13, 2026 at 01:54:54PM +0200, Antoniu Miclaus wrote:
> Introduce a chip_info structure to parameterize device-specific
> properties such as ODR/bandwidth frequency tables, activity/inactivity
> timer scale factors, and the maximum ODR value. This refactors the
> driver to use chip_info lookups instead of hardcoded values, preparing
> the driver to support multiple device variants.
>
> The sampling_frequency and filter_low_pass_3db_frequency available
> attributes are switched from custom sysfs callbacks to read_avail()
> based handling via info_mask_shared_by_type_available. This enforces
> consistent formatting through the IIO framework and makes the values
> accessible to in-kernel consumers.
>
> The SPI/I2C probe functions are updated to pass a chip_info pointer
> instead of a device name string.
>
> No functional change intended.

...

> enum adxl372_odr {

> ADXL372_ODR_1600HZ,
> ADXL372_ODR_3200HZ,
> ADXL372_ODR_6400HZ,
> + ADXL372_ODR_NUM,

No comma for the terminator entry.

> };

...

> static const struct iio_event_spec adxl372_events[] = {

> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
> BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
> BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \

Consider at some point making the above consistent by style with the below

.info_mask_shared_by_type =
BIT(IIO_CHAN_INFO_SCALE) | \
BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \

> + .info_mask_shared_by_type_available = \
> + BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
> + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \
> .scan_index = index, \

> };

...

> + chip_info = i2c_get_match_data(client);

> + if (!chip_info)
> + return -ENODEV;

It is an agreement to avoid adding a dead code such as above check.

...

> + chip_info = spi_get_device_match_data(spi);
> + if (!chip_info)
> + return -ENODEV;

Ditto.

--
With Best Regards,
Andy Shevchenko