Skip to contentSkip to conversation

ACPI: introduce new acpi execute type for device hotplug

PATCH In review Zhang Rui 1 participant 1 message Jan 17, 2008

Subsystems (2)
lore
Share & tools
lore

Zhang Rui

author
#0 lore raw

PATCH 2/4 ACPI: introduce new acpi execute type for device hotplug

From: Zhang Rui <[email protected]>

Introduce new acpi_execute_type OSL_DEVICE_HOTPLUG_HANDLER for device hotplug. so that we can move the device hotplug notify handler to keventd_wq and flush kacpi_notify_wq before removing the per-device notify handler.

---
 drivers/acpi/osl.c      |   20 ++++++++++++++++++--
 include/acpi/acpiosxf.h |    3 ++-
 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/acpi/osl.c +18 -2
Index: linux-2.6/drivers/acpi/osl.c
===================================================================
@@ -684,13 +684,27 @@ acpi_status acpi_os_execute(acpi_execute
 	dpc->function = function;
 	dpc->context = context;
 
-	if (type == OSL_NOTIFY_HANDLER) {
+	switch (type) {
+	case OSL_NOTIFY_HANDLER:
 		INIT_WORK(&dpc->work, acpi_os_execute_notify);
 		if (!queue_work(kacpi_notify_wq, &dpc->work)) {
 			status = AE_ERROR;
 			kfree(dpc);
 		}
-	} else {
+		break;
+	case OSL_DEVICE_HOTPLUG_HANDLER:
+		/*
+		 * execute device hotplug in keventd_wq so that it
+		 * can flush kacpi_notify_wq and kacpid_wq before
+		 * removing the notify handler.
+		 */
+		INIT_WORK(&dpc->work, acpi_os_execute_notify);
+		if (!schedule_work(&dpc->work)) {
+			status = AE_ERROR;
+			kfree(dpc);
+		}
+		break;
+	default:
 		INIT_WORK(&dpc->work, acpi_os_execute_deferred);
 		if (!queue_work(kacpid_wq, &dpc->work)) {
 			ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -698,7 +712,9 @@ acpi_status acpi_os_execute(acpi_execute
 			status = AE_ERROR;
 			kfree(dpc);
 		}
+		break;
 	}
+
 	return_ACPI_STATUS(status);
 }
 
include/acpi/acpiosxf.h +2 -1
Index: linux-2.6/include/acpi/acpiosxf.h
===================================================================
@@ -58,7 +58,8 @@ typedef enum {
 	OSL_GPE_HANDLER,
 	OSL_DEBUGGER_THREAD,
 	OSL_EC_POLL_HANDLER,
-	OSL_EC_BURST_HANDLER
+	OSL_EC_BURST_HANDLER,
+	OSL_DEVICE_HOTPLUG_HANDLER
 } acpi_execute_type;
 
 #define ACPI_NO_UNIT_LIMIT          ((u32) -1)