From: Salah Triki <salah.triki@gmail.com>
To: "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: tmp006: Fix endianness byte swap in trigger handler
Date: Mon, 7 Sep 2026 09:22:15 +0100 [thread overview]
Message-ID: <20260907082216.52821-1-salah.triki@gmail.com> (raw)
In tmp006_trigger_handler(), i2c_smbus_read_word_data() is used to read
the VOBJECT and TAMBIENT registers. However, the TMP006 stores register
values in Big Endian byte order, while i2c_smbus_read_word_data() assumes
Little Endian.
This causes byte-swapped values to be pushed to the IIO buffer on Little
Endian architectures, leading to corrupted sensor readings when using
triggered buffers.
Fix this by switching to i2c_smbus_read_word_swapped() inside the trigger
handler.
Fixes: 91f75ccf9f03 ("iio: temperature: tmp006: add triggered buffer support")
Assisted-by: LLM
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
drivers/iio/temperature/tmp006.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index d9f6449ec0d8..f3b3de0bf221 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -256,12 +256,12 @@ static irqreturn_t tmp006_trigger_handler(int irq, void *p)
} scan = { };
s32 ret;
- ret = i2c_smbus_read_word_data(data->client, TMP006_VOBJECT);
+ ret = i2c_smbus_read_word_swapped(data->client, TMP006_VOBJECT);
if (ret < 0)
goto err;
scan.channels[0] = ret;
- ret = i2c_smbus_read_word_data(data->client, TMP006_TAMBIENT);
+ ret = i2c_smbus_read_word_swapped(data->client, TMP006_TAMBIENT);
if (ret < 0)
goto err;
scan.channels[1] = ret;
--
2.43.0
next reply other threads:[~2026-09-07 8:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 8:22 Salah Triki [this message]
2026-09-07 14:47 ` Joshua Crofts
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=20260907082216.52821-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=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
all inboxes | Powered by JetHome®