[dahdi-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9291 - /linux/team/sru...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Sep 2 12:41:38 CDT 2010


Author: sruffell
Date: Thu Sep  2 12:41:27 2010
New Revision: 9291

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9291
Log:
dahdi: Change iteration through pseudo/real chans in process_masterspan.

Since we have the pseudo channels on their own list, we don't need to
step through the chans array when we just want to find the pseudo
channels. Likewise, all the real channels will have be on a span.  Also
removes references to the global chans array in process_masterspan.

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

Modified: linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c?view=diff&rev=9291&r1=9290&r2=9291
==============================================================================
--- linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c Thu Sep  2 12:41:27 2010
@@ -8536,6 +8536,9 @@
 	unsigned long flags;
 	int x, y, z;
 	struct dahdi_chan *chan;
+	struct pseudo_chan *pseudo;
+	struct dahdi_span *s;
+	u_char *data;
 
 #ifdef CONFIG_DAHDI_CORE_TIMER
 	/* We increment the calls since start here, so that if we switch over
@@ -8555,10 +8558,14 @@
 	if (dahdi_dynamic_ioctl)
 		dahdi_dynamic_ioctl(0, 0);
 
-	for (x = 1; x < maxchans; x++) {
-		chan = chans[x];
-		if (chan && chan->confmode && !is_pseudo_chan(chan)) {
-			u_char *data;
+	for (y = 1; y < maxspans; ++y) {
+		s = spans[y];
+		if (!s)
+			continue;
+		for (x = 0; x < s->channels; x++) {
+			chan = s->chans[x];
+			if (!chan->confmode)
+				continue;
 			spin_lock(&chan->lock);
 			data = __buf_peek(&chan->confin);
 			__dahdi_receive_chunk(chan, data);
@@ -8569,17 +8576,17 @@
 			spin_unlock(&chan->lock);
 		}
 	}
+
 	/* This is the master channel, so make things switch over */
 	rotate_sums();
+
 	/* do all the pseudo and/or conferenced channel receives (getbuf's) */
-	for (x = 1; x < maxchans; x++) {
-		chan = chans[x];
-		if (chan && is_pseudo_chan(chan)) {
-			spin_lock(&chan->lock);
-			__dahdi_transmit_chunk(chan, NULL);
-			spin_unlock(&chan->lock);
-		}
-	}
+	list_for_each_entry(pseudo, &pseudo_chans, node) {
+		spin_lock(&pseudo->chan.lock);
+		__dahdi_transmit_chunk(&pseudo->chan, NULL);
+		spin_unlock(&pseudo->chan.lock);
+	}
+
 	if (maxlinks) {
 #ifdef CONFIG_DAHDI_MMX
 		dahdi_kernel_fpu_begin();
@@ -8598,37 +8605,38 @@
 		dahdi_kernel_fpu_end();
 #endif
 	}
+
 	/* do all the pseudo/conferenced channel transmits (putbuf's) */
-	for (x = 1; x < maxchans; x++) {
-		chan = chans[x];
-		if (chan && is_pseudo_chan(chan)) {
-			unsigned char tmp[DAHDI_CHUNKSIZE];
-			spin_lock(&chan->lock);
-			__dahdi_getempty(chan, tmp);
-			__dahdi_receive_chunk(chan, tmp);
-			spin_unlock(&chan->lock);
-		}
-	}
-	for (x = 1; x < maxchans; x++) {
-		chan = chans[x];
-		if (chan && chan->confmode && !is_pseudo_chan(chan)) {
-			u_char *data;
+	list_for_each_entry(pseudo, &pseudo_chans, node) {
+		unsigned char tmp[DAHDI_CHUNKSIZE];
+		spin_lock(&pseudo->chan.lock);
+		__dahdi_getempty(&pseudo->chan, tmp);
+		__dahdi_receive_chunk(&pseudo->chan, tmp);
+		spin_unlock(&pseudo->chan.lock);
+	}
+
+	for (y = 1; y < maxspans; ++y) {
+		s = spans[y];
+		if (!s)
+			continue;
+		for (x = 0; x < s->channels; x++) {
+			chan = s->chans[x];
+			if (!chan->confmode) 
+				continue;
 			spin_lock(&chan->lock);
 			data = __buf_pushpeek(&chan->confout);
 			__dahdi_transmit_chunk(chan, data);
-			if (data)
+			if (data) {
 				__buf_push(&chan->confout, NULL,
 					   "conftransmit");
+			}
 			spin_unlock(&chan->lock);
 		}
-	}
 #ifdef	DAHDI_SYNC_TICK
-	for (x = 0; x < maxspans; x++) {
-		struct dahdi_span *const s = spans[x];
-		if (s && s->ops->sync_tick)
+		if (s->ops->sync_tick)
 			s->ops->sync_tick(s, s == master);
-	}
-#endif
+#endif
+	}
 	read_unlock(&chan_lock);
 	spin_unlock_irqrestore(&bigzaplock, flags);
 }




More information about the dahdi-commits mailing list