[svn-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9289 - in /linux/team/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Sep 2 12:41:36 CDT 2010


Author: sruffell
Date: Thu Sep  2 12:41:24 2010
New Revision: 9289

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9289
Log:
dahdi: Define psuedo channels as being without a span.

Therefore we can use the fact that the span pointer on the channel is
NULL to identify them.

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

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=9289&r1=9288&r2=9289
==============================================================================
--- 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:24 2010
@@ -409,6 +409,14 @@
 static rwlock_t zone_lock = RW_LOCK_UNLOCKED;
 static rwlock_t chan_lock = RW_LOCK_UNLOCKED;
 #endif
+
+/**
+ * is_pseudo_chan() - By definition psuedo channels are not on a span.
+ */
+static inline bool is_pseudo_chan(const struct dahdi_chan *chan)
+{
+	return (NULL == chan->span);
+}
 
 static bool valid_channo(const int channo)
 {
@@ -2264,7 +2272,7 @@
 
 	for (;;) {
 		spin_lock_irqsave(&chan->lock, flags);
-		if ((chan->curtone || chan->pdialcount) && !(chan->flags & DAHDI_FLAG_PSEUDO)) {
+		if ((chan->curtone || chan->pdialcount) && !is_pseudo_chan(chan)) {
 			chan->curtone = NULL;
 			chan->tonep = 0;
 			chan->dialing = 0;
@@ -2825,7 +2833,7 @@
 				return res;
 			}
 			spin_lock_irqsave(&chan->lock, flags);
-			if (chan->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(chan))
 				chan->flags |= DAHDI_FLAG_AUDIO;
 			if (chan->span) {
 				if (!try_module_get(chan->span->ops->owner))
@@ -2900,7 +2908,8 @@
 
 	pseudo->sig = DAHDI_SIG_CLEAR;
 	pseudo->sigcap = DAHDI_SIG_CLEAR;
-	pseudo->flags = DAHDI_FLAG_PSEUDO | DAHDI_FLAG_AUDIO;
+	pseudo->flags = DAHDI_FLAG_AUDIO;
+	pseudo->span = NULL; /* No span == psuedo channel */
 
 	if (dahdi_chan_reg(pseudo)) {
 		kfree(pseudo);
@@ -6490,7 +6499,7 @@
 	}
 #endif
 
-	if ((!ms->confmute && !ms->dialing) || (ms->flags & DAHDI_FLAG_PSEUDO)) {
+	if ((!ms->confmute && !ms->dialing) || (is_pseudo_chan(ms))) {
 		/* Handle conferencing on non-clear channel and non-HDLC channels */
 		struct dahdi_chan *const conf_chan = chans[ms->confna];
 		switch(ms->confmode & DAHDI_CONF_MODE_MASK) {
@@ -6499,9 +6508,10 @@
 			break;
 		case DAHDI_CONF_MONITOR:	/* Monitor a channel's rx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & DAHDI_FLAG_PSEUDO) break;
+			if (is_pseudo_chan(ms))
+				break;
 			/* Add monitored channel */
-			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(conf_chan))
 				ACSS(getlin, conf_chan->getlin);
 			else
 				ACSS(getlin, conf_chan->putlin);
@@ -6511,9 +6521,10 @@
 			break;
 		case DAHDI_CONF_MONITORTX: /* Monitor a channel's tx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & DAHDI_FLAG_PSEUDO) break;
+			if (is_pseudo_chan(ms))
+				break;
 			/* Add monitored channel */
-			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(conf_chan))
 				ACSS(getlin, conf_chan->putlin);
 			else
 				ACSS(getlin, conf_chan->getlin);
@@ -6523,7 +6534,8 @@
 			break;
 		case DAHDI_CONF_MONITORBOTH: /* monitor a channel's rx and tx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & DAHDI_FLAG_PSEUDO) break;
+			if (is_pseudo_chan(ms))
+				break;
 			ACSS(getlin, conf_chan->putlin);
 			ACSS(getlin, conf_chan->getlin);
 			for (x=0;x<DAHDI_CHUNKSIZE;x++)
@@ -6531,14 +6543,14 @@
 			break;
 		case DAHDI_CONF_MONITOR_RX_PREECHO:	/* Monitor a channel's rx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(ms))
 				break;
 
 			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(getlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			ACSS(getlin, is_pseudo_chan(conf_chan) ?
 			     conf_chan->readchunkpreec : conf_chan->putlin);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
@@ -6546,14 +6558,14 @@
 			break;
 		case DAHDI_CONF_MONITOR_TX_PREECHO: /* Monitor a channel's tx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(ms))
 				break;
 
 			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(getlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			ACSS(getlin, is_pseudo_chan(conf_chan) ?
 			     conf_chan->putlin : conf_chan->readchunkpreec);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				txb[x] = DAHDI_LIN2X(getlin[x], ms);
@@ -6561,7 +6573,7 @@
 			break;
 		case DAHDI_CONF_MONITORBOTH_PREECHO: /* monitor a channel's rx and tx mode */
 			  /* if a pseudo-channel, ignore */
-			if (ms->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(ms))
 				break;
 
 			if (!conf_chan->readchunkpreec)
@@ -6601,7 +6613,7 @@
 			memset(txb + 1, txb[0], DAHDI_CHUNKSIZE - 1);
 			/* fall through to normal conf mode */
 		case DAHDI_CONF_CONF:	/* Normal conference mode */
-			if (ms->flags & DAHDI_FLAG_PSEUDO) /* if pseudo-channel */
+			if (is_pseudo_chan(ms)) /* if pseudo-channel */
 			   {
 				  /* if to talk on conf */
 				if (ms->confmode & DAHDI_CONF_TALKER) {
@@ -6654,7 +6666,7 @@
 			/* Real digital monitoring, but still echo cancel if desired */
 			if (!conf_chan)
 				break;
-			if (conf_chan->flags & DAHDI_FLAG_PSEUDO) {
+			if (is_pseudo_chan(conf_chan)) {
 				if (ms->ec_state) {
 					for (x=0;x<DAHDI_CHUNKSIZE;x++)
 						txb[x] = DAHDI_LIN2X(conf_chan->getlin[x], ms);
@@ -6812,7 +6824,7 @@
 				}
 #endif
 			}
-		} else if (ms->curtone && !(ms->flags & DAHDI_FLAG_PSEUDO)) {
+		} else if (ms->curtone && !is_pseudo_chan(ms)) {
 			left = ms->curtone->tonesamples - ms->tonep;
 			if (left > bytes)
 				left = bytes;
@@ -7503,7 +7515,7 @@
 
 	if (ms->dialing) ms->afterdialingtimer = 50;
 	else if (ms->afterdialingtimer) ms->afterdialingtimer--;
-	if (ms->afterdialingtimer && (!(ms->flags & DAHDI_FLAG_PSEUDO))) {
+	if (ms->afterdialingtimer && !is_pseudo_chan(ms)) {
 		/* Be careful since memset is likely a macro */
 		rxb[0] = DAHDI_LIN2X(0, ms);
 		memset(&rxb[1], rxb[0], DAHDI_CHUNKSIZE - 1);  /* receive as silence if dialing */
@@ -7551,15 +7563,14 @@
 		}
 	}
 
-	if (!(ms->flags &  DAHDI_FLAG_PSEUDO)) {
+	if (!is_pseudo_chan(ms)) {
 		memcpy(ms->putlin, putlin, DAHDI_CHUNKSIZE * sizeof(short));
 		memcpy(ms->putraw, rxb, DAHDI_CHUNKSIZE);
 	}
 
 	/* Take the rxc, twiddle it for conferencing if appropriate and put it
 	   back */
-	if ((!ms->confmute && !ms->afterdialingtimer) ||
-	    (ms->flags & DAHDI_FLAG_PSEUDO)) {
+	if ((!ms->confmute && !ms->afterdialingtimer) || is_pseudo_chan(ms)) {
 		struct dahdi_chan *const conf_chan = chans[ms->confna];
 		switch(ms->confmode & DAHDI_CONF_MODE_MASK) {
 		case DAHDI_CONF_NORMAL:		/* Normal mode */
@@ -7567,9 +7578,10 @@
 			break;
 		case DAHDI_CONF_MONITOR:		/* Monitor a channel's rx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
+			if (!is_pseudo_chan(ms))
+				break;
 			/* Add monitored channel */
-			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(conf_chan))
 				ACSS(putlin, conf_chan->getlin);
 			else
 				ACSS(putlin, conf_chan->putlin);
@@ -7579,9 +7591,10 @@
 			break;
 		case DAHDI_CONF_MONITORTX:	/* Monitor a channel's tx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
+			if (!is_pseudo_chan(ms))
+				break;
 			/* Add monitored channel */
-			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(conf_chan))
 				ACSS(putlin, conf_chan->putlin);
 			else
 				ACSS(putlin, conf_chan->getlin);
@@ -7591,7 +7604,8 @@
 			break;
 		case DAHDI_CONF_MONITORBOTH:	/* Monitor a channel's tx and rx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
+			if (!is_pseudo_chan(ms))
+				break;
 			/* Note: Technically, saturation should be done at
 			   the end of the whole addition, but for performance
 			   reasons, we don't do that.  Besides, it only matters
@@ -7604,14 +7618,14 @@
 			break;
 		case DAHDI_CONF_MONITOR_RX_PREECHO:		/* Monitor a channel's rx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO))
+			if (!is_pseudo_chan(ms))
 				break;
 
 			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(putlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			ACSS(putlin, is_pseudo_chan(conf_chan) ?
 			     conf_chan->getlin : conf_chan->readchunkpreec);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
@@ -7619,14 +7633,14 @@
 			break;
 		case DAHDI_CONF_MONITOR_TX_PREECHO:	/* Monitor a channel's tx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO))
+			if (!is_pseudo_chan(ms))
 				break;
 
 			if (!conf_chan->readchunkpreec)
 				break;
 
 			/* Add monitored channel */
-			ACSS(putlin, conf_chan->flags & DAHDI_FLAG_PSEUDO ?
+			ACSS(putlin, is_pseudo_chan(conf_chan) ?
 			     conf_chan->readchunkpreec : conf_chan->getlin);
 			for (x = 0; x < DAHDI_CHUNKSIZE; x++)
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
@@ -7634,7 +7648,7 @@
 			break;
 		case DAHDI_CONF_MONITORBOTH_PREECHO:	/* Monitor a channel's tx and rx mode */
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO))
+			if (!is_pseudo_chan(ms))
 				break;
 
 			if (!conf_chan->readchunkpreec)
@@ -7676,7 +7690,7 @@
 				rxb[x] = DAHDI_LIN2X(putlin[x], ms);
 			break;
 		case DAHDI_CONF_CONF:	/* Normal conference mode */
-			if (ms->flags & DAHDI_FLAG_PSEUDO) /* if a pseudo-channel */
+			if (is_pseudo_chan(ms)) /* if a pseudo-channel */
 			   {
 				if (ms->confmode & DAHDI_CONF_LISTENER) {
 					/* Subtract out last sample written to conf */
@@ -7727,9 +7741,10 @@
 			break;
 		case DAHDI_CONF_DIGITALMON:
 			  /* if not a pseudo-channel, ignore */
-			if (!(ms->flags & DAHDI_FLAG_PSEUDO)) break;
+			if (!is_pseudo_chan(ms))
+				break;
 			/* Add monitored channel */
-			if (conf_chan->flags & DAHDI_FLAG_PSEUDO)
+			if (is_pseudo_chan(conf_chan))
 				memcpy(rxb, conf_chan->getraw, DAHDI_CHUNKSIZE);
 			else
 				memcpy(rxb, conf_chan->putraw, DAHDI_CHUNKSIZE);
@@ -8511,8 +8526,7 @@
 
 	for (x = 1; x < maxchans; x++) {
 		chan = chans[x];
-		if (chan && chan->confmode &&
-		    !(chan->flags & DAHDI_FLAG_PSEUDO)) {
+		if (chan && chan->confmode && !is_pseudo_chan(chan)) {
 			u_char *data;
 			spin_lock(&chan->lock);
 			data = __buf_peek(&chan->confin);
@@ -8529,7 +8543,7 @@
 	/* do all the pseudo and/or conferenced channel receives (getbuf's) */
 	for (x = 1; x < maxchans; x++) {
 		chan = chans[x];
-		if (chan && (chan->flags & DAHDI_FLAG_PSEUDO)) {
+		if (chan && is_pseudo_chan(chan)) {
 			spin_lock(&chan->lock);
 			__dahdi_transmit_chunk(chan, NULL);
 			spin_unlock(&chan->lock);
@@ -8556,7 +8570,7 @@
 	/* do all the pseudo/conferenced channel transmits (putbuf's) */
 	for (x = 1; x < maxchans; x++) {
 		chan = chans[x];
-		if (chan && (chan->flags & DAHDI_FLAG_PSEUDO)) {
+		if (chan && is_pseudo_chan(chan)) {
 			unsigned char tmp[DAHDI_CHUNKSIZE];
 			spin_lock(&chan->lock);
 			__dahdi_getempty(chan, tmp);
@@ -8566,8 +8580,7 @@
 	}
 	for (x = 1; x < maxchans; x++) {
 		chan = chans[x];
-		if (chan && chan->confmode &&
-		    !(chan->flags & DAHDI_FLAG_PSEUDO)) {
+		if (chan && chan->confmode && !is_pseudo_chan(chan)) {
 			u_char *data;
 			spin_lock(&chan->lock);
 			data = __buf_pushpeek(&chan->confout);

Modified: linux/team/sruffell/chan_list_refactoring/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/chan_list_refactoring/include/dahdi/kernel.h?view=diff&rev=9289&r1=9288&r2=9289
==============================================================================
--- linux/team/sruffell/chan_list_refactoring/include/dahdi/kernel.h (original)
+++ linux/team/sruffell/chan_list_refactoring/include/dahdi/kernel.h Thu Sep  2 12:41:24 2010
@@ -685,7 +685,6 @@
 	DAHDI_FLAGBIT_ECHOCANCEL= 4,	/*!< Channel supports native echo cancellation */
 	DAHDI_FLAGBIT_HDLC	= 5,	/*!< Perform HDLC */
 	DAHDI_FLAGBIT_NETDEV	= 6,	/*!< Send to network */
-	DAHDI_FLAGBIT_PSEUDO	= 7,	/*!< Pseudo channel */
 	DAHDI_FLAGBIT_CLEAR	= 8,	/*!< Clear channel */
 	DAHDI_FLAGBIT_AUDIO	= 9,	/*!< Audio mode channel */
 	DAHDI_FLAGBIT_OPEN	= 10,	/*!< Channel is open */
@@ -734,7 +733,6 @@
 
 #define DAHDI_FLAG_HDLC		DAHDI_FLAG(HDLC)
 #define DAHDI_FLAG_NETDEV	DAHDI_FLAG(NETDEV)
-#define DAHDI_FLAG_PSEUDO	DAHDI_FLAG(PSEUDO)
 #define DAHDI_FLAG_CLEAR	DAHDI_FLAG(CLEAR)
 #define DAHDI_FLAG_AUDIO	DAHDI_FLAG(AUDIO)
 




More information about the svn-commits mailing list