summaryrefslogtreecommitdiff
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-02-06 13:58:13 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-02-06 17:31:52 +0100
commit1a699476e25814343766342672c655fb135224cc (patch)
tree19f0ac198e24f7f8686250207ac8d042cb5a8a33 /drivers/acpi/scan.c
parent5e6f236c263117cef5f0d68e3fec241ba2adc4fc (diff)
ACPI / hotplug / PCI: Hotplug notifications from acpi_bus_notify()
Since acpi_bus_notify() is executed on all notifications for all devices anyway, make it execute acpi_device_hotplug() for all hotplug events instead of installing notify handlers pointing to the same function for all hotplug devices. This change reduces both the size and complexity of ACPI-based device hotplug code. Moreover, since acpi_device_hotplug() only does significant things for devices that have either an ACPI scan handler, or a hotplug context with .eject() defined, and those devices had notify handlers pointing to acpi_hotplug_notify_cb() installed before anyway, this modification shouldn't change functionality. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c81
1 files changed, 5 insertions, 76 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 59f9e272562e..8bb48bfab1df 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -470,7 +470,7 @@ static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
return -EINVAL;
}
-static void acpi_device_hotplug(void *data, u32 src)
+void acpi_device_hotplug(void *data, u32 src)
{
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
struct acpi_device *adev = data;
@@ -520,75 +520,6 @@ static void acpi_device_hotplug(void *data, u32 src)
unlock_device_hotplug();
}
-static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
-{
- u32 ost_code = ACPI_OST_SC_SUCCESS;
- struct acpi_device *adev;
- acpi_status status;
-
- switch (type) {
- case ACPI_NOTIFY_BUS_CHECK:
- acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n");
- break;
-
- case ACPI_NOTIFY_DEVICE_CHECK:
- acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n");
- break;
-
- case ACPI_NOTIFY_EJECT_REQUEST:
- acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
- break;
-
- case ACPI_NOTIFY_DEVICE_WAKE:
- return;
-
- case ACPI_NOTIFY_FREQUENCY_MISMATCH:
- acpi_handle_err(handle, "Device cannot be configured due "
- "to a frequency mismatch\n");
- goto out;
-
- case ACPI_NOTIFY_BUS_MODE_MISMATCH:
- acpi_handle_err(handle, "Device cannot be configured due "
- "to a bus mode mismatch\n");
- goto out;
-
- case ACPI_NOTIFY_POWER_FAULT:
- acpi_handle_err(handle, "Device has suffered a power fault\n");
- goto out;
-
- default:
- acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type);
- ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY;
- goto out;
- }
-
- ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
- adev = acpi_bus_get_acpi_device(handle);
- if (!adev)
- goto out;
-
- status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
- if (ACPI_SUCCESS(status))
- return;
-
- acpi_bus_put_acpi_device(adev);
-
- out:
- acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
-}
-
-void acpi_install_hotplug_notify_handler(acpi_handle handle)
-{
- acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
- acpi_hotplug_notify_cb, NULL);
-}
-
-void acpi_remove_hotplug_notify_handler(acpi_handle handle)
-{
- acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
- acpi_hotplug_notify_cb);
-}
-
static ssize_t real_power_state_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -2037,12 +1968,10 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev)
struct acpi_scan_handler *handler;
handler = acpi_scan_match_handler(hwid->id, NULL);
- if (!handler)
- continue;
-
- acpi_install_hotplug_notify_handler(adev->handle);
- adev->flags.hotplug_notify = true;
- break;
+ if (handler) {
+ adev->flags.hotplug_notify = true;
+ break;
+ }
}
}