[svn-commits] sruffell: linux/trunk r6125 - /linux/trunk/drivers/dahdi/wct4xxp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 11 09:51:09 CDT 2009


Author: sruffell
Date: Wed Mar 11 09:51:04 2009
New Revision: 6125

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6125
Log:
Relax ident wheel requirements.

Do not require the first card to be set to 0 and allow skips in the ident wheel
numbers.  The ident wheel allows a user to determine the order that cards
register there spans with DAHDI.

(closes issue #13078)
Reported by: opticron
Patch by: opticron

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

Modified: linux/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=6125&r1=6124&r2=6125
==============================================================================
--- linux/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wct4xxp/base.c Wed Mar 11 09:51:04 2009
@@ -163,7 +163,6 @@
 static int pedanticpci = 1;
 static int debug=0;
 static int timingcable = 0;
-static int highestorder;
 static int t1e1override = -1; //0xFF; // -1 = jumper; 0xFF = E1
 static int j1mode = 0;
 static int sigmode = FRMR_MODE_NO_ADDR_CMP;
@@ -3659,23 +3658,22 @@
 	}
 	
 	init_spans(wc);
-	
-	/* Launch cards as appropriate */
-	for (;;) {
-		/* Find a card to activate */
-		f = 0;
-		for (x = 0; cards[x]; x++) {
-			if (cards[x]->order <= highestorder) {
-				t4_launch(cards[x]);
-				if (cards[x]->order == highestorder)
-					f = 1;
-			}
-		}
-		/* If we found at least one, increment the highest order and search again, otherwise stop */
-		if (f) 
-			highestorder++;
-		else
+	/* get the current number of probed cards and run a slice of a tail
+	 * insertion sort */
+	for (x = 0; x < MAX_T4_CARDS; x++) {
+		if (!cards[x+1])
 			break;
+	}
+	for ( ; x > 0; x--) {
+		if (cards[x]->order < cards[x-1]->order) {
+			struct t4 *tmp = cards[x];
+			cards[x] = cards[x-1];
+			cards[x-1] = tmp;
+		} else {
+			/* if we're not moving it, we won't move any more
+			 * since all cards are sorted on addition */
+			break;
+		}
 	}
 	
 	printk(KERN_INFO "Found a Wildcard: %s\n", wc->variety);
@@ -3807,6 +3805,22 @@
 	res = dahdi_pci_module(&t4_driver);
 	if (res)
 		return -ENODEV;
+	/* initialize cards since we have all of them */
+	/* warn for missing zero and duplicate numbers */
+	if (cards[0] && cards[0]->order != 0) {
+		printk(KERN_NOTICE "wct4xxp: Ident of first card is not zero (%d)\n",
+			cards[0]->order);
+	}
+	for (res = 0; cards[res]; res++) {
+		/* warn the user of duplicate ident values it is probably
+		 * unintended */
+		if (debug && res < 15 && cards[res+1] &&
+		    cards[res]->order == cards[res+1]->order) {
+			printk(KERN_NOTICE "wct4xxp: Duplicate ident value found (%d)\n",
+				cards[res]->order);
+		}
+		t4_launch(cards[res]);
+	}
 	return 0;
 }
 




More information about the svn-commits mailing list