[svn-commits] russell: linux/trunk r4690 - /linux/trunk/drivers/dahdi/dahdi-base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Aug 3 18:04:24 CDT 2008


Author: russell
Date: Sun Aug  3 18:04:23 2008
New Revision: 4690

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4690
Log:
Re-work a for loop in proc_read.  This loop traversed the array of all DAHDI
channels and determined whether they belonged to the span being printed or
not.  This has been simplified by simply traversing the array of channels on
the span structure, itself.

Thanks to tzafrir for the idea in #asterisk-dev.

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

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=4690&r1=4689&r2=4690
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Sun Aug  3 18:04:23 2008
@@ -604,39 +604,42 @@
 		len += sprintf(page + len, "\tTiming slips: %d\n", spans[span]->timingslips);
 	len += sprintf(page + len, "\n");
 
-	for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
-		if (!chans[x])
-			continue;
-
-		if (chans[x]->span && (chans[x]->span->spanno == span)) {
-			if (chans[x]->name)
-				len += sprintf(page + len, "\t%4d %s ", x, chans[x]->name);
-			if (chans[x]->sig) {
-				if (chans[x]->sig == DAHDI_SIG_SLAVE)
-					len += sprintf(page + len, "%s ", sigstr(chans[x]->master->sig));
-				else {
-					len += sprintf(page + len, "%s ", sigstr(chans[x]->sig));
-					if (chans[x]->nextslave && chans[x]->master->channo == x)
-						len += sprintf(page + len, "Master ");
-				}
-			}
-			if (test_bit(DAHDI_FLAGBIT_OPEN, &chans[x]->flags))
-				len += sprintf(page + len, "(In use) ");
+	for (x = 0; x < spans[span]->channels; x++) {
+		struct dahdi_chan *chan = spans[span]->chans[x];
+
+		if (chan->name)
+			len += sprintf(page + len, "\t%4d %s ", x, chan->name);
+
+		if (chan->sig) {
+			if (chan->sig == DAHDI_SIG_SLAVE)
+				len += sprintf(page + len, "%s ", sigstr(chan->master->sig));
+			else {
+				len += sprintf(page + len, "%s ", sigstr(chan->sig));
+				if (chan->nextslave && chan->master->channo == x)
+					len += sprintf(page + len, "Master ");
+			}
+		}
+
+		if (test_bit(DAHDI_FLAGBIT_OPEN, &chan->flags))
+			len += sprintf(page + len, "(In use) ");
+
 #ifdef	OPTIMIZE_CHANMUTE
-			if (chans[x]->chanmute)
-				len += sprintf(page + len, "(no pcm) ");
-#endif
-			len += fill_alarm_string(page + len, count - len, chans[x]->chan_alarms);
-
-			if (chans[x]->ec_factory)
-				len += sprintf(page + len, " (EC: %s) ", chans[x]->ec_factory->name);
-
-			len += sprintf(page + len, "\n");
-		}
+		if (chan->chanmute)
+			len += sprintf(page + len, "(no pcm) ");
+#endif
+
+		len += fill_alarm_string(page + len, count - len, chan->chan_alarms);
+
+		if (chan->ec_factory)
+			len += sprintf(page + len, " (EC: %s) ", chan->ec_factory->name);
+
+		len += sprintf(page + len, "\n");
+
 		if (len <= off) { /* If everything printed so far is before beginning of request */
 			off -= len;
 			len = 0;
 		}
+
 		if (len > off + count) /* stop if we've already generated enough */
 			break;
 	}




More information about the svn-commits mailing list