Re: [PATCH v7 5/7] iio: imu: Add driver for the ADI ADIS16607

From: Jonathan Cameron

Date: Wed Nov 18 2026 - 22:25:06 EST


On Wed, 18 Nov 2026 15:17:47 +0200
Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@xxxxxxxxxx> wrote:

> From: Radu Sabau <radu.sabau@xxxxxxxxxx>
>
> The ADIS16607 is a Precision MEMS IMU from Analog Devices with
> triaxial gyroscope and accelerometer, delta angle/velocity, and
> temperature channels, communicating over a custom SPI Half-Duplex
> protocol. ADIS16607-2 has a ±450°/s gyroscope range, ADIS16607-3
> ±2000°/s; both share a ±40g accelerometer range and an 8 kHz internal
> clock.
>
> This is the base driver: probe, raw channel reads, sampling-frequency
> control, startup/self-test via adislib, and debugfs identity entries.
>
> Self-test leaves the device's SELF_TEST register cleared on every exit
> path, not just on success, so a read failure or a failed delta check
> doesn't leave the sensor stuck in its self-test/force state until the
> next reset.
>
> Signed-off-by: Radu Sabau <radu.sabau@xxxxxxxxxx>
One really minor thing inline. If that's all that comes up
it isn't worth a respin.

> diff --git a/drivers/iio/imu/adis16607.c b/drivers/iio/imu/adis16607.c
> new file mode 100644
> index 000000000000..c53f3e62d3fc
> --- /dev/null
> +++ b/drivers/iio/imu/adis16607.c

> +
> +static int adis16607_set_freq(struct adis16607 *st, u32 freq)
> +{
> + u32 dec;
> + int ret;
> +
> + if (!freq)
> + return -EINVAL;
> +
> + dec = DIV_ROUND_CLOSEST(st->clk_freq_mHz, freq);
> + if (dec)
> + dec--;
> +
> + dec = min(dec, st->info->max_dec);
> +
> + adis_dev_auto_scoped_lock(&st->adis) {

Why not just
adis_dev_auto_lock() ?

Seems like that would be fine through this series.


> + /* Reset the decimation accumulator before the new value */
> + ret = __adis_write_reg_16(&st->adis, ADIS16607_REG_DEC_RATE, 0);
> + if (ret)
> + return ret;
> +
> + st->dec = 0;
> +
> + if (dec) {
> + ret = __adis_write_reg_16(&st->adis,
> + ADIS16607_REG_DEC_RATE, dec);
> + if (ret)
> + return ret;
> +
> + st->dec = dec;
> + }
> + }
> +
> + return 0;
> +}
> +
> +/*
> + * .address is an index into adis16607_chan_regs[] for this driver, not a
> + * literal register like adis_single_conversion() expects, and the channel
> + * spec carries no scan_type for it to take the register width and sign
> + * extension from. Resolve both on a local copy rather than reimplementing
> + * the helper's locking logic ourselves.
> + */
> +static int adis16607_raw_read(struct iio_dev *indio_dev,
> + const struct iio_chan_spec *chan, int *val)
> +{
> + struct iio_chan_spec raw_chan = *chan;
> + bool is_temp = chan->type == IIO_TEMP;
> +
> + raw_chan.address = adis16607_chan_regs[chan->address].raw_reg;
> + raw_chan.scan_type.sign = 's';
> + raw_chan.scan_type.realbits = is_temp ? 16 : 24;
> + raw_chan.scan_type.storagebits = is_temp ? 16 : 32;
> +
> + return adis_single_conversion(indio_dev, &raw_chan, 0, val);
> +}