Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: chemical: scd4x: fix reported channel endianness

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>

authored by

Fiona Klute and committed by
Jonathan Cameron
81d5a536 943cbf90

+3 -3
+3 -3
drivers/iio/chemical/scd4x.c
··· 584 584 .sign = 'u', 585 585 .realbits = 16, 586 586 .storagebits = 16, 587 - .endianness = IIO_BE, 587 + .endianness = IIO_CPU, 588 588 }, 589 589 }, 590 590 { ··· 599 599 .sign = 'u', 600 600 .realbits = 16, 601 601 .storagebits = 16, 602 - .endianness = IIO_BE, 602 + .endianness = IIO_CPU, 603 603 }, 604 604 }, 605 605 { ··· 612 612 .sign = 'u', 613 613 .realbits = 16, 614 614 .storagebits = 16, 615 - .endianness = IIO_BE, 615 + .endianness = IIO_CPU, 616 616 }, 617 617 }, 618 618 };