[svn-commits] kpfleming: branch linux/kpfleming/modular_ec r4409 - /linux/team/kpfleming/mo...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 19 08:59:29 CDT 2008


Author: kpfleming
Date: Thu Jun 19 08:59:29 2008
New Revision: 4409

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4409
Log:
correct a reference to an uninitialized 'res' variable in the MTP2 code

use bit operations for all access to the OPEN bit for consistency

whitespace/indentation fixes


Modified:
    linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c

Modified: linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c?view=diff&rev=4409&r1=4408&r2=4409
==============================================================================
--- linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/kpfleming/modular_ec/drivers/dahdi/dahdi-base.c Thu Jun 19 08:59:29 2008
@@ -588,7 +588,7 @@
 							len += sprintf(page + len, "Master ");
 					}
 				}
-				if ((chans[x]->flags & DAHDI_FLAG_OPEN)) {
+				if (test_bit(DAHDI_FLAGBIT_OPEN, &chans[x]->flags)) {
 					len += sprintf(page + len, "(In use) ");
 				}
 #ifdef	OPTIMIZE_CHANMUTE
@@ -1357,7 +1357,7 @@
 		printk("dahdi_net_open: nothing??\n");
 		return -EINVAL;
 	}
-	if (ms->flags & DAHDI_FLAG_OPEN) {
+	if (test_bit(DAHDI_FLAGBIT_OPEN, &ms->flags)) {
 		printk("%s is already open!\n", ms->name);
 		return -EBUSY;
 	}
@@ -1589,7 +1589,7 @@
 
 	/* See if we have any buffers */
 	spin_lock_irqsave(&ss->lock, flags);
-	if (!(ss->flags & DAHDI_FLAG_OPEN)) {
+	if (!(test_bit(DAHDI_FLAGBIT_OPEN, &ss->flags))) {
 		printk("Can't transmit on closed channel\n");
 		retval = 1;
 	} else if (skb->len > ss->blocksize - 4) {
@@ -3598,6 +3598,7 @@
 	case DAHDI_CHANCONFIG:
 	{
 		struct dahdi_chanconfig ch;
+		struct dahdi_echocan *new_ec, *old_ec;
 
 		if (copy_from_user(&ch, (struct dahdi_chanconfig *)data, sizeof(ch)))
 			return -EFAULT;
@@ -3637,9 +3638,9 @@
 		}
 #else
 		if (ch.sigtype == DAHDI_SIG_HDLCNET) {
-				spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
-				printk(KERN_WARNING "DAHDI networking not supported by this build.\n");
-				return -ENOSYS;
+			spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+			printk(KERN_WARNING "DAHDI networking not supported by this build.\n");
+			return -ENOSYS;
 		}
 #endif			
 		sigcap = chans[ch.chan]->sigcap;
@@ -3649,15 +3650,17 @@
 			sigcap |= (DAHDI_SIG_HDLCRAW | DAHDI_SIG_HDLCFCS | DAHDI_SIG_HDLCNET | DAHDI_SIG_DACS);
 		
 		if ((sigcap & ch.sigtype) != ch.sigtype)
-			res =  -EINVAL;	
+			res = -EINVAL;	
 		
 		if (!res && chans[ch.chan]->span->chanconfig)
 			res = chans[ch.chan]->span->chanconfig(chans[ch.chan], ch.sigtype);
+
 		if (chans[ch.chan]->master) {
 			/* Clear the master channel */
 			recalc_slaves(chans[ch.chan]->master);
 			chans[ch.chan]->nextslave = 0;
 		}
+
 		if (!res) {
 			chans[ch.chan]->sig = ch.sigtype;
 			if (chans[ch.chan]->sig == DAHDI_SIG_CAS)
@@ -3693,12 +3696,13 @@
 				chans[ch.chan]->confna = ch.idlebits;
 				if (chans[ch.chan]->span && 
 				    chans[ch.chan]->span->dacs && 
-					chans[ch.idlebits] && 
-					chans[ch.chan]->span && 
-					(chans[ch.chan]->span->dacs == chans[ch.idlebits]->span->dacs)) 
+				    chans[ch.idlebits] && 
+				    chans[ch.chan]->span && 
+				    (chans[ch.chan]->span->dacs == chans[ch.idlebits]->span->dacs)) 
 					chans[ch.chan]->span->dacs(chans[ch.chan], chans[ch.idlebits]);
-			} else if (chans[ch.chan]->span && chans[ch.chan]->span->dacs)
+			} else if (chans[ch.chan]->span && chans[ch.chan]->span->dacs) {
 				chans[ch.chan]->span->dacs(chans[ch.chan], NULL);
+			}
 			chans[ch.chan]->master = newmaster;
 			/* Note new slave if we are not our own master */
 			if (newmaster != chans[ch.chan]) {
@@ -3708,8 +3712,9 @@
 				chans[ch.chan]->flags &= ~DAHDI_FLAG_FCS;
 				chans[ch.chan]->flags &= ~DAHDI_FLAG_HDLC;
 				chans[ch.chan]->flags |= DAHDI_FLAG_NOSTDTXRX;
-			} else
+			} else {
 				chans[ch.chan]->flags &= ~DAHDI_FLAG_NOSTDTXRX;
+			}
 
 			if ((ch.sigtype & DAHDI_SIG_MTP2) == DAHDI_SIG_MTP2)
 				chans[ch.chan]->flags |= DAHDI_FLAG_MTP2;
@@ -3718,12 +3723,13 @@
 		}
 #ifdef CONFIG_DAHDI_NET
 		if (!res && 
-			(newmaster == chans[ch.chan]) && 
-		        (chans[ch.chan]->sig == DAHDI_SIG_HDLCNET)) {
+		    (newmaster == chans[ch.chan]) && 
+		    (chans[ch.chan]->sig == DAHDI_SIG_HDLCNET)) {
 			chans[ch.chan]->hdlcnetdev = dahdi_hdlc_alloc();
 			if (chans[ch.chan]->hdlcnetdev) {
 /*				struct hdlc_device *hdlc = chans[ch.chan]->hdlcnetdev;
 				struct net_device *d = hdlc_to_dev(hdlc); mmm...get it right later --byg */
+
 				chans[ch.chan]->hdlcnetdev->netdev = alloc_hdlcdev(chans[ch.chan]->hdlcnetdev);
 				if (chans[ch.chan]->hdlcnetdev->netdev) {
 					chans[ch.chan]->hdlcnetdev->chan = chans[ch.chan];
@@ -3768,13 +3774,15 @@
 			/* And hangup */
 			dahdi_hangup(chans[ch.chan]);
 			y = dahdi_q_sig(chans[ch.chan]) & 0xff;
-			if (y >= 0) chans[ch.chan]->rxsig = (unsigned char)y;
+			if (y >= 0)
+				chans[ch.chan]->rxsig = (unsigned char) y;
 			chans[ch.chan]->rxhooksig = DAHDI_RXSIG_INITIAL;
 		}
 #ifdef CONFIG_DAHDI_DEBUG
 		printk("Configured channel %s, flags %04x, sig %04x\n", chans[ch.chan]->name, chans[ch.chan]->flags, chans[ch.chan]->sig);
 #endif			
 		spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+
 		return res;
 	}
 	case DAHDI_SFCONFIG:
@@ -6697,21 +6705,18 @@
 
 					if (ms->flags & DAHDI_FLAG_MTP2) {
 						comparemessage = (ms->inreadbuf - 1) & (ms->numbufs - 1);
-
-						res = memcmp(ms->readbuf[comparemessage], ms->readbuf[ms->inreadbuf], ms->readn[ms->inreadbuf]);
-					}
-
-					if ((ms->flags & DAHDI_FLAG_MTP2) && !res) {
-						/* Our messages are the same, so discard -
-						 * 	Don't advance buffers, reset indexes and buffer sizes. */
-						ms->readn[ms->inreadbuf] = 0;
-						ms->readidx[ms->inreadbuf] = 0;
+						if (!memcmp(ms->readbuf[comparemessage], ms->readbuf[ms->inreadbuf], ms->readn[ms->inreadbuf])) {
+							/* Our messages are the same, so discard -
+							 * 	Don't advance buffers, reset indexes and buffer sizes. */
+							ms->readn[ms->inreadbuf] = 0;
+							ms->readidx[ms->inreadbuf] = 0;
+						}
 					} else {
 						ms->inreadbuf = (ms->inreadbuf + 1) % ms->numbufs;
 						if (ms->inreadbuf == ms->outreadbuf) {
 							/* Whoops, we're full, and have no where else
-							to store into at the moment.  We'll drop it
-							until there's a buffer available */
+							   to store into at the moment.  We'll drop it
+							   until there's a buffer available */
 #ifdef CONFIG_DAHDI_DEBUG
 							printk("Out of storage space\n");
 #endif
@@ -6769,10 +6774,10 @@
 					tasklet_schedule(&ms->ppp_calls);
 				} else
 #endif
-
-				if ((ms->flags & DAHDI_FLAG_OPEN) && !ss->span->alarms) 
+					if (test_bit(DAHDI_FLAGBIT_OPEN, &ms->flags) && !ss->span->alarms) {
 						/* Notify the receiver... */
-					__qevent(ss->master, abort);
+						__qevent(ss->master, abort);
+					}
 #if 0
 				printk("torintr_receive: Aborted %d bytes of frame on %d\n", amt, ss->master);
 #endif
@@ -6830,7 +6835,7 @@
 {
 	if (ss->inreadbuf >= 0)
 		ss->readidx[ss->inreadbuf] = 0;
-	if ((ss->flags & DAHDI_FLAG_OPEN) && !ss->span->alarms)
+	if (test_bit(DAHDI_FLAGBIT_OPEN, &ss->flags) && !ss->span->alarms)
 		__qevent(ss->master, event);
 }
 




More information about the svn-commits mailing list