[asterisk-commits] tzafrir: trunk r254406 - /trunk/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 25 05:09:29 CDT 2010


Author: tzafrir
Date: Thu Mar 25 05:09:24 2010
New Revision: 254406

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=254406
Log:
remove unneeded explicit channel in dahdi ioctls

This patch removes some cases where the channel number for an ioctl was
passed as a member in a struct rather then through the file descriptor.

The gain setting functions passed around a channel which is always 0,
and thus this parameter is simply dropped.

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

Modified:
    trunk/channels/chan_dahdi.c

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=254406&r1=254405&r2=254406
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Thu Mar 25 05:09:24 2010
@@ -4304,13 +4304,12 @@
 	}
 }
 
-static int set_actual_txgain(int fd, int chan, float gain, float drc, int law)
+static int set_actual_txgain(int fd, float gain, float drc, int law)
 {
 	struct dahdi_gains g;
 	int res;
 
 	memset(&g, 0, sizeof(g));
-	g.chan = chan;
 	res = ioctl(fd, DAHDI_GETGAINS, &g);
 	if (res) {
 		ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
@@ -4322,13 +4321,12 @@
 	return ioctl(fd, DAHDI_SETGAINS, &g);
 }
 
-static int set_actual_rxgain(int fd, int chan, float gain, float drc, int law)
+static int set_actual_rxgain(int fd, float gain, float drc, int law)
 {
 	struct dahdi_gains g;
 	int res;
 
 	memset(&g, 0, sizeof(g));
-	g.chan = chan;
 	res = ioctl(fd, DAHDI_GETGAINS, &g);
 	if (res) {
 		ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
@@ -4340,9 +4338,9 @@
 	return ioctl(fd, DAHDI_SETGAINS, &g);
 }
 
-static int set_actual_gain(int fd, int chan, float rxgain, float txgain, float rxdrc, float txdrc, int law)
-{
-	return set_actual_txgain(fd, chan, txgain, txdrc, law) | set_actual_rxgain(fd, chan, rxgain, rxdrc, law);
+static int set_actual_gain(int fd, float rxgain, float txgain, float rxdrc, float txdrc, int law)
+{
+	return set_actual_txgain(fd, txgain, txdrc, law) | set_actual_rxgain(fd, rxgain, rxdrc, law);
 }
 
 static int bump_gains(struct dahdi_pvt *p)
@@ -4350,7 +4348,7 @@
 	int res;
 
 	/* Bump receive gain by value stored in cid_rxgain */
-	res = set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain + p->cid_rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
+	res = set_actual_gain(p->subs[SUB_REAL].dfd, p->rxgain + p->cid_rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
 	if (res) {
 		ast_log(LOG_WARNING, "Unable to bump gain: %s\n", strerror(errno));
 		return -1;
@@ -4363,7 +4361,7 @@
 {
 	int res;
 
-	res = set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
+	res = set_actual_gain(p->subs[SUB_REAL].dfd, p->rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
 	if (res) {
 		ast_log(LOG_WARNING, "Unable to restore gains: %s\n", strerror(errno));
 		return -1;
@@ -4624,9 +4622,9 @@
 	p->outgoing = 1;
 
 	if (IS_DIGITAL(ast->transfercapability)){
-		set_actual_gain(p->subs[SUB_REAL].dfd, 0, 0, 0, p->rxdrc, p->txdrc, p->law);
+		set_actual_gain(p->subs[SUB_REAL].dfd, 0, 0, p->rxdrc, p->txdrc, p->law);
 	} else {
-		set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
+		set_actual_gain(p->subs[SUB_REAL].dfd, p->rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
 	}	
 
 #ifdef HAVE_PRI
@@ -5991,7 +5989,7 @@
 			return -1;
 		}
 		ast_debug(1, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
-		return set_actual_txgain(p->subs[idx].dfd, 0, p->txgain + (float) *scp, p->txdrc, p->law);
+		return set_actual_txgain(p->subs[idx].dfd, p->txgain + (float) *scp, p->txdrc, p->law);
 	case AST_OPTION_RXGAIN:
 		scp = (signed char *) data;
 		idx = dahdi_get_index(chan, p, 0);
@@ -6000,7 +5998,7 @@
 			return -1;
 		}
 		ast_debug(1, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
-		return set_actual_rxgain(p->subs[idx].dfd, 0, p->rxgain + (float) *scp, p->rxdrc, p->law);
+		return set_actual_rxgain(p->subs[idx].dfd, p->rxgain + (float) *scp, p->rxdrc, p->law);
 	case AST_OPTION_TONE_VERIFY:
 		if (!p->dsp)
 			break;
@@ -8032,7 +8030,6 @@
 		struct dahdi_params ps;
 
 		memset(&ps, 0, sizeof(ps));
-		ps.channo = p->channel;
 		if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps) < 0) {
 			ast_mutex_unlock(&p->lock);
 			return NULL;
@@ -8639,7 +8636,6 @@
 		return NULL;
 	tmp->tech = &dahdi_tech;
 	memset(&ps, 0, sizeof(ps));
-	ps.channo = i->channel;
 	res = ioctl(i->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps);
 	if (res) {
 		ast_log(LOG_WARNING, "Unable to get parameters, assuming MULAW: %s\n", strerror(errno));
@@ -11695,7 +11691,7 @@
 		tmp->rxdrc = conf->chan.rxdrc;
 		tmp->tonezone = conf->chan.tonezone;
 		if (tmp->subs[SUB_REAL].dfd > -1) {
-			set_actual_gain(tmp->subs[SUB_REAL].dfd, 0, tmp->rxgain, tmp->txgain, tmp->rxdrc, tmp->txdrc, tmp->law);
+			set_actual_gain(tmp->subs[SUB_REAL].dfd, tmp->rxgain, tmp->txgain, tmp->rxdrc, tmp->txdrc, tmp->law);
 			if (tmp->dsp)
 				ast_dsp_set_digitmode(tmp->dsp, DSP_DIGITMODE_DTMF | tmp->dtmfrelax);
 			update_conf(tmp);
@@ -14849,9 +14845,9 @@
 			break;
 
 		if (tx)
-			res = set_actual_txgain(tmp->subs[SUB_REAL].dfd, channel, gain, tmp->txdrc, tmp->law);
+			res = set_actual_txgain(tmp->subs[SUB_REAL].dfd, gain, tmp->txdrc, tmp->law);
 		else
-			res = set_actual_rxgain(tmp->subs[SUB_REAL].dfd, channel, gain, tmp->rxdrc, tmp->law);
+			res = set_actual_rxgain(tmp->subs[SUB_REAL].dfd, gain, tmp->rxdrc, tmp->law);
 
 		if (res) {
 			ast_cli(a->fd, "Unable to set the software gain for channel %d\n", channel);




More information about the asterisk-commits mailing list