ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead
The only difference between acpi_bus_scan() and acpi_bus_add() is the
invocation of acpi_update_all_gpes() in the latter which in fact is
unnecessary, because acpi_update_all_gpes() has already been called
by acpi_scan_init() and the way it is implemented guarantees the next
invocations of it to do nothing.
For this reason, drop acpi_bus_add() and make all its callers use
acpi_bus_scan() directly instead of it. Additionally, rearrange the
code in acpi_scan_init() slightly to improve the visibility of the
acpi_update_all_gpes() call in there.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index eaddb7a..15ea22f 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -167,7 +167,7 @@
* Now add the notified device. This creates the acpi_device
* and invokes .add function
*/
- result = acpi_bus_add(handle);
+ result = acpi_bus_scan(handle);
if (result) {
acpi_handle_warn(handle, "Cannot add acpi bus\n");
return -EINVAL;
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index f8fb228..cc79d3e 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -166,7 +166,7 @@
if (!ACPI_FAILURE(status) || device)
break;
- result = acpi_bus_add(handle);
+ result = acpi_bus_scan(handle);
if (result) {
acpi_handle_warn(handle, "Failed to add container\n");
break;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 4a56a8b..420d24f 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -317,7 +317,7 @@
* no device created for this object,
* so we should create one.
*/
- ret = acpi_bus_add(handle);
+ ret = acpi_bus_scan(handle);
if (ret)
pr_debug("error adding bus, %x\n", -ret);
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index a24ee43..9c5929a 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -699,7 +699,7 @@
if (!acpi_bus_get_device(handle, &device))
break;
- result = acpi_bus_add(handle);
+ result = acpi_bus_scan(handle);
if (result) {
acpi_handle_err(handle, "Unable to add the device\n");
break;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 388b59c..7c43bdc 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1577,7 +1577,19 @@
return status;
}
-static int acpi_bus_scan(acpi_handle handle)
+/**
+ * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
+ * @handle: Root of the namespace scope to scan.
+ *
+ * Scan a given ACPI tree (probably recently hot-plugged) and create and add
+ * found devices.
+ *
+ * If no devices were found, -ENODEV is returned, but it does not mean that
+ * there has been a real error. There just have been no suitable ACPI objects
+ * in the table trunk from which the kernel could create a device and add an
+ * appropriate driver.
+ */
+int acpi_bus_scan(acpi_handle handle)
{
void *device = NULL;
@@ -1594,31 +1606,7 @@
return 0;
}
-
-/**
- * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
- * @handle: Root of the namespace scope to scan.
- *
- * Scan a given ACPI tree (probably recently hot-plugged) and create and add
- * found devices.
- *
- * If no devices were found, -ENODEV is returned, but it does not mean that
- * there has been a real error. There just have been no suitable ACPI objects
- * in the table trunk from which the kernel could create a device and add an
- * appropriate driver.
- */
-int acpi_bus_add(acpi_handle handle)
-{
- int err;
-
- err = acpi_bus_scan(handle);
- if (err)
- return err;
-
- acpi_update_all_gpes();
- return 0;
-}
-EXPORT_SYMBOL(acpi_bus_add);
+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)
@@ -1708,13 +1696,15 @@
return result;
result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
- if (!result)
- result = acpi_bus_scan_fixed();
-
if (result)
- acpi_device_unregister(acpi_root);
- else
- acpi_update_all_gpes();
+ return result;
- return result;
+ result = acpi_bus_scan_fixed();
+ if (result) {
+ acpi_device_unregister(acpi_root);
+ return result;
+ }
+
+ acpi_update_all_gpes();
+ return 0;
}
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 22006f2..9e2b1f6 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -746,7 +746,7 @@
dbg("acpi_bus_trim return %x\n", ret_val);
}
- ret_val = acpi_bus_add(func->handle);
+ ret_val = acpi_bus_scan(func->handle);
if (!ret_val)
ret_val = acpi_bus_get_device(func->handle, &device);
@@ -1129,7 +1129,7 @@
return;
}
- if (acpi_bus_add(handle)) {
+ if (acpi_bus_scan(handle)) {
err("cannot add bridge to acpi list\n");
return;
}
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 2e006ee..ae606b3 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -447,9 +447,9 @@
if (ACPI_SUCCESS(ret) &&
(adr>>16) == (slot->device_num + 1)) {
- ret = acpi_bus_add(chandle);
+ ret = acpi_bus_scan(chandle);
if (ACPI_FAILURE(ret)) {
- printk(KERN_ERR "%s: acpi_bus_add "
+ printk(KERN_ERR "%s: acpi_bus_scan "
"failed (0x%x) for slot %d "
"func %d\n", __func__,
ret, (int)(adr>>16),