mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org>
Cc: radu.sabau@analog.com, Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Nuno Sa <nuno.sa@analog.com>,
	David Lechner <dlechner@baylibre.com>,
	Andy Shevchenko <andy@kernel.org>,
	Alexandru Ardelean <alexandru.ardelean@analog.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux@analog.com
Subject: Re: [PATCH v4 8/8] iio: imu: adis16607: Add calibration bias support for gyro/accel
Date: Mon, 26 Oct 2026 00:15:27 +0000	[thread overview]
Message-ID: <20261026001527.456f2472@jic23-hlaptop> (raw)
In-Reply-To: <20261023-adis16607-v4-8-a4d541ebfd13@analog.com>

On Fri, 23 Oct 2026 12:30:25 +0300
Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@kernel.org> wrote:

> From: Radu Sabau <radu.sabau@analog.com>
> 
> Add IIO_CHAN_INFO_CALIBBIAS support for the gyroscope and
> accelerometer axes, backed by the device's per-axis bias registers
> (XA/YA/ZA_BIAS, XG/YG/ZG_BIAS).
> 
> Signed-off-by: Radu Sabau <radu.sabau@analog.com>
I'd missed the use of scan_index in here.  That seems like very
fragile coding to me. Moving over to address is going to require
changes a few patches back.

> +
>  /*
>   * SPI Half-Duplex read operation for ADIS16607.
>   * Protocol:
> @@ -863,6 +878,7 @@ static int adis16607_read_raw(struct iio_dev *indio_dev,
>  			      int *val, int *val2, long info)
>  {
>  	struct adis16607 *st = iio_priv(indio_dev);
> +	const int idx = chan->scan_index;

As below. This to me is hurting readability a little.
Using scan_index for this is a bit fragile anyway as those can
be changed by people expecting them to only about buffered capture.
This should be using address and that may well mean you need that
to become a lookup into an array of multiple register addresses
needed for a given channel rather than directly to one register as
currently.


>  	int ret;
>  	u32 tmp;
>  
> @@ -900,6 +916,16 @@ static int adis16607_read_raw(struct iio_dev *indio_dev,
>  		*val = 5000;
>  		return IIO_VAL_INT;
>  
> +	case IIO_CHAN_INFO_CALIBBIAS: {
> +		u16 tmp16;
> +
> +		ret = adis_read_reg_16(&st->adis, adis16607_calib_bias[idx], &tmp16);
> +		if (ret)
> +			return ret;
> +		*val = sign_extend32(tmp16, 15);
> +		return IIO_VAL_INT;
> +	}
> +
>  	case IIO_CHAN_INFO_SAMP_FREQ:
>  		ret = adis16607_get_freq(st, &tmp);
>  		if (ret)
> @@ -918,6 +944,7 @@ static int adis16607_write_raw(struct iio_dev *indio_dev,
>  			       int val, int val2, long info)
>  {
>  	struct adis16607 *st = iio_priv(indio_dev);
> +	const int idx = chan->scan_index;

I'd just go long on the line that uses this or at least push declaring it
down to the case statement that uses it.

>  	u32 tmp;
>  
>  	switch (info) {
> @@ -925,6 +952,11 @@ static int adis16607_write_raw(struct iio_dev *indio_dev,
>  		tmp = val * 1000 + val2 / 1000;
>  		return adis16607_set_freq(st, tmp);
>  
> +	case IIO_CHAN_INFO_CALIBBIAS:
> +		if (val < S16_MIN || val > S16_MAX)
> +			return -EINVAL;
> +		return adis_write_reg_16(&st->adis, adis16607_calib_bias[idx], val);
> +
>  	default:
>  		return -EINVAL;
>  	}
> @@ -934,7 +966,8 @@ static int adis16607_write_raw(struct iio_dev *indio_dev,
>  	.type = (_type), \
>  	.modified = 1, \
>  	.channel2 = (_mod), \
> -	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> +			      BIT(IIO_CHAN_INFO_CALIBBIAS), \
>  	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
>  	.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
>  	.address = (_address), \
> 


      reply	other threads:[~2026-10-26  0:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  9:30 [PATCH v4 0/8] iio: imu: Add support for the ADI ADIS16607 Radu Sabau via B4 Relay
2026-10-23  9:30 ` [PATCH v4 1/8] iio: imu: adis: Add optional self_test callback Radu Sabau via B4 Relay
2026-10-23  9:30 ` [PATCH v4 2/8] iio: imu: adis: Fix custom reset dispatch in adislib Radu Sabau via B4 Relay
2026-10-23  9:30 ` [PATCH v4 3/8] iio: imu: adis: Add optional post_reset_setup callback Radu Sabau via B4 Relay
2026-10-25 23:52   ` Jonathan Cameron
2026-10-26  9:52     ` Sabau, Radu bogdan
2026-10-23  9:30 ` [PATCH v4 4/8] dt-bindings: iio: imu: Add bindings for ADI ADIS16607 Radu Sabau via B4 Relay
2026-10-25 23:54   ` Jonathan Cameron
2026-10-23  9:30 ` [PATCH v4 5/8] iio: imu: Add driver for the " Radu Sabau via B4 Relay
2026-10-23 10:26   ` Andy Shevchenko
2026-10-26 10:22     ` Sabau, Radu bogdan
2026-10-26 10:50       ` Andy Shevchenko
2026-10-23  9:30 ` [PATCH v4 6/8] iio: imu: adis16607: Add FIFO-based buffered/triggered capture Radu Sabau via B4 Relay
2026-10-26  0:09   ` Jonathan Cameron
2026-10-27  9:36     ` Sabau, Radu bogdan
2026-10-23  9:30 ` [PATCH v4 7/8] iio: imu: adis16607: Add external clock sync support Radu Sabau via B4 Relay
2026-10-26  0:11   ` Jonathan Cameron
2026-10-26 10:54     ` Sabau, Radu bogdan
2026-10-23  9:30 ` [PATCH v4 8/8] iio: imu: adis16607: Add calibration bias support for gyro/accel Radu Sabau via B4 Relay
2026-10-26  0:15   ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261026001527.456f2472@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+radu.sabau.analog.com@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=radu.sabau@analog.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®