]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: chemical: scd4x: fix reported channel endianness
authorFiona Klute <fiona.klute@gmx.de>
Tue, 27 Jan 2026 15:52:02 +0000 (10:52 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Feb 2026 15:44:20 +0000 (16:44 +0100)
[ Upstream commit 81d5a5366d3c20203fb9d7345e1aa46d668445a2 ]

The driver converts values read from the sensor from BE to CPU
endianness in scd4x_read_meas(). The result is then pushed into the
buffer in scd4x_trigger_handler(), so on LE architectures parsing the
buffer using the reported BE type gave wrong results.

scd4x_read_raw() which provides sysfs *_raw values is not affected, it
used the values returned by scd4x_read_meas() without further
conversion.

Fixes: 49d22b695cbb6 ("drivers: iio: chemical: Add support for Sensirion SCD4x CO2 sensor")
Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/chemical/scd4x.c

index 54066532ea4589139a0e384ffec59a43a3db691b..690c70b94a57bbb63d3f09a1bc2254b7a507fbec 100644 (file)
@@ -518,7 +518,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
                        .sign = 'u',
                        .realbits = 16,
                        .storagebits = 16,
-                       .endianness = IIO_BE,
+                       .endianness = IIO_CPU,
                },
        },
        {
@@ -533,7 +533,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
                        .sign = 'u',
                        .realbits = 16,
                        .storagebits = 16,
-                       .endianness = IIO_BE,
+                       .endianness = IIO_CPU,
                },
        },
        {
@@ -546,7 +546,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
                        .sign = 'u',
                        .realbits = 16,
                        .storagebits = 16,
-                       .endianness = IIO_BE,
+                       .endianness = IIO_CPU,
                },
        },
 };