linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marcelo Schmitt <marcelo.schmitt@analog.com>
Cc: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lars@metafoo.de>,
	<Michael.Hennerich@analog.com>, <dlechner@baylibre.com>,
	<nuno.sa@analog.com>, <andy@kernel.org>, <robh@kernel.org>,
	<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<marcelo.schmitt1@gmail.com>
Subject: Re: [PATCH v2 6/7] iio: adc: ad4170: Add support for internal temperature sensor
Date: Sun, 4 May 2025 18:44:48 +0100	[thread overview]
Message-ID: <20250504184448.43b8045e@jic23-huawei> (raw)
In-Reply-To: <c249f5c7ee07583b65cd40b0fc6f1faa79c3bfe9.1745841276.git.marcelo.schmitt@analog.com>

On Mon, 28 Apr 2025 09:29:12 -0300
Marcelo Schmitt <marcelo.schmitt@analog.com> wrote:

> The AD4170 has an internal temperature sensor that can be read using the
> ADC. Whenever possible, configure an IIO channel to provide the chip's
> temperature.
> 
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>

One trivial comment below.
I don't mind that much given you already did it this way though.

>  /*
>   * Receives the number of a multiplexed AD4170 input (ain_n), and stores the
>   * voltage (in µV) of the specified input into ain_voltage. If the input number
> @@ -1189,9 +1210,27 @@ static int ad4170_read_raw(struct iio_dev *indio_dev,
>  		return ret;
>  	case IIO_CHAN_INFO_SCALE:
>  		pga = FIELD_GET(AD4170_AFE_PGA_GAIN_MSK, setup->afe);
> -		*val = chan_info->scale_tbl[pga][0];
> -		*val2 = chan_info->scale_tbl[pga][1];
> -		return IIO_VAL_INT_PLUS_NANO;
> +		switch (chan->type) {
> +		case IIO_VOLTAGE:

When you know you are going to have changes like this in later patches
in the same posted series it is fine to make the diff smaller by
using a switch from the start.

Occasionally you'll get a comment from someone like me who can't
hold the whole set in my head and misses that is what is going on.
Just reply to say it was diff minimization and likely no one will ever
mind!

> +			*val = chan_info->scale_tbl[pga][0];
> +			*val2 = chan_info->scale_tbl[pga][1];
> +			return IIO_VAL_INT_PLUS_NANO;
> +
> +		case IIO_TEMP:
> +			/*
> +			 * The scale_tbl converts output codes to mV units so
> +			 * multiply by MILLI to make the factor convert to µV.
> +			 * Then, apply the temperature sensor change sensitivity
> +			 * of 477 μV/K. Finally, multiply the result by MILLI
> +			 * again to comply with milli degrees Celsius IIO ABI.
> +			 */
> +			*val = 0;
> +			*val2 = DIV_ROUND_CLOSEST(chan_info->scale_tbl[pga][1] * MILLI,
> +						  477) * MILLI;
> +			return IIO_VAL_INT_PLUS_NANO;
> +		default:
> +			return -EINVAL;
> +		}


  parent reply	other threads:[~2025-05-04 17:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 12:27 [PATCH v2 0/7] iio: adc: Add support for AD4170 series of ADCs Marcelo Schmitt
2025-04-28 12:27 ` [PATCH v2 1/7] dt-bindings: iio: adc: Add AD4170 Marcelo Schmitt
2025-05-09 18:56   ` Rob Herring
2025-05-11 15:27     ` Marcelo Schmitt
2025-04-28 12:28 ` [PATCH v2 2/7] iio: adc: Add basic support for AD4170 Marcelo Schmitt
2025-05-02 11:28   ` Andy Shevchenko
2025-05-12 13:23     ` Marcelo Schmitt
2025-05-04 18:21   ` Jonathan Cameron
2025-04-28 12:28 ` [PATCH v2 3/7] iio: adc: ad4170: Add support for buffered data capture Marcelo Schmitt
2025-04-29 22:00   ` Andy Shevchenko
2025-04-30 13:40     ` Marcelo Schmitt
2025-05-02  8:56       ` Andy Shevchenko
2025-05-04 17:27       ` Jonathan Cameron
2025-05-04 17:57   ` Jonathan Cameron
2025-04-28 12:28 ` [PATCH v2 4/7] iio: adc: ad4170: Add clock provider support Marcelo Schmitt
2025-04-29 22:10   ` Andy Shevchenko
2025-05-06  8:21   ` kernel test robot
2025-04-28 12:28 ` [PATCH v2 5/7] iio: adc: ad4170: Add GPIO controller support Marcelo Schmitt
2025-04-29 22:14   ` Andy Shevchenko
2025-05-04 17:50   ` Jonathan Cameron
2025-04-28 12:29 ` [PATCH v2 6/7] iio: adc: ad4170: Add support for internal temperature sensor Marcelo Schmitt
2025-04-29 22:16   ` Andy Shevchenko
2025-05-04 17:44   ` Jonathan Cameron [this message]
2025-04-28 12:29 ` [PATCH v2 7/7] iio: adc: ad4170: Add support for weigh scale and RTD sensors Marcelo Schmitt
2025-04-29 22:26   ` Andy Shevchenko
2025-05-01 19:50   ` kernel test robot
2025-05-04 17:42   ` Jonathan Cameron

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=20250504184448.43b8045e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.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=marcelo.schmitt1@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=nuno.sa@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;
as well as URLs for NNTP newsgroup(s).