All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Chris Lesiak <chris.lesiak@licor.com>
Cc: Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	Peter Rosin <peda@axentia.se>, Jonathan Cameron <jic23@cam.ac.uk>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed
Date: Sat, 26 Dec 2020 00:01:49 +0100	[thread overview]
Message-ID: <CACRpkdbEcxkjLb-zJDui6bq2=OQA=v5-OG_6P0svX48AUMLyEA@mail.gmail.com> (raw)
In-Reply-To: <SN6PR08MB55657ED2F83CE43C97C9C1749ADD0@SN6PR08MB5565.namprd08.prod.outlook.com>

On Thu, Dec 24, 2020 at 4:15 AM Chris Lesiak <chris.lesiak@licor.com> wrote:

> A closer reading of the "iio: inkern: pass through raw values if no scaling"
> commit leads me to believe that even when the sensor provides no scale,
> the returned value is expected to be in the correct units.
>
> If that is true, there was a bug in the commit.
> It failed to apply the caller supplied scale that ntc_thermistor.c relies on
> to convert from milliVolts to microVolts.
>
> Linus, would this change address your original problem?
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index fe30bcb6a57b..79787474d511 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -587,7 +587,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>                  * Just pass raw values as processed if no scaling is
>                  * available.
>                  */
> -               *processed = raw;
> +               *processed = raw * scale;
>                 return 0;
>         }

I do not think the raw values have any obligation to be in
e.g. millivolts. They may be, by chance.

In my case, it is just an unscaled byte [0..255].

So it unfortunately does not solve my problem, because in my driver,
that does not support scaling, the result will be the raw value
* 1000 which is not going to be microvolts at all, because the
raw values are not millivolts, rather a value 0..255.

However if I used the processed values, the value will be
adjusted non-linearly to millivolts.

Yours,
Linus Walleij

  reply	other threads:[~2020-12-25 23:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-24  1:16 Linus Walleij
2020-12-24  1:39 ` Chris Lesiak
2020-12-24  3:15   ` Chris Lesiak
2020-12-25 23:01     ` Linus Walleij [this message]
2020-12-25 22:55   ` Linus Walleij
2020-12-26  1:45     ` Chris Lesiak
2020-12-27 13:46       ` Linus Walleij
2020-12-27 18:54         ` Chris Lesiak
2020-12-27 21:47           ` Linus Walleij
2020-12-27 22:08             ` Chris Lesiak
2020-12-29 14:25               ` Jonathan Cameron
2020-12-29 16:33                 ` Guenter Roeck
2020-12-29 16:53                   ` 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='CACRpkdbEcxkjLb-zJDui6bq2=OQA=v5-OG_6P0svX48AUMLyEA@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=chris.lesiak@licor.com \
    --cc=jdelvare@suse.com \
    --cc=jic23@cam.ac.uk \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=peda@axentia.se \
    --subject='Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.