Skip to contentSkip to conversation

patch "iio: temperature: mcp9600: Fix temperature reading for negative" added to char-misc-next

PATCH [email protected] 1 participant 1 message May 4, 2024

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

iio: temperature: mcp9600: Fix temperature reading for negative

to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-next branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will also be merged in the next major kernel release during the merge window.

If you have any questions about this process, please let me know.

From 827dca3129708a8465bde90c86c2e3c38e62dd4f Mon Sep 17 00:00:00 2001
From: Dimitri Fedrau <[email protected]>
Date: Wed, 24 Apr 2024 20:59:10 +0200
Subject: iio: temperature: mcp9600: Fix temperature reading for negative
values

Temperature is stored as 16bit value in two's complement format. Current implementation ignores the sign bit. Make it aware of the sign bit by using sign_extend32.

---
 drivers/iio/temperature/mcp9600.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/temperature/mcp9600.c +2 -1
index 46845804292b..7a3eef5d5e75 100644
@@ -52,7 +52,8 @@ static int mcp9600_read(struct mcp9600_data *data,
 
 	if (ret < 0)
 		return ret;
-	*val = ret;
+
+	*val = sign_extend32(ret, 15);
 
 	return 0;
 }
Signature · 1 line
2.45.0