提交 e3c963c4 编写于 作者: R Rafael J. Wysocki

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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: NHans de Goede <hdegoede@redhat.com>
上级 e38f9ff6
...@@ -135,12 +135,12 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) ...@@ -135,12 +135,12 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
void **ret_p) void **ret_p)
{ {
struct acpi_device *device = NULL; struct acpi_device *device = acpi_fetch_acpi_dev(handle);
struct acpi_device_physical_node *pn; struct acpi_device_physical_node *pn;
bool second_pass = (bool)data; bool second_pass = (bool)data;
acpi_status status = AE_OK; acpi_status status = AE_OK;
if (acpi_bus_get_device(handle, &device)) if (!device)
return AE_OK; return AE_OK;
if (device->handler && !device->handler->hotplug.enabled) { if (device->handler && !device->handler->hotplug.enabled) {
...@@ -180,10 +180,10 @@ static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, ...@@ -180,10 +180,10 @@ static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data, static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data,
void **ret_p) void **ret_p)
{ {
struct acpi_device *device = NULL; struct acpi_device *device = acpi_fetch_acpi_dev(handle);
struct acpi_device_physical_node *pn; struct acpi_device_physical_node *pn;
if (acpi_bus_get_device(handle, &device)) if (!device)
return AE_OK; return AE_OK;
mutex_lock(&device->physical_node_lock); mutex_lock(&device->physical_node_lock);
...@@ -599,6 +599,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) ...@@ -599,6 +599,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
} }
EXPORT_SYMBOL(acpi_bus_get_device); EXPORT_SYMBOL(acpi_bus_get_device);
/**
* acpi_fetch_acpi_dev - Retrieve ACPI device object.
* @handle: ACPI handle associated with the requested ACPI device object.
*
* Return a pointer to the ACPI device object associated with @handle, if
* present, or NULL otherwise.
*/
struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle)
{
return handle_to_device(handle, NULL);
}
EXPORT_SYMBOL_GPL(acpi_fetch_acpi_dev);
static void get_acpi_device(void *dev) static void get_acpi_device(void *dev)
{ {
acpi_dev_get(dev); acpi_dev_get(dev);
...@@ -799,7 +812,7 @@ static const char * const acpi_ignore_dep_ids[] = { ...@@ -799,7 +812,7 @@ static const char * const acpi_ignore_dep_ids[] = {
static struct acpi_device *acpi_bus_get_parent(acpi_handle handle) static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
{ {
struct acpi_device *device = NULL; struct acpi_device *device;
acpi_status status; acpi_status status;
/* /*
...@@ -814,7 +827,9 @@ static struct acpi_device *acpi_bus_get_parent(acpi_handle handle) ...@@ -814,7 +827,9 @@ static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
status = acpi_get_parent(handle, &handle); status = acpi_get_parent(handle, &handle);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return status == AE_NULL_ENTRY ? NULL : acpi_root; return status == AE_NULL_ENTRY ? NULL : acpi_root;
} while (acpi_bus_get_device(handle, &device));
device = acpi_fetch_acpi_dev(handle);
} while (!device);
return device; return device;
} }
...@@ -2003,11 +2018,10 @@ static bool acpi_bus_scan_second_pass; ...@@ -2003,11 +2018,10 @@ static bool acpi_bus_scan_second_pass;
static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep, static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
struct acpi_device **adev_p) struct acpi_device **adev_p)
{ {
struct acpi_device *device = NULL; struct acpi_device *device = acpi_fetch_acpi_dev(handle);
acpi_object_type acpi_type; acpi_object_type acpi_type;
int type; int type;
acpi_bus_get_device(handle, &device);
if (device) if (device)
goto out; goto out;
...@@ -2548,8 +2562,8 @@ int __init acpi_scan_init(void) ...@@ -2548,8 +2562,8 @@ int __init acpi_scan_init(void)
if (result) if (result)
goto out; goto out;
result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); acpi_root = acpi_fetch_acpi_dev(ACPI_ROOT_OBJECT);
if (result) if (!acpi_root)
goto out; goto out;
/* Fixed feature devices do not exist on HW-reduced platform */ /* Fixed feature devices do not exist on HW-reduced platform */
......
...@@ -505,6 +505,7 @@ extern int unregister_acpi_notifier(struct notifier_block *); ...@@ -505,6 +505,7 @@ extern int unregister_acpi_notifier(struct notifier_block *);
*/ */
int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle);
acpi_status acpi_bus_get_status_handle(acpi_handle handle, acpi_status acpi_bus_get_status_handle(acpi_handle handle,
unsigned long long *sta); unsigned long long *sta);
int acpi_bus_get_status(struct acpi_device *device); int acpi_bus_get_status(struct acpi_device *device);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册