From: Andrew Hepp <andrew.hepp@ahepp.dev>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Dimitri Fedrau <dima.fedrau@gmail.com>,
Marcelo Schmitt <marcelo.schmitt1@gmail.com>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: temperature: mcp9600: Fix temperature reading for negative values
Date: Sun, 28 Apr 2024 14:46:39 -0400 [thread overview]
Message-ID: <C96CEE0A-920C-4BDD-9689-058B2E6D4B29@ahepp.dev> (raw)
In-Reply-To: <20240428144606.5b3d9a7e@jic23-huawei>
Hi all,
On Apr 28, 2024, at 9:46 AM, Jonathan Cameron <jic23@kernel.org> wrote:
> Agreed - by my reading the original patch is correct. Maybe it would act
> as cleaner 'documentation' to have the sign_extend32() for the cold junction be
> from bit 12 rather than 15, but I'm not sure it's worth the effort.
>
> Andrew, would be great if you can review this fix in case we are all missing
> something!
I also agree that Dimitri’s original patch appears correct per the data sheet.
I think of the cold junction register as a 16 bit 2s complement signed integer,
despite the limited range. I like sign extending it from bit 15 rather than from 12.
I applied Dimitri’s patch and stuck a dev board in my icebox.
Before patch:
# cat /sys/bus/iio/devices/iio:device0/in_temp_raw
65222
# cat /sys/bus/iio/devices/iio:device0/in_temp_ambient_raw
65256
After patch:
# cat /sys/bus/iio/devices/iio:device0/in_temp_raw
-260
# cat /sys/bus/iio/devices/iio:device0/in_temp_ambient_raw
-212
Looks good to me! Thanks for the patch Dimitri, and thanks to all for the review!
Andrew
next prev parent reply other threads:[~2024-04-28 19:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 18:59 [PATCH] iio: temperature: mcp9600: Fix temperature reading for negative values Dimitri Fedrau
2024-04-27 8:49 ` Marcelo Schmitt
2024-04-27 19:57 ` Dimitri Fedrau
2024-04-28 13:46 ` Jonathan Cameron
2024-04-28 18:46 ` Andrew Hepp [this message]
2024-04-29 19:44 ` Jonathan Cameron
2024-04-28 18:53 ` Marcelo Schmitt
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=C96CEE0A-920C-4BDD-9689-058B2E6D4B29@ahepp.dev \
--to=andrew.hepp@ahepp.dev \
--cc=dima.fedrau@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).