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

Configure Feed

Select the types of activity you want to include in your feed.

iio: accel: st_accel: Fix invalid mount_matrix on devices without ACPI _ONT method

When apply_acpi_orientation() fails, st_accel_common_probe() will fall back
to iio_read_mount_matrix(), which checks for a mount-matrix device property
and if that is not set falls back to the identity matrix.

But when a sensor has no ACPI companion fwnode, or when the ACPI fwnode
does not have a "_ONT" method apply_acpi_orientation() was returning 0,
causing iio_read_mount_matrix() to never get called resulting in an
invalid mount_matrix:

[root@fedora ~]# cat /sys/bus/iio/devices/iio\:device0/mount_matrix
(null), (null), (null); (null), (null), (null); (null), (null), (null)

Fix this by making apply_acpi_orientation() always return an error when
it did not set the mount_matrix.

Fixes: 3d8ad94bb175 ("iio: accel: st_sensors: Support generic mounting matrix")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Marius Hoch <mail@mariushoch.de>
Link: https://lore.kernel.org/r/20230416212409.310936-1-hdegoede@redhat.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Hans de Goede and committed by
Jonathan Cameron
79b8ded9 e6506513

+2 -2
+2 -2
drivers/iio/accel/st_accel_core.c
··· 1291 1291 1292 1292 adev = ACPI_COMPANION(indio_dev->dev.parent); 1293 1293 if (!adev) 1294 - return 0; 1294 + return -ENXIO; 1295 1295 1296 1296 /* Read _ONT data, which should be a package of 6 integers. */ 1297 1297 status = acpi_evaluate_object(adev->handle, "_ONT", NULL, &buffer); 1298 1298 if (status == AE_NOT_FOUND) { 1299 - return 0; 1299 + return -ENXIO; 1300 1300 } else if (ACPI_FAILURE(status)) { 1301 1301 dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n", 1302 1302 status);