[svn-commits] sruffell: linux/trunk r9385 - in /linux/trunk: drivers/dahdi/ include/dahdi/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Sep 20 15:34:44 CDT 2010


Author: sruffell
Date: Mon Sep 20 15:34:40 2010
New Revision: 9385

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9385
Log:
dahdi: Remove redundant 'gainalloc' member from struct dahdi_chan.

I want to add some new members to dahdi_chan, but I don't want to
increase the overall size any more than necessary.

Review: https://reviewboard.asterisk.org/r/905/

Signed-off-by: Shaun Ruffell <sruffell at digium.com>

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c
    linux/trunk/include/dahdi/kernel.h

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9385&r1=9384&r2=9385
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Sep 20 15:34:40 2010
@@ -1312,6 +1312,15 @@
 		module_put(ec->owner);
 }
 
+/**
+ * is_gain_allocated() - True if gain tables were dynamically allocated.
+ * @chan:  The channel to check.
+ */
+static inline bool is_gain_allocated(const struct dahdi_chan *chan)
+{
+	return (chan->rxgain && (chan->rxgain != defgain));
+}
+
 /* 
  * close_channel - close the channel, resetting any channel variables
  * @chan: the dahdi_chan to close
@@ -1323,7 +1332,7 @@
 static void close_channel(struct dahdi_chan *chan)
 {
 	unsigned long flags;
-	void *rxgain = NULL;
+	const void *rxgain = NULL;
 	struct dahdi_echocan_state *ec_state;
 	const struct dahdi_echocan_factory *ec_current;
 	int oldconf;
@@ -1384,12 +1393,11 @@
 	chan->gotgs = 0;
 	reset_conf(chan);
 
-	if (chan->gainalloc && chan->rxgain)
+	if (is_gain_allocated(chan))
 		rxgain = chan->rxgain;
 
 	chan->rxgain = defgain;
 	chan->txgain = defgain;
-	chan->gainalloc = 0;
 	chan->eventinidx = chan->eventoutidx = 0;
 	chan->flags &= ~(DAHDI_FLAG_LOOPED | DAHDI_FLAG_LINEAR | DAHDI_FLAG_PPP | DAHDI_FLAG_SIGFREEZE);
 
@@ -1646,6 +1654,9 @@
 		chan->readchunk = chan->sreadchunk;
 	if (!chan->writechunk)
 		chan->writechunk = chan->swritechunk;
+	chan->rxgain = NULL;
+	chan->txgain = NULL;
+	dahdi_set_law(chan, 0);
 	dahdi_set_law(chan, DAHDI_LAW_DEFAULT);
 	close_channel(chan);
 
@@ -2624,7 +2635,7 @@
 {
 	int res;
 	unsigned long flags;
-	void *rxgain=NULL;
+	const void *rxgain = NULL;
 	struct dahdi_echocan_state *ec_state;
 	const struct dahdi_echocan_factory *ec_current;
 
@@ -2705,11 +2716,10 @@
 	chan->curtone = NULL;
 	chan->tonep = 0;
 	chan->pdialcount = 0;
-	if (chan->gainalloc && chan->rxgain)
+	if (is_gain_allocated(chan))
 		rxgain = chan->rxgain;
 	chan->rxgain = defgain;
 	chan->txgain = defgain;
-	chan->gainalloc = 0;
 	chan->eventinidx = chan->eventoutidx = 0;
 	dahdi_set_law(chan, DAHDI_LAW_DEFAULT);
 	dahdi_hangup(chan);
@@ -3776,18 +3786,16 @@
 	    !memcmp(txgain, defgain, GAIN_TABLE_SIZE)) {
 		kfree(rxgain);
 		spin_lock_irqsave(&chan->lock, flags);
-		if (chan->gainalloc)
+		if (is_gain_allocated(chan))
 			kfree(chan->rxgain);
-		chan->gainalloc = 0;
 		chan->rxgain = defgain;
 		chan->txgain = defgain;
 		spin_unlock_irqrestore(&chan->lock, flags);
 	} else {
 		/* This is a custom gain setting */
 		spin_lock_irqsave(&chan->lock, flags);
-		if (chan->gainalloc)
+		if (is_gain_allocated(chan))
 			kfree(chan->rxgain);
-		chan->gainalloc = 1;
 		chan->rxgain = rxgain;
 		chan->txgain = txgain;
 		spin_unlock_irqrestore(&chan->lock, flags);
@@ -3841,7 +3849,7 @@
 	module_printk(KERN_INFO, "flags: %x hex, writechunk: %p, readchunk: %p\n",
 		      (unsigned int) temp->flags, temp->writechunk, temp->readchunk);
 	module_printk(KERN_INFO, "rxgain: %p, txgain: %p, gainalloc: %d\n",
-		      temp->rxgain, temp->txgain, temp->gainalloc);
+		      temp->rxgain, temp->txgain, is_gain_allocated(temp));
 	module_printk(KERN_INFO, "span: %p, sig: %x hex, sigcap: %x hex\n",
 		      temp->span, temp->sig, temp->sigcap);
 	module_printk(KERN_INFO, "inreadbuf: %d, outreadbuf: %d, inwritebuf: %d, outwritebuf: %d\n",
@@ -5685,7 +5693,7 @@
 	int j, rv;
 	int ret;
 	int oldconf;
-	void *rxgain=NULL;
+	const void *rxgain = NULL;
 
 	if (!chan)
 		return -ENOSYS;
@@ -5747,14 +5755,13 @@
 			chan->ec_current = NULL;
 			/* release conference resource, if any to release */
 			reset_conf(chan);
-			if (chan->gainalloc && chan->rxgain)
+			if (is_gain_allocated(chan))
 				rxgain = chan->rxgain;
 			else
 				rxgain = NULL;
 
 			chan->rxgain = defgain;
 			chan->txgain = defgain;
-			chan->gainalloc = 0;
 			spin_unlock_irqrestore(&chan->lock, flags);
 
 			if (ec_state) {
@@ -5806,11 +5813,10 @@
 					ec_current = chan->ec_current;
 					chan->ec_current = NULL;
 					/* Make sure there's no gain */
-					if (chan->gainalloc)
+					if (is_gain_allocated(chan))
 						kfree(chan->rxgain);
 					chan->rxgain = defgain;
 					chan->txgain = defgain;
-					chan->gainalloc = 0;
 					chan->flags &= ~DAHDI_FLAG_AUDIO;
 					chan->flags |= (DAHDI_FLAG_PPP | DAHDI_FLAG_HDLC | DAHDI_FLAG_FCS);
 

Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=9385&r1=9384&r2=9385
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Mon Sep 20 15:34:40 2010
@@ -425,12 +425,9 @@
 	short *readchunkpreec;
 
 	/*! Pointer to tx and rx gain tables */
-	u_char *rxgain;
-	u_char *txgain;
-	
-	/*! Whether or not we have allocated gains or are using the default */
-	int gainalloc;
-
+	const u_char *rxgain;
+	const u_char *txgain;
+	
 	/* Specified by driver, readable by DAHDI */
 	void *pvt;			/*!< Private channel data */
 	struct file *file;	/*!< File structure */




More information about the svn-commits mailing list