[dahdi-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9292 - in /linux/team/...

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


Author: sruffell
Date: Thu Sep  2 12:41:28 2010
New Revision: 9292

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9292
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.

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=9292&r1=9291&r2=9292
==============================================================================
--- 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:28 2010
@@ -1340,6 +1340,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
@@ -1351,7 +1360,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;
@@ -1412,12 +1421,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);
 
@@ -1674,6 +1682,8 @@
 		chan->readchunk = chan->sreadchunk;
 	if (!chan->writechunk)
 		chan->writechunk = chan->swritechunk;
+	chan->rxgain = NULL;
+	chan->txgain = NULL;
 	dahdi_set_law(chan, 0);
 	close_channel(chan);
 
@@ -2653,7 +2663,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;
 
@@ -2734,11 +2744,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,0);
 	dahdi_hangup(chan);
@@ -3805,18 +3814,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);
@@ -3870,7 +3877,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",
@@ -5678,7 +5685,7 @@
 	int j, rv;
 	int ret;
 	int oldconf;
-	void *rxgain=NULL;
+	const void *rxgain = NULL;
 
 	if (!chan)
 		return -ENOSYS;
@@ -5740,14 +5747,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) {

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=9292&r1=9291&r2=9292
==============================================================================
--- 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:28 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 dahdi-commits mailing list