From edf5bf34d40804fbef32f240a79b74ffc69a658b Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 21 Feb 2014 01:10:18 +0100 Subject: ACPI / dock: Use callback pointers from devices' ACPI hotplug contexts Instead of requiring a set of special dock operations to be registered via register_hotplug_dock_device() for each ACPI dock device, it is much more straightforward to use callback pointers from the devices' hotplug contexts if available. For this reason, modify dock_hotplug_event() to use callback pointers from the hotplug contexts of ACPI devices and fall back to using the special dock operarions only if those callbacks are missing. Also make the ACPI-based PCI hotplug (ACPIPHP) subsystem set the .fixup callback pointer in the hotplug contexts of devices handled by it to a new function, acpiphp_post_dock_fixup(), so that the dock station driver can use the callbacks from those contexts instead of special dock operations registered via register_hotplug_dock_device(). Along with the above changes drop the ACPIPHP's dock operations that are not necessary any more. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/dock.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'drivers/acpi/dock.c') diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 8c3967cb4830..78c4ee7a422e 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -185,9 +185,38 @@ static void dock_release_hotplug(struct dock_dependent_device *dd) static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event, enum dock_callback_type cb_type) { + struct acpi_device *adev = dd->adev; acpi_notify_handler cb = NULL; bool run = false; + acpi_lock_hp_context(); + + if (!adev->hp) + goto no_context; + + if (cb_type == DOCK_CALL_FIXUP) { + void (*fixup)(struct acpi_device *); + + fixup = adev->hp->fixup; + if (fixup) { + acpi_unlock_hp_context(); + fixup(adev); + return; + } + } else { + int (*notify)(struct acpi_device *, u32); + + notify = adev->hp->event; + if (notify) { + acpi_unlock_hp_context(); + notify(adev, event); + return; + } + } + + no_context: + acpi_unlock_hp_context(); + mutex_lock(&hotplug_lock); if (dd->hp_context) { -- cgit v1.2.3