Commit 79b8ded9 authored by Hans de Goede's avatar Hans de Goede Committed by Jonathan Cameron

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: 3d8ad94b ("iio: accel: st_sensors: Support generic mounting matrix")
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Tested-by: default avatarMarius Hoch <mail@mariushoch.de>
Link: https://lore.kernel.org/r/20230416212409.310936-1-hdegoede@redhat.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent e6506513
...@@ -1291,12 +1291,12 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev) ...@@ -1291,12 +1291,12 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
adev = ACPI_COMPANION(indio_dev->dev.parent); adev = ACPI_COMPANION(indio_dev->dev.parent);
if (!adev) if (!adev)
return 0; return -ENXIO;
/* Read _ONT data, which should be a package of 6 integers. */ /* Read _ONT data, which should be a package of 6 integers. */
status = acpi_evaluate_object(adev->handle, "_ONT", NULL, &buffer); status = acpi_evaluate_object(adev->handle, "_ONT", NULL, &buffer);
if (status == AE_NOT_FOUND) { if (status == AE_NOT_FOUND) {
return 0; return -ENXIO;
} else if (ACPI_FAILURE(status)) { } else if (ACPI_FAILURE(status)) {
dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n", dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n",
status); status);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment