[dahdi-commits] sruffell: branch linux/sruffell/dahdi-linux-parallelload r7364 - /linux/team/...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Fri Oct 9 10:31:45 CDT 2009


Author: sruffell
Date: Fri Oct  9 10:31:33 2009
New Revision: 7364

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7364
Log:
wip: Look at using the async infrastructure for parallel init

Modified:
    linux/team/sruffell/dahdi-linux-parallelload/drivers/dahdi/wctdm24xxp/base.c

Modified: linux/team/sruffell/dahdi-linux-parallelload/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-parallelload/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=7364&r1=7363&r2=7364
==============================================================================
--- linux/team/sruffell/dahdi-linux-parallelload/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/team/sruffell/dahdi-linux-parallelload/drivers/dahdi/wctdm24xxp/base.c Fri Oct  9 10:31:33 2009
@@ -49,6 +49,13 @@
 #include <linux/semaphore.h>
 #else
 #include <asm/semaphore.h>
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
+#define USE_ASYNC_INIT
+#include <linux/async.h>
+#else
+#undef USE_ASYNC_INIT
 #endif
 
 #include <dahdi/kernel.h>
@@ -3722,7 +3729,15 @@
 	kfree(wc);
 }
 
-static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+#ifdef USE_ASYNC_INIT
+struct async_data {
+	struct pci_dev *pdev;
+	const struct pci_device_id *ent;
+};
+static int __devinit __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent, async_cookie_t cookie)
+#else
+static int __devinit __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+#endif
 {
 	struct wctdm *wc;
 	int i;
@@ -3821,6 +3836,10 @@
 	/* Final initialization */
 	wctdm_post_initialize(wc);
 	
+#ifdef USE_ASYNC_INIT
+	async_synchronize_cookie(cookie);
+#endif
+
 	/* We should be ready for DAHDI to come in now. */
 	if (dahdi_register(&wc->span, 0)) {
 		printk(KERN_NOTICE "Unable to register span with DAHDI\n");
@@ -3834,6 +3853,38 @@
 	
 	return 0;
 }
+
+#ifdef USE_ASYNC_INIT
+static __devinit void wctdm_init_one_async(void *data, async_cookie_t cookie)
+{
+	struct async_data *dat = data;
+	__wctdm_init_one(dat->pdev, dat->ent, cookie);
+	kfree(dat);
+}
+
+static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	struct async_data *dat;
+
+	dat = kmalloc(sizeof(*dat), GFP_KERNEL);
+	/* If we can't allocate the memory for the async_data, odds are we won't
+	 * be able to initialize the device either, but let's try synchronously
+	 * anyway... */
+	if (!dat) 
+		return __wctdm_init_one(pdev, ent, 0);
+
+	dat->pdev = pdev;
+	dat->ent = ent;
+	async_schedule(wctdm_init_one_async, dat);
+	return 0;
+}
+#else
+static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+	return __wctdm_init_one(pdev, ent);
+}
+#endif
+
 
 static void wctdm_release(struct wctdm *wc)
 {




More information about the dahdi-commits mailing list