[svn-commits] sruffell: linux/trunk r5090 - /linux/trunk/drivers/dahdi/wcte12xp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Oct 14 17:11:46 CDT 2008


Author: sruffell
Date: Tue Oct 14 17:11:45 2008
New Revision: 5090

URL: http://svn.digium.com/view/dahdi?view=rev&rev=5090
Log:
If the vpmad032 firmware needs to be reloaded, make sure we use the same slot
in the ifaces array.

Modified:
    linux/trunk/drivers/dahdi/wcte12xp/base.c

Modified: linux/trunk/drivers/dahdi/wcte12xp/base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wcte12xp/base.c?view=diff&rev=5090&r1=5089&r2=5090
==============================================================================
--- linux/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcte12xp/base.c Tue Oct 14 17:11:45 2008
@@ -1582,11 +1582,16 @@
 	unsigned int x;
 	int res;
 	int startinglatency;
-
-	for (x = 0; x < sizeof(ifaces) / sizeof(ifaces[0]); x++)
-		if (!ifaces[x]) break;
-
-	if (x >= sizeof(ifaces) / sizeof(ifaces[0])) {
+	unsigned int index = -1;
+
+	for (x = 0; x < sizeof(ifaces) / sizeof(ifaces[0]); x++) {
+		if (!ifaces[x]) {
+			index = x;
+			break;
+		}
+	}
+
+	if (-1 == index) {
 		module_printk("Too many interfaces\n");
 		return -EIO;
 	}
@@ -1596,18 +1601,19 @@
 		return -ENOMEM;
 	}
 
-	ifaces[x] = wc;
+	ifaces[index] = wc;
 	memset(wc, 0, sizeof(*wc));
 	spin_lock_init(&wc->reglock);
 	wc->variety = d->name;
 	wc->txident = 1;
 
 	init_waitqueue_head(&wc->regq);
-	snprintf(wc->name, sizeof(wc->name)-1, "wcte12xp%d", x);
+	snprintf(wc->name, sizeof(wc->name)-1, "wcte12xp%d", index);
 	if ((res = voicebus_init(pdev, SFRAME_SIZE, wc->name,
 				 t1_handle_receive, t1_handle_transmit, wc, &wc->vb))) {
 		WARN_ON(1);
 		kfree(wc);
+		ifaces[index] = NULL;
 		return res;
 	}
 	
@@ -1627,6 +1633,7 @@
 			}
 
 			kfree(wc);
+			ifaces[index] = NULL;
 			return -ENOMEM;
 		}
 		memset(wc->chans[x], 0, sizeof(*wc->chans[x]));




More information about the svn-commits mailing list