[svn-commits] kpfleming: linux/trunk r4513 - in /linux/trunk: drivers/dahdi/ drivers/dahdi/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 2 08:31:32 CDT 2008


Author: kpfleming
Date: Wed Jul  2 08:31:31 2008
New Revision: 4513

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4513
Log:
break up large memory allocations made by digital span drivers into smaller ones (one allocation for each dahdi_chan structure, separate from any private structures used by the driver)

(closes issue #12657)
Reported by: tzafrir

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c
    linux/trunk/drivers/dahdi/dahdi_dynamic.c
    linux/trunk/drivers/dahdi/tor2.c
    linux/trunk/drivers/dahdi/wct1xxp.c
    linux/trunk/drivers/dahdi/wct4xxp/base.c
    linux/trunk/drivers/dahdi/wcte11xp.c
    linux/trunk/drivers/dahdi/wcte12xp/base.c
    linux/trunk/drivers/dahdi/wcte12xp/vpmadt032.c
    linux/trunk/drivers/dahdi/wcte12xp/wcte12xp.h
    linux/trunk/drivers/dahdi/xpp/card_fxo.c
    linux/trunk/drivers/dahdi/xpp/card_fxs.c
    linux/trunk/drivers/dahdi/xpp/card_pri.c
    linux/trunk/drivers/dahdi/xpp/xbus-pcm.c
    linux/trunk/drivers/dahdi/xpp/xpd.h
    linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
    linux/trunk/include/dahdi/kernel.h

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=4513&r1=4512&r2=4513
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Wed Jul  2 08:31:31 2008
@@ -3113,7 +3113,7 @@
 	if ((!span->alarms) != (!span->lastalarms)) {
 		span->lastalarms = span->alarms;
 		for (x = 0; x < span->channels; x++)
-			dahdi_alarm_channel(&span->chans[x], span->alarms);
+			dahdi_alarm_channel(span->chans[x], span->alarms);
 		/* Switch to other master if current master in alarm */
 		for (x=1; x<maxspans; x++) {
 			if (spans[x] && !spans[x]->alarms && (spans[x]->flags & DAHDI_FLAG_RUNNING)) {
@@ -3424,7 +3424,7 @@
 		stack.spaninfo.totalchans = spans[i]->channels;
 		stack.spaninfo.numchans = 0;
 		for (j = 0; j < spans[i]->channels; j++) {
-			if (spans[i]->chans[j].sig)
+			if (spans[i]->chans[j]->sig)
 				stack.spaninfo.numchans++;
 		}
 		stack.spaninfo.lbo = spans[i]->lbo;
@@ -3536,13 +3536,13 @@
 
 	/* Link all slaves appropriately */
 	for (x=chan->chanpos;x<chan->span->channels;x++)
-		if (chan->span->chans[x].master == chan) {
+		if (chan->span->chans[x]->master == chan) {
 #ifdef CONFIG_DAHDI_DEBUG
 			module_printk(KERN_NOTICE, "Channel %s, slave to %s, last is %s, its next will be %d\n", 
 				      chan->span->chans[x].name, chan->name, last->name, x);
 #endif
 			last->nextslave = x;
-			last = &chan->span->chans[x];
+			last = chan->span->chans[x];
 		}
 	/* Terminate list */
 	last->nextslave = 0;
@@ -3600,12 +3600,12 @@
 			/* Mark as running and hangup any channels */
 			spans[j]->flags |= DAHDI_FLAG_RUNNING;
 			for (x=0;x<spans[j]->channels;x++) {
-				y = dahdi_q_sig(&spans[j]->chans[x]) & 0xff;
-				if (y >= 0) spans[j]->chans[x].rxsig = (unsigned char)y;
-				spin_lock_irqsave(&spans[j]->chans[x].lock, flags);
-				dahdi_hangup(&spans[j]->chans[x]);
-				spin_unlock_irqrestore(&spans[j]->chans[x].lock, flags);
-				spans[j]->chans[x].rxhooksig = DAHDI_RXSIG_INITIAL;
+				y = dahdi_q_sig(spans[j]->chans[x]) & 0xff;
+				if (y >= 0) spans[j]->chans[x]->rxsig = (unsigned char)y;
+				spin_lock_irqsave(&spans[j]->chans[x]->lock, flags);
+				dahdi_hangup(spans[j]->chans[x]);
+				spin_unlock_irqrestore(&spans[j]->chans[x]->lock, flags);
+				spans[j]->chans[x]->rxhooksig = DAHDI_RXSIG_INITIAL;
 			}
 		}
 		return 0;
@@ -5193,8 +5193,8 @@
 	}
 
 	for (x=0;x<span->channels;x++) {
-		span->chans[x].span = span;
-		dahdi_chan_reg(&span->chans[x]); 
+		span->chans[x]->span = span;
+		dahdi_chan_reg(span->chans[x]); 
 	}
 
 #ifdef CONFIG_PROC_FS
@@ -5204,9 +5204,9 @@
 
 	for (x = 0; x < span->channels; x++) {
 		char chan_name[50];
-		if (span->chans[x].channo < 250) {
-			sprintf(chan_name, "dahdi%d", span->chans[x].channo);
-			CLASS_DEV_CREATE(dahdi_class, MKDEV(DAHDI_MAJOR, span->chans[x].channo), NULL, chan_name);
+		if (span->chans[x]->channo < 250) {
+			sprintf(chan_name, "dahdi%d", span->chans[x]->channo);
+			CLASS_DEV_CREATE(dahdi_class, MKDEV(DAHDI_MAJOR, span->chans[x]->channo), NULL, chan_name);
 		}
 	}
 
@@ -5251,15 +5251,15 @@
 #endif /* CONFIG_PROC_FS */
 
 	for (x = 0; x < span->channels; x++) {
-		if (span->chans[x].channo < 250)
-			class_device_destroy(dahdi_class, MKDEV(DAHDI_MAJOR, span->chans[x].channo));
+		if (span->chans[x]->channo < 250)
+			class_device_destroy(dahdi_class, MKDEV(DAHDI_MAJOR, span->chans[x]->channo));
 	}
 
 	spans[span->spanno] = NULL;
 	span->spanno = 0;
 	span->flags &= ~DAHDI_FLAG_REGISTERED;
 	for (x=0;x<span->channels;x++)
-		dahdi_chan_unreg(&span->chans[x]);
+		dahdi_chan_unreg(span->chans[x]);
 	new_maxspans = 0;
 	new_master = master; /* FIXME: locking */
 	if (master == span)
@@ -6322,8 +6322,8 @@
 {
 	int x;
 	for (x = 0; x < span->channels; x++) {
-		if (span->chans[x].ec_current)
-			__dahdi_ec_chunk(&span->chans[x], span->chans[x].readchunk, span->chans[x].writechunk);
+		if (span->chans[x]->ec_current)
+			__dahdi_ec_chunk(span->chans[x], span->chans[x]->readchunk, span->chans[x]->writechunk);
 	}
 }
 
@@ -7309,22 +7309,22 @@
 
 #if 1
 	for (x=0;x<span->channels;x++) {
-		spin_lock_irqsave(&span->chans[x].lock, flags);
-		if (span->chans[x].flags & DAHDI_FLAG_NOSTDTXRX) {
-			spin_unlock_irqrestore(&span->chans[x].lock, flags);
+		spin_lock_irqsave(&span->chans[x]->lock, flags);
+		if (span->chans[x]->flags & DAHDI_FLAG_NOSTDTXRX) {
+			spin_unlock_irqrestore(&span->chans[x]->lock, flags);
 			continue;
 		}
-		if (&span->chans[x] == span->chans[x].master) {
-			if (span->chans[x].otimer) {
-				span->chans[x].otimer -= DAHDI_CHUNKSIZE;
-				if (span->chans[x].otimer <= 0) {
-					__rbs_otimer_expire(&span->chans[x]);
+		if (span->chans[x] == span->chans[x]->master) {
+			if (span->chans[x]->otimer) {
+				span->chans[x]->otimer -= DAHDI_CHUNKSIZE;
+				if (span->chans[x]->otimer <= 0) {
+					__rbs_otimer_expire(span->chans[x]);
 				}
 			}
-			if (span->chans[x].flags & DAHDI_FLAG_AUDIO) {
-				__dahdi_real_transmit(&span->chans[x]);
+			if (span->chans[x]->flags & DAHDI_FLAG_AUDIO) {
+				__dahdi_real_transmit(span->chans[x]);
 			} else {
-				if (span->chans[x].nextslave) {
+				if (span->chans[x]->nextslave) {
 					u_char data[DAHDI_CHUNKSIZE];
 					int pos=DAHDI_CHUNKSIZE;
 					/* Process master/slaves one way */
@@ -7334,30 +7334,30 @@
 						do {
 							if (pos==DAHDI_CHUNKSIZE) {
 								/* Get next chunk */
-								__dahdi_transmit_chunk(&span->chans[x], data);
+								__dahdi_transmit_chunk(span->chans[x], data);
 								pos = 0;
 							}
-							span->chans[z].writechunk[y] = data[pos++]; 
-							z = span->chans[z].nextslave;
+							span->chans[z]->writechunk[y] = data[pos++]; 
+							z = span->chans[z]->nextslave;
 						} while(z);
 					}
 				} else {
 					/* Process independents elsewise */
-					__dahdi_real_transmit(&span->chans[x]);
+					__dahdi_real_transmit(span->chans[x]);
 				}
 			}
-			if (span->chans[x].sig == DAHDI_SIG_DACS_RBS) {
-				if (chans[span->chans[x].confna]) {
+			if (span->chans[x]->sig == DAHDI_SIG_DACS_RBS) {
+				if (chans[span->chans[x]->confna]) {
 				    	/* Just set bits for our destination */
-					if (span->chans[x].txsig != chans[span->chans[x].confna]->rxsig) {
-						span->chans[x].txsig = chans[span->chans[x].confna]->rxsig;
-						span->rbsbits(&span->chans[x], chans[span->chans[x].confna]->rxsig);
+					if (span->chans[x]->txsig != chans[span->chans[x]->confna]->rxsig) {
+						span->chans[x]->txsig = chans[span->chans[x]->confna]->rxsig;
+						span->rbsbits(span->chans[x], chans[span->chans[x]->confna]->rxsig);
 					}
 				}
 			}
 
 		}
-		spin_unlock_irqrestore(&span->chans[x].lock, flags);
+		spin_unlock_irqrestore(&span->chans[x]->lock, flags);
 	}
 	if (span->mainttimer) {
 		span->mainttimer -= DAHDI_CHUNKSIZE;
@@ -7383,9 +7383,9 @@
 	span->watchcounter--;
 #endif	
 	for (x=0;x<span->channels;x++) {
-		if (span->chans[x].master == &span->chans[x]) {
-			spin_lock_irqsave(&span->chans[x].lock, flags);
-			if (span->chans[x].nextslave) {
+		if (span->chans[x]->master == span->chans[x]) {
+			spin_lock_irqsave(&span->chans[x]->lock, flags);
+			if (span->chans[x]->nextslave) {
 				/* Must process each slave at the same time */
 				u_char data[DAHDI_CHUNKSIZE];
 				int pos = 0;
@@ -7393,65 +7393,65 @@
 					/* Put all its slaves, too */
 					z = x;
 					do {
-						data[pos++] = span->chans[z].readchunk[y];
+						data[pos++] = span->chans[z]->readchunk[y];
 						if (pos == DAHDI_CHUNKSIZE) {
-							if(!(span->chans[x].flags & DAHDI_FLAG_NOSTDTXRX))
-								__dahdi_receive_chunk(&span->chans[x], data);
+							if(!(span->chans[x]->flags & DAHDI_FLAG_NOSTDTXRX))
+								__dahdi_receive_chunk(span->chans[x], data);
 							pos = 0;
 						}
-						z=span->chans[z].nextslave;
+						z=span->chans[z]->nextslave;
 					} while(z);
 				}
 			} else {
 				/* Process a normal channel */
-				if (!(span->chans[x].flags & DAHDI_FLAG_NOSTDTXRX))
-					__dahdi_real_receive(&span->chans[x]);
-			}
-			if (span->chans[x].itimer) {
-				span->chans[x].itimer -= DAHDI_CHUNKSIZE;
-				if (span->chans[x].itimer <= 0) {
-					rbs_itimer_expire(&span->chans[x]);
+				if (!(span->chans[x]->flags & DAHDI_FLAG_NOSTDTXRX))
+					__dahdi_real_receive(span->chans[x]);
+			}
+			if (span->chans[x]->itimer) {
+				span->chans[x]->itimer -= DAHDI_CHUNKSIZE;
+				if (span->chans[x]->itimer <= 0) {
+					rbs_itimer_expire(span->chans[x]);
 				}
 			}
-			if (span->chans[x].ringdebtimer)
-				span->chans[x].ringdebtimer--;
-			if (span->chans[x].sig & __DAHDI_SIG_FXS) {
-				if (span->chans[x].rxhooksig == DAHDI_RXSIG_RING)
-					span->chans[x].ringtrailer = DAHDI_RINGTRAILER;
-				else if (span->chans[x].ringtrailer) {
-					span->chans[x].ringtrailer-= DAHDI_CHUNKSIZE;
+			if (span->chans[x]->ringdebtimer)
+				span->chans[x]->ringdebtimer--;
+			if (span->chans[x]->sig & __DAHDI_SIG_FXS) {
+				if (span->chans[x]->rxhooksig == DAHDI_RXSIG_RING)
+					span->chans[x]->ringtrailer = DAHDI_RINGTRAILER;
+				else if (span->chans[x]->ringtrailer) {
+					span->chans[x]->ringtrailer-= DAHDI_CHUNKSIZE;
 					/* See if RING trailer is expired */
-					if (!span->chans[x].ringtrailer && !span->chans[x].ringdebtimer) 
-						__qevent(&span->chans[x],DAHDI_EVENT_RINGOFFHOOK);
+					if (!span->chans[x]->ringtrailer && !span->chans[x]->ringdebtimer) 
+						__qevent(span->chans[x],DAHDI_EVENT_RINGOFFHOOK);
 				}
 			}
-			if (span->chans[x].pulsetimer)
+			if (span->chans[x]->pulsetimer)
 			{
-				span->chans[x].pulsetimer--;
-				if (span->chans[x].pulsetimer <= 0)
+				span->chans[x]->pulsetimer--;
+				if (span->chans[x]->pulsetimer <= 0)
 				{
-					if (span->chans[x].pulsecount)
+					if (span->chans[x]->pulsecount)
 					{
-						if (span->chans[x].pulsecount > 12) {
+						if (span->chans[x]->pulsecount > 12) {
 						
 							module_printk(KERN_NOTICE, "Got pulse digit %d on %s???\n",
-						    span->chans[x].pulsecount,
-							span->chans[x].name);
-						} else if (span->chans[x].pulsecount > 11) {
-							__qevent(&span->chans[x], DAHDI_EVENT_PULSEDIGIT | '#');
-						} else if (span->chans[x].pulsecount > 10) {
-							__qevent(&span->chans[x], DAHDI_EVENT_PULSEDIGIT | '*');
-						} else if (span->chans[x].pulsecount > 9) {
-							__qevent(&span->chans[x], DAHDI_EVENT_PULSEDIGIT | '0');
+						    span->chans[x]->pulsecount,
+							span->chans[x]->name);
+						} else if (span->chans[x]->pulsecount > 11) {
+							__qevent(span->chans[x], DAHDI_EVENT_PULSEDIGIT | '#');
+						} else if (span->chans[x]->pulsecount > 10) {
+							__qevent(span->chans[x], DAHDI_EVENT_PULSEDIGIT | '*');
+						} else if (span->chans[x]->pulsecount > 9) {
+							__qevent(span->chans[x], DAHDI_EVENT_PULSEDIGIT | '0');
 						} else {
-							__qevent(&span->chans[x], DAHDI_EVENT_PULSEDIGIT | ('0' + 
-								span->chans[x].pulsecount));
+							__qevent(span->chans[x], DAHDI_EVENT_PULSEDIGIT | ('0' + 
+								span->chans[x]->pulsecount));
 						}
-						span->chans[x].pulsecount = 0;
+						span->chans[x]->pulsecount = 0;
 					}
 				}
 			}
-			spin_unlock_irqrestore(&span->chans[x].lock, flags);
+			spin_unlock_irqrestore(&span->chans[x]->lock, flags);
 		}
 	}
 

Modified: linux/trunk/drivers/dahdi/dahdi_dynamic.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi_dynamic.c?view=diff&rev=4513&r1=4512&r2=4513
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi_dynamic.c (original)
+++ linux/trunk/drivers/dahdi/dahdi_dynamic.c Wed Jul  2 08:31:31 2008
@@ -236,7 +236,7 @@
 			/* Ignore dead spans */
 			for (y=0;y<z->span.channels;y++) {
 				/* Echo cancel double buffered data */
-				dahdi_ec_chunk(&z->span.chans[y], z->span.chans[y].readchunk, z->span.chans[y].writechunk);
+				dahdi_ec_chunk(z->span.chans[y], z->span.chans[y]->readchunk, z->span.chans[y]->writechunk);
 			}
 			dahdi_receive(&z->span);
 			dahdi_transmit(&z->span);
@@ -368,15 +368,15 @@
 			sig = (bits >> ((x % 4) << 2)) & 0xff;
 			
 			/* Update signalling if appropriate */
-			if (sig != span->chans[x].rxsig)
-				dahdi_rbsbits(&span->chans[x], sig);
+			if (sig != span->chans[x]->rxsig)
+				dahdi_rbsbits(span->chans[x], sig);
 				
 		}
 	}
 	
 	/* Record data for channels */
 	for (x=0;x<nchans;x++) {
-		memcpy(span->chans[x].readchunk, msg, DAHDI_CHUNKSIZE);
+		memcpy(span->chans[x]->readchunk, msg, DAHDI_CHUNKSIZE);
 		msg += DAHDI_CHUNKSIZE;
 	}
 

Modified: linux/trunk/drivers/dahdi/tor2.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/tor2.c?view=diff&rev=4513&r1=4512&r2=4513
==============================================================================
--- linux/trunk/drivers/dahdi/tor2.c (original)
+++ linux/trunk/drivers/dahdi/tor2.c Wed Jul  2 08:31:31 2008
@@ -101,7 +101,7 @@
 	volatile unsigned char *mem8;	/* Virtual representation of 8 bit Xilinx memory area */
 	struct dahdi_span spans[SPANS_PER_CARD];		/* Spans */
 	struct tor2_span tspans[SPANS_PER_CARD];	/* Span data */
-	struct dahdi_chan *chans[SPANS_PER_CARD];		/* Pointers to blocks of 24(30/31) contiguous dahdi_chans for each span */
+	struct dahdi_chan **chans[SPANS_PER_CARD];		/* Pointers to blocks of 24(30/31) contiguous dahdi_chans for each span */
 	struct tor2_chan tchans[32 * SPANS_PER_CARD];	/* Channel user data */
 	unsigned char txsigs[SPANS_PER_CARD][16];	/* Copy of tx sig registers */
 	int loopupcnt[SPANS_PER_CARD];	/* loop up code counter */
@@ -296,7 +296,7 @@
 		tor->tspans[x].span = x;
 		init_waitqueue_head(&tor->spans[x].maintq);
 		for (y=0;y<tor->spans[x].channels;y++) {
-			struct dahdi_chan *mychans = tor->chans[x] + y;
+			struct dahdi_chan *mychans = tor->chans[x][y];
 			sprintf(mychans->name, "Tor2/%d/%d/%d", tor->num, x + 1, y + 1);
 			mychans->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_FXSLS | DAHDI_SIG_FXSGS | DAHDI_SIG_FXSKS |
  									 DAHDI_SIG_FXOLS | DAHDI_SIG_FXOGS | DAHDI_SIG_FXOKS | DAHDI_SIG_CAS | DAHDI_SIG_SF | DAHDI_SIG_EM_E1;
@@ -343,6 +343,20 @@
 	return 0;
 }
 
+static void free_tor(struct tor2 *tor)
+{
+	unsigned int x, f;
+
+	for (x = 0; x < SPANS_PER_CARD; x++) {
+		for (f = 0; f < (tor->cardtype == TYPE_E1 ? 31 : 24); f++) {
+			if (tor->chans[x][f]) {
+				kfree(tor->chans[x][f]);
+			}
+		}
+	}
+	kfree(tor);
+}
+
 static int __devinit tor2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	int res,x,f;
@@ -359,12 +373,6 @@
 		return -ENOMEM;
 	memset(tor,0,sizeof(struct tor2));
 	spin_lock_init(&tor->lock);
-	for (x = 0; x < SPANS_PER_CARD; x++) {
-		tor->chans[x] = kmalloc(sizeof(struct dahdi_chan) * 31,GFP_KERNEL);
-		if (!tor->chans[x])
-			return -ENOMEM;
-		memset(tor->chans[x],0,sizeof(struct dahdi_chan) * 31);
-	}
 	/* Load the resources */
 	tor->pci = pdev;
 	tor->irq = pdev->irq;
@@ -524,7 +532,6 @@
 #endif
 	for (x = 0; x < 256; x++) tor->mem32[x] = 0x7f7f7f7f;
 
-
 	if (request_irq(tor->irq, tor2_intr, DAHDI_IRQ_SHARED_DISABLED, "tor2", tor)) {
 		printk(KERN_ERR "Unable to request tormenta IRQ %d\n", tor->irq);
 		goto err_out_release_all;
@@ -539,6 +546,16 @@
 		tor->cardtype = TYPE_T1;
 		tor->datxlt = datxlt_t1;
 	}
+
+	for (x = 0; x < SPANS_PER_CARD; x++) {
+		for (f = 0; f < (tor->cardtype == TYPE_E1 ? 31 : 24); f++) {
+			if (!(tor->chans[x][f] = kmalloc(sizeof(*tor->chans[x][f]), GFP_KERNEL))) {
+				return -ENOMEM;
+			}
+			memset(tor->chans[x][f], 0, sizeof(*tor->chans[x][f]));
+		}
+	}
+
 	init_spans(tor); 
 
 	tor->order = tor->mem8[SWREG];
@@ -575,8 +592,7 @@
 	if (tor->mem8) iounmap((void *)tor->mem8);
 	if (tor->mem32) iounmap((void *)tor->mem32);
 	if (tor) {
-		for (x = 0; x < 3; x++) kfree(tor->chans[x]);
-		kfree(tor);
+		free_tor(tor);
 	}
 	return -ENODEV;
 }
@@ -585,8 +601,8 @@
 
 static void __devexit tor2_remove(struct pci_dev *pdev)
 {
-	int x;
 	struct tor2 *tor;
+
 	tor = pci_get_drvdata(pdev);
 	if (!tor)
 		BUG();
@@ -612,10 +628,7 @@
 
 	cards[tor->num] = 0;
 	pci_set_drvdata(pdev, NULL);
-	for (x = 0; x < 3; x++) 
-		if (tor->chans[x])
-			kfree(tor->chans[x]);
-	kfree(tor);
+	free_tor(tor);
 }
 
 static struct pci_driver tor2_driver = {
@@ -644,7 +657,7 @@
 	for (s = 0; s < SPANS_PER_CARD; s++) {
 		for (i = 0; i < 24; i++) {
 			j = (i/8);
-			if (tor->spans[s].chans[i].flags & DAHDI_FLAG_CLEAR) 
+			if (tor->spans[s].chans[i]->flags & DAHDI_FLAG_CLEAR) 
 				val |= 1 << (i % 8);
 
 			if ((i % 8)==7) {
@@ -797,9 +810,9 @@
 	for (i = 0; i < span->channels; i++)
 	{
 		memset(p->tor->ec_chunk1[p->span][i],
-			DAHDI_LIN2X(0,&span->chans[i]),DAHDI_CHUNKSIZE);
+			DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE);
 		memset(p->tor->ec_chunk2[p->span][i],
-			DAHDI_LIN2X(0,&span->chans[i]),DAHDI_CHUNKSIZE);
+			DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE);
 	}
 	/* Force re-evaluation of the timing source */
 	if (timingcable)
@@ -1052,13 +1065,13 @@
 			   need to delay the transmit data 2 entire chunks so
 			   that the transmit will be in sync with the receive */
 			for (y=0;y<tor->spans[x].channels;y++) {
-				dahdi_ec_chunk(&tor->spans[x].chans[y], 
-				    tor->spans[x].chans[y].readchunk, 
+				dahdi_ec_chunk(tor->spans[x].chans[y], 
+				    tor->spans[x].chans[y]->readchunk, 
 					tor->ec_chunk2[x][y]);
 				memcpy(tor->ec_chunk2[x][y],tor->ec_chunk1[x][y],
 					DAHDI_CHUNKSIZE);
 				memcpy(tor->ec_chunk1[x][y],
-					tor->spans[x].chans[y].writechunk,
+					tor->spans[x].chans[y]->writechunk,
 						DAHDI_CHUNKSIZE);
 			}
 			dahdi_receive(&tor->spans[x]);
@@ -1199,13 +1212,13 @@
 	for (n = 0; n < tor->spans[0].channels; n++) {
 		for (i = 0; i < DAHDI_CHUNKSIZE; i++) {
 			/* span 1 */
-			txword = tor->spans[0].chans[n].writechunk[i] << 24;
+			txword = tor->spans[0].chans[n]->writechunk[i] << 24;
 			/* span 2 */
-			txword |= tor->spans[1].chans[n].writechunk[i] << 16;
+			txword |= tor->spans[1].chans[n]->writechunk[i] << 16;
 			/* span 3 */
-			txword |= tor->spans[2].chans[n].writechunk[i] << 8;
+			txword |= tor->spans[2].chans[n]->writechunk[i] << 8;
 			/* span 4 */
-			txword |= tor->spans[3].chans[n].writechunk[i];
+			txword |= tor->spans[3].chans[n]->writechunk[i];
 			/* write to part */
 #ifdef FIXTHISFOR64
 			tor->mem32[tor->datxlt[n] + (32 * i)] = txword;
@@ -1225,13 +1238,13 @@
 			rxword = le32_to_cpu(tor->mem32[tor->datxlt[n] + (32 * i)]);
 #endif
 			/* span 1 */
-			tor->spans[0].chans[n].readchunk[i] = rxword >> 24;
+			tor->spans[0].chans[n]->readchunk[i] = rxword >> 24;
 			/* span 2 */
-			tor->spans[1].chans[n].readchunk[i] = (rxword & 0xff0000) >> 16;
+			tor->spans[1].chans[n]->readchunk[i] = (rxword & 0xff0000) >> 16;
 			/* span 3 */
-			tor->spans[2].chans[n].readchunk[i] = (rxword & 0xff00) >> 8;
+			tor->spans[2].chans[n]->readchunk[i] = (rxword & 0xff00) >> 8;
 			/* span 4 */
-			tor->spans[3].chans[n].readchunk[i] = rxword & 0xff;
+			tor->spans[3].chans[n]->readchunk[i] = rxword & 0xff;
 		}
 	}
 
@@ -1242,16 +1255,16 @@
 			for (k = 1; k <= SPANS_PER_CARD; k++) {
 				c = t1in(tor,k,0x31 + j);
 				rxc = c & 15;
-				if (rxc != tor->spans[k - 1].chans[j + 16].rxsig) {
+				if (rxc != tor->spans[k - 1].chans[j + 16]->rxsig) {
 					/* Check for changes in received bits */
-					if (!(tor->spans[k - 1].chans[j + 16].sig & DAHDI_SIG_CLEAR))
-						dahdi_rbsbits(&tor->spans[k - 1].chans[j + 16], rxc);
+					if (!(tor->spans[k - 1].chans[j + 16]->sig & DAHDI_SIG_CLEAR))
+						dahdi_rbsbits(tor->spans[k - 1].chans[j + 16], rxc);
 				}
 				rxc = c >> 4;
-				if (rxc != tor->spans[k - 1].chans[j].rxsig) {
+				if (rxc != tor->spans[k - 1].chans[j]->rxsig) {
 					/* Check for changes in received bits */
-					if (!(tor->spans[k - 1].chans[j].sig & DAHDI_SIG_CLEAR))
-						dahdi_rbsbits(&tor->spans[k - 1].chans[j], rxc);
+					if (!(tor->spans[k - 1].chans[j]->sig & DAHDI_SIG_CLEAR))
+						dahdi_rbsbits(tor->spans[k - 1].chans[j], rxc);
 				}
 			}
 		}
@@ -1269,10 +1282,10 @@
 			rxc = 0;
 			if (abits & (1 << j)) rxc |= DAHDI_ABIT;
 			if (bbits & (1 << j)) rxc |= DAHDI_BBIT;
-			if (tor->spans[k].chans[i].rxsig != rxc) {
+			if (tor->spans[k].chans[i]->rxsig != rxc) {
 				/* Check for changes in received bits */
-				if (!(tor->spans[k].chans[i].sig & DAHDI_SIG_CLEAR)) {
-					dahdi_rbsbits(&tor->spans[k].chans[i], rxc);
+				if (!(tor->spans[k].chans[i]->sig & DAHDI_SIG_CLEAR)) {
+					dahdi_rbsbits(tor->spans[k].chans[i], rxc);
 				}
 			}
 		}
@@ -1357,8 +1370,8 @@
 			  /* go thru all chans, and count # open */
 			for (n = 0,k = 0; k < tor->spans[i].channels; k++) 
 			   {
-				if (((tor->chans[i] + k)->flags & DAHDI_FLAG_OPEN) ||
-				    ((tor->chans[i] + k)->flags & DAHDI_FLAG_NETDEV)) n++;
+				if (((tor->chans[i][k])->flags & DAHDI_FLAG_OPEN) ||
+				    ((tor->chans[i][k])->flags & DAHDI_FLAG_NETDEV)) n++;
 			   }
 			  /* if none open, set alarm condition */
 			if (!n) j |= DAHDI_ALARM_NOTOPEN; 

Modified: linux/trunk/drivers/dahdi/wct1xxp.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wct1xxp.c?view=diff&rev=4513&r1=4512&r2=4513
==============================================================================
--- linux/trunk/drivers/dahdi/wct1xxp.c (original)
+++ linux/trunk/drivers/dahdi/wct1xxp.c Wed Jul  2 08:31:31 2008
@@ -161,7 +161,7 @@
 	unsigned char ec_chunk2[31][DAHDI_CHUNKSIZE];
 	unsigned char tempo[32];
 	struct dahdi_span span;						/* Span */
-	struct dahdi_chan chans[31];					/* Channels */
+	struct dahdi_chan *chans[31];					/* Channels */
 };
 
 #define CANARY 0xca1e
@@ -272,7 +272,12 @@
 
 static void t1xxp_release(struct t1xxp *wc)
 {
+	unsigned int x;
+
 	dahdi_unregister(&wc->span);
+	for (x = 0; x < (wc->ise1 ? 31 : 24); x++) {
+		kfree(wc->chans[x]);
+	}
 	kfree(wc);
 	printk("Freed a Wildcard\n");
 }
@@ -334,7 +339,7 @@
 	for (x=0;x<3;x++) {
 		b = 0;
 		for (y=0;y<8;y++)
-			if (wc->chans[x * 8 + y].sig & DAHDI_SIG_CLEAR)
+			if (wc->chans[x * 8 + y]->sig & DAHDI_SIG_CLEAR)
 				b |= (1 << y);
 		__t1_set_reg(wc, 0x39 + x, b);
 	}
@@ -555,14 +560,14 @@
 	spin_lock_irqsave(&wc->lock, flags);
 	if (wc->ise1) {
                 if (chan->chanpos < 16) {
-                       mask = ((bits << 4) | wc->chans[chan->chanpos - 1 + 16].txsig);
+                       mask = ((bits << 4) | wc->chans[chan->chanpos - 1 + 16]->txsig);
                         __t1_set_reg(wc, 0x40 + chan->chanpos, mask);
                 }
 		else if (chan->chanpos > 16) {
-			mask = (bits | (wc->chans[chan->chanpos - 1 - 16].txsig << 4));
+			mask = (bits | (wc->chans[chan->chanpos - 1 - 16]->txsig << 4));
 			__t1_set_reg(wc, 0x40 + chan->chanpos - 16, mask);
 		}
-		wc->chans[chan->chanpos - 1].txsig = bits;
+		wc->chans[chan->chanpos - 1]->txsig = bits;
 	} else {
 		b = (chan->chanpos - 1) / 8;
 		o = (chan->chanpos - 1) % 8;
@@ -610,9 +615,9 @@
 	for(i = 0; i < span->channels; i++)
 	{
 		memset(wc->ec_chunk1[i],
-			DAHDI_LIN2X(0,&span->chans[i]),DAHDI_CHUNKSIZE);
+			DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE);
 		memset(wc->ec_chunk2[i],
-			DAHDI_LIN2X(0,&span->chans[i]),DAHDI_CHUNKSIZE);
+			DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE);
 	}
 
 	/* Reset framer with proper parameters and start */
@@ -781,13 +786,13 @@
 	}
 	init_waitqueue_head(&wc->span.maintq);
 	for (x=0;x<wc->span.channels;x++) {
-		sprintf(wc->chans[x].name, "WCT1/%d/%d", wc->num, x + 1);
-		wc->chans[x].sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_EM_E1 | 
+		sprintf(wc->chans[x]->name, "WCT1/%d/%d", wc->num, x + 1);
+		wc->chans[x]->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_EM_E1 | 
 				      DAHDI_SIG_FXSLS | DAHDI_SIG_FXSGS | 
 				      DAHDI_SIG_FXSKS | DAHDI_SIG_FXOLS | DAHDI_SIG_DACS_RBS |
 				      DAHDI_SIG_FXOGS | DAHDI_SIG_FXOKS | DAHDI_SIG_CAS | DAHDI_SIG_SF;
-		wc->chans[x].pvt = wc;
-		wc->chans[x].chanpos = x + 1;
+		wc->chans[x]->pvt = wc;
+		wc->chans[x]->chanpos = x + 1;
 	}
 	if (dahdi_register(&wc->span, 0)) {
 		printk("Unable to register span with DAHDI\n");
@@ -870,9 +875,9 @@
 			pos = y * 32 + wc->chanmap[x] + wc->offset;
 			/* Put channel number as outgoing data */
 			if (pos < 32 * DAHDI_CHUNKSIZE)
-				txbuf[pos] = wc->chans[x].writechunk[y];
+				txbuf[pos] = wc->chans[x]->writechunk[y];
 			else
-				wc->tempo[pos - 32 * DAHDI_CHUNKSIZE] = wc->chans[x].writechunk[y];
+				wc->tempo[pos - 32 * DAHDI_CHUNKSIZE] = wc->chans[x]->writechunk[y];
 		}
 	}
 }
@@ -905,7 +910,7 @@
 		for (x=0;x<wc->span.channels;x++) {
 			/* XXX Optimize, remove * and + XXX */
 			/* Must map received channels into appropriate data */
-			wc->chans[x].readchunk[y] = 
+			wc->chans[x]->readchunk[y] = 
 				rxbuf[32 * y + ((wc->chanmap[x] + WC_OFFSET + wc->offset) & 0x1f)];
 		}
 		if (!wc->ise1) {
@@ -944,10 +949,9 @@
 	canary = (unsigned int *)(rxbuf + DAHDI_CHUNKSIZE * 32 - 4);
 	*canary = (wc->canary++) | (CANARY << 16);
 	for (x=0;x<wc->span.channels;x++) {
-		dahdi_ec_chunk(&wc->chans[x], wc->chans[x].readchunk, 
-			wc->ec_chunk2[x]);
+		dahdi_ec_chunk(wc->chans[x], wc->chans[x]->readchunk, wc->ec_chunk2[x]);
 		memcpy(wc->ec_chunk2[x],wc->ec_chunk1[x],DAHDI_CHUNKSIZE);
-		memcpy(wc->ec_chunk1[x],wc->chans[x].writechunk,DAHDI_CHUNKSIZE);
+		memcpy(wc->ec_chunk1[x],wc->chans[x]->writechunk,DAHDI_CHUNKSIZE);
 	}
 	dahdi_receive(&wc->span);
 }
@@ -964,18 +968,18 @@
 			a = __t1_get_reg(wc, 0x31 + i);
 			/* Get high channel in low bits */
 			rxs = (a & 0xf);
-			if (!(wc->chans[i+16].sig & DAHDI_SIG_CLEAR)) {
-				if (wc->chans[i+16].rxsig != rxs) {
+			if (!(wc->chans[i+16]->sig & DAHDI_SIG_CLEAR)) {
+				if (wc->chans[i+16]->rxsig != rxs) {
 					spin_unlock_irqrestore(&wc->lock, flags);
-					dahdi_rbsbits(&wc->chans[i+16], rxs);
+					dahdi_rbsbits(wc->chans[i+16], rxs);
 					spin_lock_irqsave(&wc->lock, flags);
 				}
 			}
 			rxs = (a >> 4) & 0xf;
-			if (!(wc->chans[i].sig & DAHDI_SIG_CLEAR)) {
-				if (wc->chans[i].rxsig != rxs) {
+			if (!(wc->chans[i]->sig & DAHDI_SIG_CLEAR)) {
+				if (wc->chans[i]->rxsig != rxs) {
 					spin_unlock_irqrestore(&wc->lock, flags);
-					dahdi_rbsbits(&wc->chans[i], rxs);
+					dahdi_rbsbits(wc->chans[i], rxs);
 					spin_lock_irqsave(&wc->lock, flags);
 				}
 			}
@@ -990,10 +994,10 @@
 				rxs |= DAHDI_ABIT;
 			if (b & (1 << y))
 				rxs |= DAHDI_BBIT;
-			if (!(wc->chans[i].sig & DAHDI_SIG_CLEAR)) {
-				if (wc->chans[i].rxsig != rxs) {
+			if (!(wc->chans[i]->sig & DAHDI_SIG_CLEAR)) {
+				if (wc->chans[i]->rxsig != rxs) {
 					spin_unlock_irqrestore(&wc->lock, flags);
-					dahdi_rbsbits(&wc->chans[i], rxs);
+					dahdi_rbsbits(wc->chans[i], rxs);
 					spin_lock_irqsave(&wc->lock, flags);
 				}
 			}
@@ -1058,8 +1062,8 @@
 
 	if (wc->span.lineconfig & DAHDI_CONFIG_NOTOPEN) {
 		for (x=0,j=0;x < wc->span.channels;x++)
-			if ((wc->chans[x].flags & DAHDI_FLAG_OPEN) ||
-			    (wc->chans[x].flags & DAHDI_FLAG_NETDEV))
+			if ((wc->chans[x]->flags & DAHDI_FLAG_OPEN) ||
+			    (wc->chans[x]->flags & DAHDI_FLAG_NETDEV))
 				j++;
 		if (!j)
 			alarms |= DAHDI_ALARM_NOTOPEN;
@@ -1266,71 +1270,85 @@
 
 static int __devinit t1xxp_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	int res;
 	struct t1xxp *wc;
 	unsigned int *canary;
-	
-	if (pci_enable_device(pdev)) {
-		res = -EIO;
-	} else {
-		wc = kmalloc(sizeof(struct t1xxp), GFP_KERNEL);
-		if (wc) {
-			memset(wc, 0x0, sizeof(struct t1xxp));
-			spin_lock_init(&wc->lock);
-			wc->ioaddr = pci_resource_start(pdev, 0);
-			wc->dev = pdev;
-			wc->offset = 28;	/* And you thought 42 was the answer */
-
-			wc->writechunk = 
-				/* 32 channels, Double-buffer, Read/Write */
-				(unsigned char *)pci_alloc_consistent(pdev, DAHDI_MAX_CHUNKSIZE * 32 * 2 * 2, &wc->writedma);
-			if (!wc->writechunk) {
-				printk("wct1xxp: Unable to allocate DMA-able memory\n");
-				return -ENOMEM;
+	unsigned int x;
+	
+	if (!pci_enable_device(pdev)) {
+		return -EIO;
+	}
+
+	if (!(wc = kmalloc(sizeof(*wc), GFP_KERNEL))) {
+		return -ENOMEM;
+	}
+
+	memset(wc, 0x0, sizeof(*wc));
+	spin_lock_init(&wc->lock);
+	wc->ioaddr = pci_resource_start(pdev, 0);
+	wc->dev = pdev;
+	wc->offset = 28;	/* And you thought 42 was the answer */
+	
+	wc->writechunk = 
+		/* 32 channels, Double-buffer, Read/Write */
+		(unsigned char *)pci_alloc_consistent(pdev, DAHDI_MAX_CHUNKSIZE * 32 * 2 * 2, &wc->writedma);
+	if (!wc->writechunk) {
+		printk("wct1xxp: Unable to allocate DMA-able memory\n");
+		return -ENOMEM;
+	}
+	
+	/* Read is after the whole write piece (in bytes) */
+	wc->readchunk = wc->writechunk + DAHDI_CHUNKSIZE * 32 * 2;
+	
+	/* Same thing...  */
+	wc->readdma = wc->writedma + DAHDI_CHUNKSIZE * 32 * 2;
+	
+	/* Initialize Write/Buffers to all blank data */
+	memset((void *)wc->writechunk,0x00,DAHDI_MAX_CHUNKSIZE * 2 * 2 * 32);
+	/* Initialize canary */
+	canary = (unsigned int *)(wc->readchunk + DAHDI_CHUNKSIZE * 64 - 4);
+	*canary = (CANARY << 16) | (0xffff);
+	
+	/* Enable bus mastering */
+	pci_set_master(pdev);
+	
+	/* Keep track of which device we are */
+	pci_set_drvdata(pdev, wc);
+	
+	if (request_irq(pdev->irq, t1xxp_interrupt, DAHDI_IRQ_SHARED_DISABLED, "t1xxp", wc)) {
+		printk("t1xxp: Unable to request IRQ %d\n", pdev->irq);
+		kfree(wc);
+		return -EIO;
+	}
+	/* Initialize hardware */
+	t1xxp_hardware_init(wc);
+	
+	/* We now know which version of card we have */
+	if (wc->ise1) {
+		wc->variety = "Digium Wildcard E100P E1/PRA";
+	} else {
+		wc->variety = "Digium Wildcard T100P T1/PRI";
+	}
+
+	for (x = 0; x < (wc->ise1 ? 31 : 24); x++) {
+		if (!(wc->chans[x] = kmalloc(sizeof(*wc->chans[x]), GFP_KERNEL))) {
+			while (x) {
+				kfree(wc->chans[--x]);
 			}
 
-			/* Read is after the whole write piece (in bytes) */
-			wc->readchunk = wc->writechunk + DAHDI_CHUNKSIZE * 32 * 2;
-
-			/* Same thing...  */
-			wc->readdma = wc->writedma + DAHDI_CHUNKSIZE * 32 * 2;
-
-			/* Initialize Write/Buffers to all blank data */
-			memset((void *)wc->writechunk,0x00,DAHDI_MAX_CHUNKSIZE * 2 * 2 * 32);
-			/* Initialize canary */
-			canary = (unsigned int *)(wc->readchunk + DAHDI_CHUNKSIZE * 64 - 4);
-			*canary = (CANARY << 16) | (0xffff);
-
-			/* Enable bus mastering */
-			pci_set_master(pdev);
-
-			/* Keep track of which device we are */
-			pci_set_drvdata(pdev, wc);
-
-			if (request_irq(pdev->irq, t1xxp_interrupt, DAHDI_IRQ_SHARED_DISABLED, "t1xxp", wc)) {
-				printk("t1xxp: Unable to request IRQ %d\n", pdev->irq);
-				kfree(wc);
-				return -EIO;
-			}
-			/* Initialize hardware */
-			t1xxp_hardware_init(wc);
-
-			/* We now know which version of card we have */
-			if (wc->ise1)
-				wc->variety = "Digium Wildcard E100P E1/PRA";
-			else
-				wc->variety = "Digium Wildcard T100P T1/PRI";
-
-			/* Misc. software stuff */
-			t1xxp_software_init(wc);
-
-			printk("Found a Wildcard: %s\n", wc->variety);
-			res = 0;
-		} else
-			res = -ENOMEM;
-	}
-	return res;
-}
+			kfree(wc);
+			return -ENOMEM;
+		}
+		memset(wc->chans[x], 0, sizeof(*wc->chans[x]));
+	}
+
+	/* Misc. software stuff */
+	t1xxp_software_init(wc);
+	
+	printk("Found a Wildcard: %s\n", wc->variety);
+
+	return 0;
+}
+
 
 static void t1xxp_stop_stuff(struct t1xxp *wc)
 {

Modified: linux/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=4513&r1=4512&r2=4513
==============================================================================
--- linux/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wct4xxp/base.c Wed Jul  2 08:31:31 2008
@@ -282,7 +282,7 @@
 #ifdef ENABLE_WORKQUEUES
 	struct work_struct swork;
 #endif	
-	struct dahdi_chan chans[0];		/* Individual channels */
+	struct dahdi_chan *chans[32];		/* Individual channels */
 };
 
 struct t4 {
@@ -743,7 +743,7 @@
 					   guessed it.  */
 					if (test_bit(channel, &wc->tspans[span]->dtmfmutemask)) {
 						unsigned long flags;
-						struct dahdi_chan *chan = &wc->tspans[span]->span.chans[channel];
+						struct dahdi_chan *chan = wc->tspans[span]->span.chans[channel];
 						int y;
 						spin_lock_irqsave(&chan->lock, flags);
 						for (y=0;y<chan->numbufs;y++) {
@@ -753,10 +753,10 @@
 						spin_unlock_irqrestore(&chan->lock, flags);
 					}
 					set_bit(channel, &wc->tspans[span]->dtmfactive);
-					dahdi_qevent_lock(&wc->tspans[span]->span.chans[channel], (DAHDI_EVENT_DTMFDOWN | tone));
+					dahdi_qevent_lock(wc->tspans[span]->span.chans[channel], (DAHDI_EVENT_DTMFDOWN | tone));
 				} else {
 					clear_bit(channel, &wc->tspans[span]->dtmfactive);
-					dahdi_qevent_lock(&wc->tspans[span]->span.chans[channel], (DAHDI_EVENT_DTMFUP | tone));
+					dahdi_qevent_lock(wc->tspans[span]->span.chans[channel], (DAHDI_EVENT_DTMFUP | tone));
 				}
 			}
 		}
@@ -800,21 +800,21 @@
 				digit = vpm_digits[regbyte];
 				if (!(wc->tspans[0]->spanflags & FLAG_VPM2GEN)) {
 					energy = t4_vpm_in(wc, x, 0x58 + channel);
-					energy = DAHDI_XLAW(energy, ts->chans);
+					energy = DAHDI_XLAW(energy, ts->chans[0]);
 					ts->dtmfenergy[base] = energy;
 				}
 				set_bit(base, &ts->dtmfactive);
 				if (ts->dtmfdigit[base]) {
 					if (ts->dtmfmask & (1 << base))
-						dahdi_qevent_lock(&ts->span.chans[base], (DAHDI_EVENT_DTMFUP | ts->dtmfdigit[base]));
+						dahdi_qevent_lock(ts->span.chans[base], (DAHDI_EVENT_DTMFUP | ts->dtmfdigit[base]));
 				}
 				ts->dtmfdigit[base] = digit;
 				if (test_bit(base, &ts->dtmfmask))
-					dahdi_qevent_lock(&ts->span.chans[base], (DAHDI_EVENT_DTMFDOWN | digit));
+					dahdi_qevent_lock(ts->span.chans[base], (DAHDI_EVENT_DTMFDOWN | digit));
 				if (test_bit(base, &ts->dtmfmutemask)) {
 					/* Mute active receive buffer*/
 					unsigned long flags;
-					struct dahdi_chan *chan = &ts->span.chans[base];
+					struct dahdi_chan *chan = ts->span.chans[base];
 					int y;
 					spin_lock_irqsave(&chan->lock, flags);
 					for (y=0;y<chan->numbufs;y++) {
@@ -850,7 +850,7 @@
 				clear_bit(base, &ts->dtmfactive);
 				if (ts->dtmfdigit[base]) {
 					if (test_bit(base, &ts->dtmfmask))
-						dahdi_qevent_lock(&ts->span.chans[base], (DAHDI_EVENT_DTMFUP | ts->dtmfdigit[base]));
+						dahdi_qevent_lock(ts->span.chans[base], (DAHDI_EVENT_DTMFUP | ts->dtmfdigit[base]));
 				}
 				digit = ts->dtmfdigit[base];
 				ts->dtmfdigit[base] = 0;
@@ -982,7 +982,7 @@
 	if ((ts->spantype == TYPE_T1) || (ts->spantype == TYPE_J1)) {
 		for (i=0;i<24;i++) {
 			j = (i/8);
-			if (ts->span.chans[i].flags & DAHDI_FLAG_CLEAR) {
+			if (ts->span.chans[i]->flags & DAHDI_FLAG_CLEAR) {
 				val |= 1 << (7 - (i % 8));
 				ts->notclear &= ~(1 << i);
 			} else
@@ -997,7 +997,7 @@
 		}
 	} else {
 		for (i=0;i<31;i++) {
-			if (ts->span.chans[i].flags & DAHDI_FLAG_CLEAR)
+			if (ts->span.chans[i]->flags & DAHDI_FLAG_CLEAR)
 				ts->notclear &= ~(1 << i);
 			else 
 				ts->notclear |= (1 << i);
@@ -1603,7 +1603,7 @@
 		ts->readchunk = (void *)(wc->readchunk + x * 32 * 2);
 		init_waitqueue_head(&ts->span.maintq);
 		for (y=0;y<wc->tspans[x]->span.channels;y++) {
-			struct dahdi_chan *mychans = ts->chans + y;
+			struct dahdi_chan *mychans = ts->chans[y];
 			sprintf(mychans->name, "TE%d/%d/%d/%d", wc->numspans, wc->num, x + 1, y + 1);
 			mychans->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR | DAHDI_SIG_FXSLS | DAHDI_SIG_FXSGS | DAHDI_SIG_FXSKS | DAHDI_SIG_HARDHDLC | DAHDI_SIG_MTP2 |
 									 DAHDI_SIG_FXOLS | DAHDI_SIG_FXOGS | DAHDI_SIG_FXOKS | DAHDI_SIG_CAS | DAHDI_SIG_EM_E1 | DAHDI_SIG_DACS_RBS;
@@ -2011,9 +2011,9 @@
 	for(i = 0; i < span->channels; i++)
 	{
 		memset(ts->ec_chunk1[i],
-			DAHDI_LIN2X(0,&span->chans[i]),DAHDI_CHUNKSIZE);
+			DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE);
 		memset(ts->ec_chunk2[i],
-			DAHDI_LIN2X(0,&span->chans[i]),DAHDI_CHUNKSIZE);
+			DAHDI_LIN2X(0,span->chans[i]),DAHDI_CHUNKSIZE);
 	}
 #endif
 	/* Force re-evaluation fo timing source */
@@ -2146,11 +2146,11 @@
 			/* All T1/E1 channels */
 			tmp = readchunk[z+1+offset];
 			if (wc->numspans == 4) {
-				wc->tspans[3]->span.chans[z].readchunk[x] = tmp & 0xff;
-				wc->tspans[2]->span.chans[z].readchunk[x] = (tmp & 0xff00) >> 8;
+				wc->tspans[3]->span.chans[z]->readchunk[x] = tmp & 0xff;
+				wc->tspans[2]->span.chans[z]->readchunk[x] = (tmp & 0xff00) >> 8;
 			}
-			wc->tspans[1]->span.chans[z].readchunk[x] = (tmp & 0xff0000) >> 16;
-			wc->tspans[0]->span.chans[z].readchunk[x] = tmp >> 24;
+			wc->tspans[1]->span.chans[z]->readchunk[x] = (tmp & 0xff0000) >> 16;
+			wc->tspans[0]->span.chans[z]->readchunk[x] = tmp >> 24;
 		}
 		if (wc->t1e1) {
 			if (wc->e1recover > 0)
@@ -2167,14 +2167,14 @@
 				tmp = readchunk[z+1];
 				if (wc->numspans == 4) {
 					if (wc->tspans[3]->span.channels > 24)
-						wc->tspans[3]->span.chans[z].readchunk[x] = tmp & 0xff;
+						wc->tspans[3]->span.chans[z]->readchunk[x] = tmp & 0xff;
 					if (wc->tspans[2]->span.channels > 24)
-						wc->tspans[2]->span.chans[z].readchunk[x] = (tmp & 0xff00) >> 8;
+						wc->tspans[2]->span.chans[z]->readchunk[x] = (tmp & 0xff00) >> 8;
 				}
 				if (wc->tspans[1]->span.channels > 24)
-					wc->tspans[1]->span.chans[z].readchunk[x] = (tmp & 0xff0000) >> 16;
+					wc->tspans[1]->span.chans[z]->readchunk[x] = (tmp & 0xff0000) >> 16;
 				if (wc->tspans[0]->span.channels > 24)
-					wc->tspans[0]->span.chans[z].readchunk[x] = tmp >> 24;
+					wc->tspans[0]->span.chans[z]->readchunk[x] = tmp >> 24;
 			}
 		}
 		/* Advance pointer by 4 TDM frame lengths */
@@ -2184,13 +2184,13 @@
 		if (wc->tspans[x]->span.flags & DAHDI_FLAG_RUNNING) {
 			for (y=0;y<wc->tspans[x]->span.channels;y++) {
 				/* Echo cancel double buffered data */
-				dahdi_ec_chunk(&wc->tspans[x]->span.chans[y], 
-				    wc->tspans[x]->span.chans[y].readchunk, 
+				dahdi_ec_chunk(wc->tspans[x]->span.chans[y], 
+				    wc->tspans[x]->span.chans[y]->readchunk, 
 					wc->tspans[x]->ec_chunk2[y]);
 				memcpy(wc->tspans[x]->ec_chunk2[y],wc->tspans[x]->ec_chunk1[y],
 					DAHDI_CHUNKSIZE);
 				memcpy(wc->tspans[x]->ec_chunk1[y],
-					wc->tspans[x]->span.chans[y].writechunk,
+					wc->tspans[x]->span.chans[y]->writechunk,
 						DAHDI_CHUNKSIZE);
 			}
 			dahdi_receive(&wc->tspans[x]->span);
@@ -2213,7 +2213,7 @@
 		for (y=0;y<ts->span.channels;y++) {
 			/* Mute any DTMFs which are supposed to be muted */
 			if (test_bit(y, &merged)) {
-				memset(ts->span.chans[y].readchunk, DAHDI_XLAW(0, (ts->span.chans + y)), DAHDI_CHUNKSIZE);
+				memset(ts->span.chans[y]->readchunk, DAHDI_XLAW(0, ts->span.chans[y]), DAHDI_CHUNKSIZE);
 			}
 		}
 	}
@@ -2296,10 +2296,10 @@
 		/* Once per chunk */
 		for (z=0;z<24;z++) {
 			/* All T1/E1 channels */
-			tmp = (wc->tspans[3]->span.chans[z].writechunk[x]) | 
-				  (wc->tspans[2]->span.chans[z].writechunk[x] << 8) |
-				  (wc->tspans[1]->span.chans[z].writechunk[x] << 16) |
-				  (wc->tspans[0]->span.chans[z].writechunk[x] << 24);
+			tmp = (wc->tspans[3]->span.chans[z]->writechunk[x]) | 
+				  (wc->tspans[2]->span.chans[z]->writechunk[x] << 8) |
+				  (wc->tspans[1]->span.chans[z]->writechunk[x] << 16) |

[... 1612 lines stripped ...]



More information about the svn-commits mailing list