[zaptel-commits] mattf: trunk r2394 - /trunk/wct4xxp/base.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Wed Apr 4 15:07:04 MST 2007


Author: mattf
Date: Wed Apr  4 17:07:03 2007
New Revision: 2394

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2394
Log:
Make sure we use the fast kernel bitops that are guarunteed atomic.

Modified:
    trunk/wct4xxp/base.c

Modified: trunk/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/trunk/wct4xxp/base.c?view=diff&rev=2394&r1=2393&r2=2394
==============================================================================
--- trunk/wct4xxp/base.c (original)
+++ trunk/wct4xxp/base.c Wed Apr  4 17:07:03 2007
@@ -269,9 +269,9 @@
 	int frames_in;
 
 #ifdef VPM_SUPPORT
-	unsigned int dtmfactive;
-	unsigned int dtmfmask;
-	unsigned int dtmfmutemask;
+	unsigned long dtmfactive;
+	unsigned long dtmfmask;
+	unsigned long dtmfmutemask;
 	short dtmfenergy[31];
 	short dtmfdigit[31];
 #endif
@@ -728,11 +728,11 @@
 		if (debug)
 			printk("Got tone %s of '%c' on channel %d of span %d\n",
 				(start ? "START" : "STOP"), tone, channel, span + 1);
-		if ((wc->tspans[span]->dtmfmask & (1 << channel)) && (tone != 'u')) {
+		if (test_bit(channel, &wc->tspans[span]->dtmfmask) && (tone != 'u')) {
 			if (start) {
 				/* The octasic is supposed to mute us, but...  Yah, you
 				   guessed it.  */
-				if (wc->tspans[span]->dtmfmutemask & (1 << channel)) {
+				if (test_bit(channel, &wc->tspans[span]->dtmfmutemask)) {
 					unsigned long flags;
 					struct zt_chan *chan = &wc->tspans[span]->span.chans[channel];
 					int y;
@@ -743,10 +743,10 @@
 					}
 					spin_unlock_irqrestore(&chan->lock, flags);
 				}
-				wc->tspans[span]->dtmfactive |= (1 << channel);
+				set_bit(channel, &wc->tspans[span]->dtmfactive);
 				zt_qevent_lock(&wc->tspans[span]->span.chans[channel], (ZT_EVENT_DTMFDOWN | tone));
 			} else {
-				wc->tspans[span]->dtmfactive &= ~(1 << channel);
+				clear_bit(channel, &wc->tspans[span]->dtmfactive);
 				zt_qevent_lock(&wc->tspans[span]->span.chans[channel], (ZT_EVENT_DTMFUP | tone));
 			}
 		}
@@ -793,15 +793,15 @@
 					energy = ZT_XLAW(energy, ts->chans);
 					ts->dtmfenergy[base] = energy;
 				}
-				ts->dtmfactive |= (1 << base);
+				set_bit(base, &ts->dtmfactive);
 				if (ts->dtmfdigit[base]) {
 					if (ts->dtmfmask & (1 << base))
 						zt_qevent_lock(&ts->span.chans[base], (ZT_EVENT_DTMFUP | ts->dtmfdigit[base]));
 				}
 				ts->dtmfdigit[base] = digit;
-				if (ts->dtmfmask & (1 << base))
+				if (test_bit(base, &ts->dtmfmask))
 					zt_qevent_lock(&ts->span.chans[base], (ZT_EVENT_DTMFDOWN | digit));
-				if (ts->dtmfmutemask & (1 << base)) {
+				if (test_bit(base, &ts->dtmfmutemask)) {
 					/* Mute active receive buffer*/
 					unsigned long flags;
 					struct zt_chan *chan = &ts->span.chans[base];
@@ -837,9 +837,9 @@
 
 				if (!wc->t1e1)
 					base -= 4;
-				ts->dtmfactive &= ~(1 << base);
+				clear_bit(base, &ts->dtmfactive);
 				if (ts->dtmfdigit[base]) {
-					if (ts->dtmfmask & (1 << base))
+					if (test_bit(base, &ts->dtmfmask))
 						zt_qevent_lock(&ts->span.chans[base], (ZT_EVENT_DTMFUP | ts->dtmfdigit[base]));
 				}
 				digit = ts->dtmfdigit[base];
@@ -1152,13 +1152,13 @@
 		if (j && (vpmdtmfsupport == 0))
 			return -ENOSYS;
 		if (j & ZT_TONEDETECT_ON)
-			ts->dtmfmask |= (1 << (chan->chanpos - 1));
+			set_bit(chan->chanpos - 1, &ts->dtmfmask);
 		else
-			ts->dtmfmask &= ~(1 << (chan->chanpos - 1));
+			clear_bit(chan->chanpos - 1, &ts->dtmfmask);
 		if (j & ZT_TONEDETECT_MUTE)
-			ts->dtmfmutemask |= (1 << (chan->chanpos - 1));
+			set_bit(chan->chanpos - 1, &ts->dtmfmutemask);
 		else
-			ts->dtmfmutemask &= ~(1 << (chan->chanpos - 1));
+			clear_bit(chan->chanpos - 1, &ts->dtmfmutemask);
 		if (wc->vpm450m) {
 			channel = (chan->chanpos) << 2;
 			if (!wc->t1e1)
@@ -2165,12 +2165,12 @@
 {
 #ifdef VPM_SUPPORT
 	int y;
-	unsigned int merged;
+	unsigned long merged;
 	merged = ts->dtmfactive & ts->dtmfmutemask;
 	if (merged) {
 		for (y=0;y<ts->span.channels;y++) {
 			/* Mute any DTMFs which are supposed to be muted */
-			if (merged & (1 << y))  {
+			if (test_bit(y, &merged)) {
 				memset(ts->span.chans[y].readchunk, ZT_XLAW(0, (ts->span.chans + y)), ZT_CHUNKSIZE);
 			}
 		}



More information about the zaptel-commits mailing list