Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Guillaume Ranquet <granquet@baylibre.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] iio: adc: ad7173: add calibration support
Date: Sat, 30 Nov 2024 19:11:38 +0000	[thread overview]
Message-ID: <20241130191138.6305f23c@jic23-huawei> (raw)
In-Reply-To: <20241127-ad411x_calibration-v2-1-66412dac35aa@baylibre.com>

On Wed, 27 Nov 2024 10:06:13 +0100
Guillaume Ranquet <granquet@baylibre.com> wrote:

> The ad7173 family of chips has up to four calibration modes.
> 
> Internal zero scale: removes ADC core offset errors.
> Internal full scale: removes ADC core gain errors.
> System zero scale: reduces offset error to the order of channel noise.
> System full scale: reduces gain error to the order of channel noise.
> 
> All voltage channels will undergo an internal zero/full scale
> calibration at bootup.
> 
> System zero/full scale can be done after bootup using the newly created
> iio interface 'sys_calibration' and 'sys_calibration_mode'
> 
> Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>


>  static const struct iio_chan_spec ad7173_temp_iio_channel_template = {
> @@ -1213,6 +1329,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
>  	struct iio_chan_spec *chan_arr, *chan;
>  	unsigned int ain[AD7173_NO_AINS_PER_CHANNEL], chan_index = 0;
>  	int ref_sel, ret, num_channels;
> +	u8 *calib_mode;
>  
>  	num_channels = device_get_child_node_count(dev);
>  
> @@ -1240,8 +1357,14 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
>  	if (!chans_st_arr)
>  		return -ENOMEM;
>  
> +	calib_mode = devm_kcalloc(dev, st->num_channels, sizeof(*st->syscalib_mode),
> +				  GFP_KERNEL);
As it is per channel, can we put it in struct ad7173_channel?

This driver already has a lot of small allocations. Avoiding an extra one would nice!

> +	if (!calib_mode)
> +		return -ENOMEM;
> +
>  	indio_dev->channels = chan_arr;
>  	st->channels = chans_st_arr;
> +	st->syscalib_mode = calib_mode;
>  
>  	if (st->info->has_temp) {
>  		chan_arr[chan_index] = ad7173_temp_iio_channel_template;
> 


  reply	other threads:[~2024-11-30 19:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27  9:06 [PATCH v2 0/2] iio: adc: ad7173: add calibration support to chip family Guillaume Ranquet
2024-11-27  9:06 ` [PATCH v2 1/2] iio: adc: ad7173: add calibration support Guillaume Ranquet
2024-11-30 19:11   ` Jonathan Cameron [this message]
2024-11-27  9:06 ` [PATCH v2 2/2] iio: adc: ad-sigma-delta: Document ABI for sigma delta adc Guillaume Ranquet
2024-11-30 19:06   ` Jonathan Cameron
2024-12-02  9:28     ` Guillaume Ranquet

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=20241130191138.6305f23c@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=granquet@baylibre.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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