public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Salah Triki <salah.triki@gmail.com>
To: "Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Salah Triki <salah.triki@gmail.com>
Subject: [PATCH] iio: temperature: max30208: fix wrong scale value
Date: Tue, 28 Apr 2026 09:54:15 +0100	[thread overview]
Message-ID: <20260428085415.52858-1-salah.triki@gmail.com> (raw)

The driver currently returns a scale of 5 for IIO_CHAN_INFO_SCALE, which
leads to incorrect temperature readings.

According to the MAX30208 datasheet, the temperature resolution is 0.005°C
per LSB. Using IIO_VAL_FRACTIONAL with 5/1000 correctly represents this
16-bit resolution.

Fix the scale value to ensure user space tools report the temperature
correctly in Celsius.

Fixes: 9ee95ae4cffd ("iio: temperature: Add driver support for Maxim
MAX30208")
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/iio/temperature/max30208.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/temperature/max30208.c b/drivers/iio/temperature/max30208.c
index 720469f9dc36..96f63c4fb2b6 100644
--- a/drivers/iio/temperature/max30208.c
+++ b/drivers/iio/temperature/max30208.c
@@ -163,7 +163,8 @@ static int max30208_read(struct iio_dev *indio_dev,
 
 	case IIO_CHAN_INFO_SCALE:
 		*val = 5;
-		return IIO_VAL_INT;
+		*val2 = 1000;
+		return IIO_VAL_FRACTIONAL;
 
 	default:
 		return -EINVAL;
-- 
2.43.0


             reply	other threads:[~2026-04-28  8:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  8:54 Salah Triki [this message]
2026-04-28 11:00 ` [PATCH] iio: temperature: max30208: fix wrong scale value Andy Shevchenko
2026-04-28 13:36   ` Salah Triki
2026-04-28 15:34     ` Jonathan Cameron
2026-04-28 15:43       ` Andy Shevchenko
2026-04-28 15:56     ` 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=20260428085415.52858-1-salah.triki@gmail.com \
    --to=salah.triki@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=nuno.sa@analog.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