ACPI / hotplug: Make ACPI PCI root hotplug use common hotplug code
Rework the common ACPI device hotplug code so that it is suitable
for PCI host bridge hotplug and switch the PCI host bridge scan
handler to using the common hotplug code.
This allows quite a few lines of code that are not necessary any more
to be dropped from the PCI host bridge scan handler and removes
arbitrary differences in behavior between PCI host bridge hotplug
and ACPI-based hotplug of other components, like CPUs and memory.
Also acpi_device_hotplug() can be static now.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index dd0ff9d..18865c8 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -283,17 +283,6 @@
{
int error;
- /*
- * This function is only called for device objects for which matching
- * scan handlers exist. The only situation in which the scan handler is
- * not attached to this device object yet is when the device has just
- * appeared (either it wasn't present at all before or it was removed
- * and then added again).
- */
- if (adev->handler) {
- dev_warn(&adev->dev, "Already enumerated\n");
- return -EBUSY;
- }
error = acpi_bus_scan(adev->handle);
if (error) {
dev_warn(&adev->dev, "Namespace scan failure\n");
@@ -309,10 +298,11 @@
return 0;
}
-void acpi_device_hotplug(void *data, u32 src)
+static void acpi_device_hotplug(void *data, u32 src)
{
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
struct acpi_device *adev = data;
+ struct acpi_scan_handler *handler;
int error;
lock_device_hotplug();
@@ -326,12 +316,32 @@
if (adev->handle == INVALID_ACPI_HANDLE)
goto out;
+ handler = adev->handler;
+
switch (src) {
case ACPI_NOTIFY_BUS_CHECK:
- error = acpi_bus_scan(adev->handle);
+ if (handler) {
+ error = handler->hotplug.scan_dependent ?
+ handler->hotplug.scan_dependent(adev) :
+ acpi_bus_scan(adev->handle);
+ } else {
+ error = acpi_scan_device_check(adev);
+ }
break;
case ACPI_NOTIFY_DEVICE_CHECK:
- error = acpi_scan_device_check(adev);
+ /*
+ * This code is only run for device objects for which matching
+ * scan handlers exist. The only situation in which the scan
+ * handler is not attached to this device object yet is when the
+ * device has just appeared (either it wasn't present at all
+ * before or it was removed and then added again).
+ */
+ if (adev->handler) {
+ dev_warn(&adev->dev, "Already enumerated\n");
+ error = -EBUSY;
+ } else {
+ error = acpi_scan_device_check(adev);
+ }
break;
case ACPI_NOTIFY_EJECT_REQUEST:
case ACPI_OST_EC_OSPM_EJECT:
@@ -1805,7 +1815,7 @@
*/
list_for_each_entry(hwid, &pnp.ids, list) {
handler = acpi_scan_match_handler(hwid->id, NULL);
- if (handler && !handler->hotplug.ignore) {
+ if (handler) {
acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
acpi_hotplug_notify_cb, handler);
break;
@@ -2083,8 +2093,6 @@
acpi_update_all_gpes();
- acpi_pci_root_hp_init();
-
out:
mutex_unlock(&acpi_scan_lock);
return result;