|
@@ -1909,54 +1909,40 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
|
|
|
|
|
- void *not_used, void **ret_not_used)
|
|
|
|
|
|
|
+static void acpi_bus_attach(struct acpi_device *device)
|
|
|
{
|
|
{
|
|
|
- struct acpi_device *device;
|
|
|
|
|
- unsigned long long sta;
|
|
|
|
|
|
|
+ struct acpi_device *child;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
|
|
|
|
|
- * namespace walks prematurely.
|
|
|
|
|
- */
|
|
|
|
|
- if (acpi_bus_type_and_status(handle, &ret, &sta))
|
|
|
|
|
- return AE_OK;
|
|
|
|
|
-
|
|
|
|
|
- if (acpi_bus_get_device(handle, &device))
|
|
|
|
|
- return AE_CTRL_DEPTH;
|
|
|
|
|
-
|
|
|
|
|
- acpi_set_device_status(device, sta);
|
|
|
|
|
|
|
+ acpi_bus_get_status(device);
|
|
|
/* Skip devices that are not present. */
|
|
/* Skip devices that are not present. */
|
|
|
- if (!acpi_device_is_present(device))
|
|
|
|
|
- goto err;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (!acpi_device_is_present(device)) {
|
|
|
|
|
+ device->flags.visited = false;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (device->handler)
|
|
if (device->handler)
|
|
|
- return AE_OK;
|
|
|
|
|
|
|
+ goto ok;
|
|
|
|
|
|
|
|
if (!device->flags.initialized) {
|
|
if (!device->flags.initialized) {
|
|
|
acpi_bus_update_power(device, NULL);
|
|
acpi_bus_update_power(device, NULL);
|
|
|
device->flags.initialized = true;
|
|
device->flags.initialized = true;
|
|
|
}
|
|
}
|
|
|
|
|
+ device->flags.visited = false;
|
|
|
ret = acpi_scan_attach_handler(device);
|
|
ret = acpi_scan_attach_handler(device);
|
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
|
- goto err;
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
device->flags.match_driver = true;
|
|
device->flags.match_driver = true;
|
|
|
- if (ret > 0)
|
|
|
|
|
- goto ok;
|
|
|
|
|
-
|
|
|
|
|
- ret = device_attach(&device->dev);
|
|
|
|
|
- if (ret < 0)
|
|
|
|
|
- goto err;
|
|
|
|
|
-
|
|
|
|
|
- ok:
|
|
|
|
|
|
|
+ if (!ret) {
|
|
|
|
|
+ ret = device_attach(&device->dev);
|
|
|
|
|
+ if (ret < 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
device->flags.visited = true;
|
|
device->flags.visited = true;
|
|
|
- return AE_OK;
|
|
|
|
|
|
|
|
|
|
- err:
|
|
|
|
|
- device->flags.visited = false;
|
|
|
|
|
- return AE_CTRL_DEPTH;
|
|
|
|
|
|
|
+ ok:
|
|
|
|
|
+ list_for_each_entry(child, &device->children, node)
|
|
|
|
|
+ acpi_bus_attach(child);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1976,64 +1962,48 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
|
|
|
int acpi_bus_scan(acpi_handle handle)
|
|
int acpi_bus_scan(acpi_handle handle)
|
|
|
{
|
|
{
|
|
|
void *device = NULL;
|
|
void *device = NULL;
|
|
|
- int error = 0;
|
|
|
|
|
|
|
|
|
|
if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
|
|
if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
|
|
|
acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
|
|
acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
|
|
|
acpi_bus_check_add, NULL, NULL, &device);
|
|
acpi_bus_check_add, NULL, NULL, &device);
|
|
|
|
|
|
|
|
- if (!device)
|
|
|
|
|
- error = -ENODEV;
|
|
|
|
|
- else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
|
|
|
|
|
- acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
|
|
|
|
|
- acpi_bus_device_attach, NULL, NULL, NULL);
|
|
|
|
|
-
|
|
|
|
|
- return error;
|
|
|
|
|
-}
|
|
|
|
|
-EXPORT_SYMBOL(acpi_bus_scan);
|
|
|
|
|
-
|
|
|
|
|
-static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
|
|
|
|
|
- void *not_used, void **ret_not_used)
|
|
|
|
|
-{
|
|
|
|
|
- struct acpi_device *device = NULL;
|
|
|
|
|
-
|
|
|
|
|
- if (!acpi_bus_get_device(handle, &device)) {
|
|
|
|
|
- struct acpi_scan_handler *dev_handler = device->handler;
|
|
|
|
|
-
|
|
|
|
|
- if (dev_handler) {
|
|
|
|
|
- if (dev_handler->detach)
|
|
|
|
|
- dev_handler->detach(device);
|
|
|
|
|
-
|
|
|
|
|
- device->handler = NULL;
|
|
|
|
|
- } else {
|
|
|
|
|
- device_release_driver(&device->dev);
|
|
|
|
|
- }
|
|
|
|
|
- /*
|
|
|
|
|
- * Most likely, the device is going away, so put it into D3cold
|
|
|
|
|
- * before that.
|
|
|
|
|
- */
|
|
|
|
|
- acpi_device_set_power(device, ACPI_STATE_D3_COLD);
|
|
|
|
|
- device->flags.initialized = false;
|
|
|
|
|
- device->flags.visited = false;
|
|
|
|
|
|
|
+ if (device) {
|
|
|
|
|
+ acpi_bus_attach(device);
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
- return AE_OK;
|
|
|
|
|
|
|
+ return -ENODEV;
|
|
|
}
|
|
}
|
|
|
|
|
+EXPORT_SYMBOL(acpi_bus_scan);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * acpi_bus_trim - Remove ACPI device node and all of its descendants
|
|
|
|
|
- * @start: Root of the ACPI device nodes subtree to remove.
|
|
|
|
|
|
|
+ * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
|
|
|
|
|
+ * @adev: Root of the ACPI namespace scope to walk.
|
|
|
*
|
|
*
|
|
|
* Must be called under acpi_scan_lock.
|
|
* Must be called under acpi_scan_lock.
|
|
|
*/
|
|
*/
|
|
|
-void acpi_bus_trim(struct acpi_device *start)
|
|
|
|
|
|
|
+void acpi_bus_trim(struct acpi_device *adev)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct acpi_scan_handler *handler = adev->handler;
|
|
|
|
|
+ struct acpi_device *child;
|
|
|
|
|
+
|
|
|
|
|
+ list_for_each_entry_reverse(child, &adev->children, node)
|
|
|
|
|
+ acpi_bus_trim(child);
|
|
|
|
|
+
|
|
|
|
|
+ if (handler) {
|
|
|
|
|
+ if (handler->detach)
|
|
|
|
|
+ handler->detach(adev);
|
|
|
|
|
+
|
|
|
|
|
+ adev->handler = NULL;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ device_release_driver(&adev->dev);
|
|
|
|
|
+ }
|
|
|
/*
|
|
/*
|
|
|
- * Execute acpi_bus_device_detach() as a post-order callback to detach
|
|
|
|
|
- * all ACPI drivers from the device nodes being removed.
|
|
|
|
|
|
|
+ * Most likely, the device is going away, so put it into D3cold before
|
|
|
|
|
+ * that.
|
|
|
*/
|
|
*/
|
|
|
- acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
|
|
|
|
|
- acpi_bus_device_detach, NULL, NULL);
|
|
|
|
|
- acpi_bus_device_detach(start->handle, 0, NULL, NULL);
|
|
|
|
|
|
|
+ acpi_device_set_power(adev, ACPI_STATE_D3_COLD);
|
|
|
|
|
+ adev->flags.initialized = false;
|
|
|
|
|
+ adev->flags.visited = false;
|
|
|
}
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(acpi_bus_trim);
|
|
EXPORT_SYMBOL_GPL(acpi_bus_trim);
|
|
|
|
|
|