ACPI: convert acpi_bus_scan() to operate on an acpi_handle

This patch changes acpi_bus_scan() to take an acpi_handle rather than an
acpi_device pointer.  I plan to use acpi_bus_scan() in the hotplug path,
and I'd rather not assume that notifications only go to nodes that already
have acpi_devices.

This will also help remove the special case for adding the root node.  We
currently add the root by hand before acpi_bus_scan(), but using a handle
here means we can start the acpi_bus_scan() directly with the root even
though it doesn't have an acpi_device yet.

Note that acpi_bus_scan() currently adds and/or starts the *children* of
its device argument.  It doesn't do anything with the device itself.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
Bjorn Helgaas 2009-09-21 19:29:40 +00:00 committed by Len Brown
parent 5c478f499c
commit 8e029bf0a6

View File

@ -1387,7 +1387,7 @@ end:
return result; return result;
} }
static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops)
{ {
acpi_status status = AE_OK; acpi_status status = AE_OK;
struct acpi_device *parent = NULL; struct acpi_device *parent = NULL;
@ -1396,13 +1396,16 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
acpi_handle chandle = NULL; acpi_handle chandle = NULL;
acpi_object_type type = 0; acpi_object_type type = 0;
u32 level = 1; u32 level = 1;
int ret;
/*
if (!start) * We must have an acpi_device for the starting node already, and
return -EINVAL; * we scan its children.
*/
parent = start; phandle = handle;
phandle = start->handle; ret = acpi_bus_get_device(phandle, &parent);
if (ret)
return ret;
/* /*
* Parse through the ACPI namespace, identify all 'devices', and * Parse through the ACPI namespace, identify all 'devices', and
@ -1516,7 +1519,7 @@ acpi_bus_add(struct acpi_device **child,
result = acpi_add_single_object(child, handle, type, &ops); result = acpi_add_single_object(child, handle, type, &ops);
if (!result) if (!result)
result = acpi_bus_scan(*child, &ops); result = acpi_bus_scan((*child)->handle, &ops);
return result; return result;
} }
@ -1527,16 +1530,13 @@ int acpi_bus_start(struct acpi_device *device)
int result; int result;
struct acpi_bus_ops ops; struct acpi_bus_ops ops;
memset(&ops, 0, sizeof(ops));
if (!device) ops.acpi_op_start = 1;
return -EINVAL;
result = acpi_start_single_object(device); result = acpi_start_single_object(device);
if (!result) { if (!result)
memset(&ops, 0, sizeof(ops)); result = acpi_bus_scan(device->handle, &ops);
ops.acpi_op_start = 1;
result = acpi_bus_scan(device, &ops);
}
return result; return result;
} }
EXPORT_SYMBOL(acpi_bus_start); EXPORT_SYMBOL(acpi_bus_start);
@ -1653,7 +1653,7 @@ int __init acpi_scan_init(void)
result = acpi_bus_scan_fixed(); result = acpi_bus_scan_fixed();
if (!result) if (!result)
result = acpi_bus_scan(acpi_root, &ops); result = acpi_bus_scan(acpi_root->handle, &ops);
if (result) if (result)
acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);