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

ACPI: scan: Introduce acpi_fetch_acpi_dev()

Introduce acpi_fetch_acpi_dev() as a more reasonable replacement for
acpi_bus_get_device() and modify the code in scan.c to use it instead
of the latter.

No expected functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>

+25 -10
+24 -10
drivers/acpi/scan.c
··· 135 135 static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, 136 136 void **ret_p) 137 137 { 138 - struct acpi_device *device = NULL; 138 + struct acpi_device *device = acpi_fetch_acpi_dev(handle); 139 139 struct acpi_device_physical_node *pn; 140 140 bool second_pass = (bool)data; 141 141 acpi_status status = AE_OK; 142 142 143 - if (acpi_bus_get_device(handle, &device)) 143 + if (!device) 144 144 return AE_OK; 145 145 146 146 if (device->handler && !device->handler->hotplug.enabled) { ··· 180 180 static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data, 181 181 void **ret_p) 182 182 { 183 - struct acpi_device *device = NULL; 183 + struct acpi_device *device = acpi_fetch_acpi_dev(handle); 184 184 struct acpi_device_physical_node *pn; 185 185 186 - if (acpi_bus_get_device(handle, &device)) 186 + if (!device) 187 187 return AE_OK; 188 188 189 189 mutex_lock(&device->physical_node_lock); ··· 599 599 } 600 600 EXPORT_SYMBOL(acpi_bus_get_device); 601 601 602 + /** 603 + * acpi_fetch_acpi_dev - Retrieve ACPI device object. 604 + * @handle: ACPI handle associated with the requested ACPI device object. 605 + * 606 + * Return a pointer to the ACPI device object associated with @handle, if 607 + * present, or NULL otherwise. 608 + */ 609 + struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle) 610 + { 611 + return handle_to_device(handle, NULL); 612 + } 613 + EXPORT_SYMBOL_GPL(acpi_fetch_acpi_dev); 614 + 602 615 static void get_acpi_device(void *dev) 603 616 { 604 617 acpi_dev_get(dev); ··· 812 799 813 800 static struct acpi_device *acpi_bus_get_parent(acpi_handle handle) 814 801 { 815 - struct acpi_device *device = NULL; 802 + struct acpi_device *device; 816 803 acpi_status status; 817 804 818 805 /* ··· 827 814 status = acpi_get_parent(handle, &handle); 828 815 if (ACPI_FAILURE(status)) 829 816 return status == AE_NULL_ENTRY ? NULL : acpi_root; 830 - } while (acpi_bus_get_device(handle, &device)); 817 + 818 + device = acpi_fetch_acpi_dev(handle); 819 + } while (!device); 831 820 return device; 832 821 } 833 822 ··· 2018 2003 static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, 2019 2004 struct acpi_device **adev_p) 2020 2005 { 2021 - struct acpi_device *device = NULL; 2006 + struct acpi_device *device = acpi_fetch_acpi_dev(handle); 2022 2007 acpi_object_type acpi_type; 2023 2008 int type; 2024 2009 2025 - acpi_bus_get_device(handle, &device); 2026 2010 if (device) 2027 2011 goto out; 2028 2012 ··· 2562 2548 if (result) 2563 2549 goto out; 2564 2550 2565 - result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); 2566 - if (result) 2551 + acpi_root = acpi_fetch_acpi_dev(ACPI_ROOT_OBJECT); 2552 + if (!acpi_root) 2567 2553 goto out; 2568 2554 2569 2555 /* Fixed feature devices do not exist on HW-reduced platform */
+1
include/acpi/acpi_bus.h
··· 505 505 */ 506 506 507 507 int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 508 + struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle); 508 509 acpi_status acpi_bus_get_status_handle(acpi_handle handle, 509 510 unsigned long long *sta); 510 511 int acpi_bus_get_status(struct acpi_device *device);