iio: acpi: Improve iio_read_acpi_mount_matrix()
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Thu, 24 Oct 2024 19:04:53 +0000 (22:04 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 28 Oct 2024 20:04:11 +0000 (20:04 +0000)
By using ACPI_HANDLE() the handler argument can be retrieved directly.
Replace ACPI_COMPANION() + dereference with ACPI_HANDLE().

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241024191200.229894-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-acpi.c

index 981b75d..1e46908 100644 (file)
@@ -28,17 +28,21 @@ bool iio_read_acpi_mount_matrix(struct device *dev,
                                char *acpi_method)
 {
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-       struct acpi_device *adev = ACPI_COMPANION(dev);
        char *str;
        union acpi_object *obj, *elements;
+       acpi_handle handle;
        acpi_status status;
        int i, j, val[3];
        bool ret = false;
 
-       if (!adev || !acpi_has_method(adev->handle, acpi_method))
+       handle = ACPI_HANDLE(dev);
+       if (!handle)
                return false;
 
-       status = acpi_evaluate_object(adev->handle, acpi_method, NULL, &buffer);
+       if (!acpi_has_method(handle, acpi_method))
+               return false;
+
+       status = acpi_evaluate_object(handle, acpi_method, NULL, &buffer);
        if (ACPI_FAILURE(status)) {
                dev_err(dev, "Failed to get ACPI mount matrix: %d\n", status);
                return false;