iio: core: Add iio_read_acpi_mount_matrix() helper function
authorHans de Goede <hdegoede@redhat.com>
Thu, 25 Apr 2024 12:57:51 +0000 (14:57 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 29 Apr 2024 19:53:25 +0000 (20:53 +0100)
commit02eae0bb9538dc7dcb5a6bc2c3066bd6ca682969
tree846f3cf6ea9f218f0589d969c666add1fa4b7f6f
parent79df437b5661b2f7e1c0bad097fd18c4e154bb94
iio: core: Add iio_read_acpi_mount_matrix() helper function

The ACPI "ROTM" rotation matrix parsing code atm is already duplicated
between bmc150-accel-core.c and kxcjk-1013.c and a third user of this
is coming.

Add an iio_read_acpi_mount_matrix() helper function for this.
The 2 existing copies of the code are identical, except that
the kxcjk-1013.c has slightly better error logging.

To new helper is a 1:1 copy of the kxcjk-1013.c version, the only change
is the addition of a "char *acpi_method" parameter since some bmc150
dual-accel setups (360° hinges with 1 accel in kbd/base + 1 in display)
declare both accels in a single ACPI device with 2 different method names
for the 2 matrices. This new acpi_method parameter is not "const char *"
because the pathname parameter to acpi_evaluate_object() is not const.

The 2 existing copies of this function will be removed in further patches
in this series.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240425125754.76010-2-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/Makefile
drivers/iio/industrialio-acpi.c [new file with mode: 0644]
include/linux/iio/iio.h