From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: Sean Nyekjaer <sean@geanix.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] iio: accel: fxls8962af: Fix temperature calculation
Date: Thu, 1 May 2025 16:13:29 -0300 [thread overview]
Message-ID: <aBPH2dHgwI_4lHvj@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <20250501-fxls-v1-1-f54061a07099@geanix.com>
Hello Sean,
Overall, this looks good to me.
Only thing I think need to (not) change is the offset (see comment below).
Regards,
Marcelo
On 05/01, Sean Nyekjaer wrote:
> According to spec temperature should be returned in milli degrees Celsius.
> Add in_temp_scale to calculate from Celsius to milli Celsius.
>
> Fixes: a3e0b51884ee ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>
> ---
> drivers/iio/accel/fxls8962af-core.c | 17 ++++++++++++++---
...
>
> /* Raw temp channel offset */
> -#define FXLS8962AF_TEMP_CENTER_VAL 25
> +#define FXLS8962AF_TEMP_CENTER_VAL 25000
I think the offset was correct the way it was before.
For example, if the sensor at 37°C, the output code will be 0b00001100, 12 (decimal).
Then (_raw + _offset) * _scale = (12 + 25) * 1000 = 37000 milli °C
> +/* Raw temp channel scale */
> +#define FXLS8962AF_TEMP_SCALE 1000
>
...
> @@ -736,6 +746,7 @@ static const struct iio_event_spec fxls8962af_event[] = {
> .type = IIO_TEMP, \
> .address = FXLS8962AF_TEMP_OUT, \
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> + BIT(IIO_CHAN_INFO_SCALE) | \
> BIT(IIO_CHAN_INFO_OFFSET),\
> .scan_index = -1, \
> .scan_type = { \
Datasheet page 39 says 'the TEMP_OUT register contains the 8-bit, 2's complement
temperature value.'
So I think we can make the temperature scan element signed.
.sign = 's', \
Though, I guess that would be a thing for a separate patch.
next prev parent reply other threads:[~2025-05-01 19:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-01 13:13 Sean Nyekjaer
2025-05-01 19:13 ` Marcelo Schmitt [this message]
2025-05-02 5:34 ` Sean Nyekjaer
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=aBPH2dHgwI_4lHvj@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy.shevchenko@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sean@geanix.com \
--cc=stable@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
all inboxes | Powered by JetHome®