Patch "iio: pressure: bmp280: Fix BMP580 temperature reading" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    iio: pressure: bmp280: Fix BMP580 temperature reading

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iio-pressure-bmp280-fix-bmp580-temperature-reading.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2eff3512837f988cd739cac6072e7b3064c879d9
Author: Adam Rizkalla <ajarizzo@xxxxxxxxx>
Date:   Thu Apr 25 01:22:49 2024 -0500

    iio: pressure: bmp280: Fix BMP580 temperature reading
    
    [ Upstream commit 0f0f6306617cb4b6231fc9d4ec68ab9a56dba7c0 ]
    
    Fix overflow issue when storing BMP580 temperature reading and
    properly preserve sign of 24-bit data.
    
    Signed-off-by: Adam Rizkalla <ajarizzo@xxxxxxxxx>
    Tested-By: Vasileios Amoiridis <vassilisamir@xxxxxxxxx>
    Acked-by: Angel Iglesias <ang.iglesiasg@xxxxxxxxx>
    Link: https://lore.kernel.org/r/Zin2udkXRD0+GrML@xxxxxxxxxxxxxx
    Cc: <Stable@xxxxxxxxxxxxxxx>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 4c493db7db965..a65630d5742f0 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1385,12 +1385,12 @@ static int bmp580_read_temp(struct bmp280_data *data, int *val, int *val2)
 
 	/*
 	 * Temperature is returned in Celsius degrees in fractional
-	 * form down 2^16. We rescale by x1000 to return milli Celsius
-	 * to respect IIO ABI.
+	 * form down 2^16. We rescale by x1000 to return millidegrees
+	 * Celsius to respect IIO ABI.
 	 */
-	*val = raw_temp * 1000;
-	*val2 = 16;
-	return IIO_VAL_FRACTIONAL_LOG2;
+	raw_temp = sign_extend32(raw_temp, 23);
+	*val = ((s64)raw_temp * 1000) / (1 << 16);
+	return IIO_VAL_INT;
 }
 
 static int bmp580_read_press(struct bmp280_data *data, int *val, int *val2)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux