iio: bmc150-accel-core: Use iio_read_acpi_mount_matrix() helper
Replace the duplicate ACPI "ROTM" data parsing code with the new shared iio_read_acpi_mount_matrix() helper. 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-4-hdegoede@redhat.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
e074cc3080
commit
dd3f40b539
@ -386,13 +386,9 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
|
||||
static bool bmc150_apply_bosc0200_acpi_orientation(struct device *dev,
|
||||
struct iio_mount_matrix *orientation)
|
||||
{
|
||||
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
struct iio_dev *indio_dev = dev_get_drvdata(dev);
|
||||
struct acpi_device *adev = ACPI_COMPANION(dev);
|
||||
char *name, *alt_name, *label, *str;
|
||||
union acpi_object *obj, *elements;
|
||||
acpi_status status;
|
||||
int i, j, val[3];
|
||||
char *name, *alt_name, *label;
|
||||
|
||||
if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0) {
|
||||
alt_name = "ROMK";
|
||||
@ -411,43 +407,7 @@ static bool bmc150_apply_bosc0200_acpi_orientation(struct device *dev,
|
||||
return false;
|
||||
}
|
||||
|
||||
status = acpi_evaluate_object(adev->handle, name, NULL, &buffer);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
dev_warn(dev, "Failed to get ACPI mount matrix: %d\n", status);
|
||||
return false;
|
||||
}
|
||||
|
||||
obj = buffer.pointer;
|
||||
if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 3)
|
||||
goto unknown_format;
|
||||
|
||||
elements = obj->package.elements;
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (elements[i].type != ACPI_TYPE_STRING)
|
||||
goto unknown_format;
|
||||
|
||||
str = elements[i].string.pointer;
|
||||
if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3)
|
||||
goto unknown_format;
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
switch (val[j]) {
|
||||
case -1: str = "-1"; break;
|
||||
case 0: str = "0"; break;
|
||||
case 1: str = "1"; break;
|
||||
default: goto unknown_format;
|
||||
}
|
||||
orientation->rotation[i * 3 + j] = str;
|
||||
}
|
||||
}
|
||||
|
||||
kfree(buffer.pointer);
|
||||
return true;
|
||||
|
||||
unknown_format:
|
||||
dev_warn(dev, "Unknown ACPI mount matrix format, ignoring\n");
|
||||
kfree(buffer.pointer);
|
||||
return false;
|
||||
return iio_read_acpi_mount_matrix(dev, orientation, name);
|
||||
}
|
||||
|
||||
static bool bmc150_apply_dual250e_acpi_orientation(struct device *dev,
|
||||
|
Loading…
Reference in New Issue
Block a user