]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: temperature: mcp9600: Fix temperature reading for negative values
authorDimitri Fedrau <dima.fedrau@gmail.com>
Wed, 24 Apr 2024 18:59:10 +0000 (20:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Jun 2024 12:40:35 +0000 (14:40 +0200)
commitc70cc82c800365b91bdebc97fd829c249ffab35d
tree60d44cd3b51d425e0463dffe735b44e2272b0d21
parent6f0cfe3b8de76e709a3dab4d2e2a6ae9ff85cd81
iio: temperature: mcp9600: Fix temperature reading for negative values

commit 827dca3129708a8465bde90c86c2e3c38e62dd4f upstream.

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.

Fixes: 3f6b9598b6df ("iio: temperature: Add MCP9600 thermocouple EMF converter")
Signed-off-by: Dimitri Fedrau <dima.fedrau@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Tested-by: Andrew Hepp <andrew.hepp@ahepp.dev>
Link: https://lore.kernel.org/r/20240424185913.1177127-1-dima.fedrau@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/temperature/mcp9600.c