diff mbox

[2/3] PCI Hotplug: convert acpiphp_hp_work to use delayed work

Message ID 1355412708-20046-3-git-send-email-kirill.shutemov@linux.intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Kirill A . Shutemov Dec. 13, 2012, 3:31 p.m. UTC
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>

Some broken ACPI PCI Hotplug implementations notify OS about hotplug
before devices ready to be enumerated.

Let's convert acpiphp_hp_work to delayed work. It will allow to delay
enumeration on broken hardware to workaround the issue.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3d6d4fd..1a2b3ca 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1191,7 +1191,7 @@  check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
 }
 
 struct acpiphp_hp_work {
-	struct work_struct work;
+	struct delayed_work work;
 	acpi_handle handle;
 	u32 type;
 	void *context;
@@ -1199,7 +1199,8 @@  struct acpiphp_hp_work {
 
 static void alloc_acpiphp_hp_work(acpi_handle handle, u32 type,
 				  void *context,
-				  void (*func)(struct work_struct *work))
+				  void (*func)(struct work_struct *work),
+				  unsigned long delay)
 {
 	struct acpiphp_hp_work *hp_work;
 	int ret;
@@ -1212,8 +1213,8 @@  static void alloc_acpiphp_hp_work(acpi_handle handle, u32 type,
 	hp_work->type = type;
 	hp_work->context = context;
 
-	INIT_WORK(&hp_work->work, func);
-	ret = queue_work(kacpi_hotplug_wq, &hp_work->work);
+	INIT_DELAYED_WORK(&hp_work->work, func);
+	ret = queue_delayed_work(kacpi_hotplug_wq, &hp_work->work, delay);
 	if (!ret)
 		kfree(hp_work);
 }
@@ -1230,7 +1231,8 @@  static void _handle_hotplug_event_bridge(struct work_struct *work)
 	acpi_handle handle;
 	u32 type;
 
-	hp_work = container_of(work, struct acpiphp_hp_work, work);
+	hp_work = container_of(to_delayed_work(work),
+			struct acpiphp_hp_work, work);
 	handle = hp_work->handle;
 	type = hp_work->type;
 
@@ -1334,7 +1336,7 @@  static void handle_hotplug_event_bridge(acpi_handle handle, u32 type,
 	 * don't deadlock on hotplug actions.
 	 */
 	alloc_acpiphp_hp_work(handle, type, context,
-			      _handle_hotplug_event_bridge);
+			      _handle_hotplug_event_bridge, 0);
 }
 
 static void _handle_hotplug_event_func(struct work_struct *work)
@@ -1348,7 +1350,8 @@  static void _handle_hotplug_event_func(struct work_struct *work)
 	u32 type;
 	void *context;
 
-	hp_work = container_of(work, struct acpiphp_hp_work, work);
+	hp_work = container_of(to_delayed_work(work),
+			struct acpiphp_hp_work, work);
 	handle = hp_work->handle;
 	type = hp_work->type;
 	context = hp_work->context;
@@ -1410,7 +1413,7 @@  static void handle_hotplug_event_func(acpi_handle handle, u32 type,
 	 * don't deadlock on hotplug actions.
 	 */
 	alloc_acpiphp_hp_work(handle, type, context,
-			      _handle_hotplug_event_func);
+			      _handle_hotplug_event_func, 0);
 }
 
 static acpi_status