Skip to content

Commit e3c963c

Browse files
committed
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>
1 parent e38f9ff commit e3c963c

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

drivers/acpi/scan.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
135135
static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
136136
void **ret_p)
137137
{
138-
struct acpi_device *device = NULL;
138+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
139139
struct acpi_device_physical_node *pn;
140140
bool second_pass = (bool)data;
141141
acpi_status status = AE_OK;
142142

143-
if (acpi_bus_get_device(handle, &device))
143+
if (!device)
144144
return AE_OK;
145145

146146
if (device->handler && !device->handler->hotplug.enabled) {
@@ -180,10 +180,10 @@ static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
180180
static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data,
181181
void **ret_p)
182182
{
183-
struct acpi_device *device = NULL;
183+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
184184
struct acpi_device_physical_node *pn;
185185

186-
if (acpi_bus_get_device(handle, &device))
186+
if (!device)
187187
return AE_OK;
188188

189189
mutex_lock(&device->physical_node_lock);
@@ -599,6 +599,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
599599
}
600600
EXPORT_SYMBOL(acpi_bus_get_device);
601601

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+
602615
static void get_acpi_device(void *dev)
603616
{
604617
acpi_dev_get(dev);
@@ -799,7 +812,7 @@ static const char * const acpi_ignore_dep_ids[] = {
799812

800813
static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
801814
{
802-
struct acpi_device *device = NULL;
815+
struct acpi_device *device;
803816
acpi_status status;
804817

805818
/*
@@ -814,7 +827,9 @@ static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
814827
status = acpi_get_parent(handle, &handle);
815828
if (ACPI_FAILURE(status))
816829
return status == AE_NULL_ENTRY ? NULL : acpi_root;
817-
} while (acpi_bus_get_device(handle, &device));
830+
831+
device = acpi_fetch_acpi_dev(handle);
832+
} while (!device);
818833
return device;
819834
}
820835

@@ -2003,11 +2018,10 @@ static bool acpi_bus_scan_second_pass;
20032018
static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
20042019
struct acpi_device **adev_p)
20052020
{
2006-
struct acpi_device *device = NULL;
2021+
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
20072022
acpi_object_type acpi_type;
20082023
int type;
20092024

2010-
acpi_bus_get_device(handle, &device);
20112025
if (device)
20122026
goto out;
20132027

@@ -2548,8 +2562,8 @@ int __init acpi_scan_init(void)
25482562
if (result)
25492563
goto out;
25502564

2551-
result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
2552-
if (result)
2565+
acpi_root = acpi_fetch_acpi_dev(ACPI_ROOT_OBJECT);
2566+
if (!acpi_root)
25532567
goto out;
25542568

25552569
/* Fixed feature devices do not exist on HW-reduced platform */

include/acpi/acpi_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ extern int unregister_acpi_notifier(struct notifier_block *);
505505
*/
506506

507507
int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
508+
struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle);
508509
acpi_status acpi_bus_get_status_handle(acpi_handle handle,
509510
unsigned long long *sta);
510511
int acpi_bus_get_status(struct acpi_device *device);

0 commit comments

Comments
 (0)