[zaptel-commits] tzafrir: branch 1.4 r3051 - /branches/1.4/zaptel-base.c

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Tue Sep 18 04:55:40 CDT 2007


Author: tzafrir
Date: Tue Sep 18 04:55:39 2007
New Revision: 3051

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3051
Log:
Fix the ioctl ZT_CHANDIAG and enable it by default.
(Backport changeset 2384 from trunk)

Modified:
    branches/1.4/zaptel-base.c

Modified: branches/1.4/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel-base.c?view=diff&rev=3051&r1=3050&r2=3051
==============================================================================
--- branches/1.4/zaptel-base.c (original)
+++ branches/1.4/zaptel-base.c Tue Sep 18 04:55:39 2007
@@ -2958,10 +2958,7 @@
 	struct zt_chan *chan;
 	unsigned long flags;
 	unsigned char *txgain, *rxgain;
-#ifdef ALLOW_CHAN_DIAG
-	/* This structure is huge and will bork a 4k stack */
-	struct zt_chan mychan;
-#endif	
+	struct zt_chan *mychan;
 	int i,j;
 	int return_master = 0;
 
@@ -3177,57 +3174,62 @@
 		if (copy_to_user((struct zt_spaninfo *) data,&stack.span, cmd == ZT_SPANSTAT_COMPAT ? sizeof(stack.span_compat) : sizeof(stack.span)))
 			return -EFAULT;
 		break;
-#ifdef ALLOW_CHAN_DIAG
 	case ZT_CHANDIAG:
 		get_user(j, (int *)data); /* get channel number from user */
 		/* make sure its a valid channel number */
 		if ((j < 1) || (j >= maxchans))
 			return -EINVAL;
 		/* if channel not mapped, not there */
-		if (!chans[j]) return -EINVAL;
-		/* lock irq state */
+		if (!chans[j]) 
+			return -EINVAL;
+
+		if (!(mychan = kmalloc(sizeof(*mychan), GFP_KERNEL)))
+			return -ENOMEM;
+
+		/* lock channel */
 		spin_lock_irqsave(&chans[j]->lock, flags);
 		/* make static copy of channel */
-		memcpy(&mychan,chans[j],sizeof(struct zt_chan));
-		/* let irq's go */
+		memcpy(mychan, chans[j], sizeof(*mychan));
+		/* release it. */
 		spin_unlock_irqrestore(&chans[j]->lock, flags);
+
 		printk("Dump of Zaptel Channel %d (%s,%d,%d):\n\n",j,
-			mychan.name,mychan.channo,mychan.chanpos);
+			mychan->name,mychan->channo,mychan->chanpos);
 		printk("flags: %x hex, writechunk: %08lx, readchunk: %08lx\n",
-			mychan.flags, (long) mychan.writechunk, (long) mychan.readchunk);
+			mychan->flags, (long) mychan->writechunk, (long) mychan->readchunk);
 		printk("rxgain: %08lx, txgain: %08lx, gainalloc: %d\n",
-			(long) mychan.rxgain, (long)mychan.txgain, mychan.gainalloc);
+			(long) mychan->rxgain, (long)mychan->txgain, mychan->gainalloc);
 		printk("span: %08lx, sig: %x hex, sigcap: %x hex\n",
-			(long)mychan.span, mychan.sig, mychan.sigcap);
+			(long)mychan->span, mychan->sig, mychan->sigcap);
 		printk("inreadbuf: %d, outreadbuf: %d, inwritebuf: %d, outwritebuf: %d\n",
-			mychan.inreadbuf, mychan.outreadbuf, mychan.inwritebuf, mychan.outwritebuf);
+			mychan->inreadbuf, mychan->outreadbuf, mychan->inwritebuf, mychan->outwritebuf);
 		printk("blocksize: %d, numbufs: %d, txbufpolicy: %d, txbufpolicy: %d\n",
-			mychan.blocksize, mychan.numbufs, mychan.txbufpolicy, mychan.rxbufpolicy);
+			mychan->blocksize, mychan->numbufs, mychan->txbufpolicy, mychan->rxbufpolicy);
 		printk("txdisable: %d, rxdisable: %d, iomask: %d\n",
-			mychan.txdisable, mychan.rxdisable, mychan.iomask);
+			mychan->txdisable, mychan->rxdisable, mychan->iomask);
 		printk("curzone: %08lx, tonezone: %d, curtone: %08lx, tonep: %d\n",
-			(long) mychan.curzone, mychan.tonezone, (long) mychan.curtone, mychan.tonep);
+			(long) mychan->curzone, mychan->tonezone, (long) mychan->curtone, mychan->tonep);
 		printk("digitmode: %d, txdialbuf: %s, dialing: %d, aftdialtimer: %d, cadpos. %d\n",
-			mychan.digitmode, mychan.txdialbuf, mychan.dialing,
-				mychan.afterdialingtimer, mychan.cadencepos);
+			mychan->digitmode, mychan->txdialbuf, mychan->dialing,
+				mychan->afterdialingtimer, mychan->cadencepos);
 		printk("confna: %d, confn: %d, confmode: %d, confmute: %d\n",
-			mychan.confna, mychan._confn, mychan.confmode, mychan.confmute);
+			mychan->confna, mychan->_confn, mychan->confmode, mychan->confmute);
 		printk("ec: %08lx, echocancel: %d, deflaw: %d, xlaw: %08lx\n",
-			(long) mychan.ec, mychan.echocancel, mychan.deflaw, (long) mychan.xlaw);
+			(long) mychan->ec, mychan->echocancel, mychan->deflaw, (long) mychan->xlaw);
 		printk("echostate: %02x, echotimer: %d, echolastupdate: %d\n",
-			(int) mychan.echostate, mychan.echotimer, mychan.echolastupdate);
+			(int) mychan->echostate, mychan->echotimer, mychan->echolastupdate);
 		printk("itimer: %d, otimer: %d, ringdebtimer: %d\n\n",
-			mychan.itimer,mychan.otimer,mychan.ringdebtimer);
+			mychan->itimer, mychan->otimer, mychan->ringdebtimer);
 #if 0
-		if (mychan.ec) {
+		if (mychan->ec) {
 			int x;
 			/* Dump the echo canceller parameters */
-			for (x=0;x<mychan.ec->taps;x++) {
-				printk("tap %d: %d\n", x, mychan.ec->fir_taps[x]);
-			}
-		}
-#endif
-#endif /* ALLOW_CHAN_DIAG */
+			for (x=0;x<mychan->ec->taps;x++) {
+				printk("tap %d: %d\n", x, mychan->ec->fir_taps[x]);
+			}
+		}
+#endif
+		kfree(mychan);
 		break;
 	default:
 		return -ENOTTY;




More information about the zaptel-commits mailing list