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

iio: acpi: Improve iio_read_acpi_mount_matrix()

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>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
d411e5b5 77005bc2

+7 -3
+7 -3
drivers/iio/industrialio-acpi.c
··· 28 28 char *acpi_method) 29 29 { 30 30 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 31 - struct acpi_device *adev = ACPI_COMPANION(dev); 32 31 char *str; 33 32 union acpi_object *obj, *elements; 33 + acpi_handle handle; 34 34 acpi_status status; 35 35 int i, j, val[3]; 36 36 bool ret = false; 37 37 38 - if (!adev || !acpi_has_method(adev->handle, acpi_method)) 38 + handle = ACPI_HANDLE(dev); 39 + if (!handle) 39 40 return false; 40 41 41 - status = acpi_evaluate_object(adev->handle, acpi_method, NULL, &buffer); 42 + if (!acpi_has_method(handle, acpi_method)) 43 + return false; 44 + 45 + status = acpi_evaluate_object(handle, acpi_method, NULL, &buffer); 42 46 if (ACPI_FAILURE(status)) { 43 47 dev_err(dev, "Failed to get ACPI mount matrix: %d\n", status); 44 48 return false;