[svn-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder r2005 - /team/mogorman/zapte...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Jan 29 14:10:04 MST 2007


Author: kpfleming
Date: Mon Jan 29 15:10:04 2007
New Revision: 2005

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2005
Log:
don't treat the read/write buffers as u32 when they are really u8
there is no need to memset() the read/write buffers to zeroes, as the actual read/write operations will write over every used byte anyway

Modified:
    team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c

Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c?view=diff&rev=2005&r1=2004&r2=2005
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c Mon Jan 29 15:10:04 2007
@@ -318,9 +318,9 @@
 	dma_addr_t readdma;
 	dma_addr_t writedma;
 	dma_addr_t descripdma;
-	volatile u32 *writechunk;					/* Double-word aligned write memory */
-	volatile u32 *readchunk;					/* Double-word aligned read memory */
-	volatile u32 *descripchunk;					/* Descriptors */
+	volatile u8 *writechunk;		/* write buffers */
+	volatile u8 *readchunk;			/* read buffers */
+	volatile u32 *descripchunk;		/* descriptors */
 	
 	int wqueints;
 	struct workqueue_struct *dte_wq;
@@ -452,16 +452,10 @@
 
 static inline void __transmit_one(struct wcdte *wc, u8 *data, u32 length)
 {
-	volatile u8 *writechunk;
-	u32 o2;
+	u32 o2 = wc->tdbl * 4;
+	volatile u8 *writechunk = wc->writechunk + (o2 * SFRAME_SIZE);
 	u32 xmt_length;
 
-	writechunk = (volatile u8 *) (wc->writechunk);
-
-	writechunk += wc->tdbl * SFRAME_SIZE;
-
-	o2 = wc->tdbl * 4;
-		
 	/* Yes... this is a busy loop, that is not interruptible. However, it is
 	   highly unlikely (and testing proves) that the wait for a descriptor
 	   to become available will ever be long enough for this to be an issue.
@@ -472,9 +466,9 @@
 
 	wc->descripchunk[o2 + 1] = cpu_to_le32((le32_to_cpu(wc->descripchunk[o2 + 1]) & 0xFBFFF800) | xmt_length);
 				
-	memcpy((u8 *) writechunk, data, length);
+	memcpy((void *) writechunk, data, length);
 	if (length < xmt_length)
-		memset((u8 *) writechunk + length, 0, xmt_length - length);
+		memset((void *) writechunk + length, 0, xmt_length - length);
 
 	wc->descripchunk[o2] = cpu_to_le32(0x80000000);
 	setctl(wc, 0x0008, 0x00000000);			/* Transmit Poll Demand */
@@ -715,7 +709,7 @@
 
 static inline void receiveprep(struct wcdte *wc, int dbl)
 {
-	volatile u8 *readchunk;
+	volatile u8 *readchunk = wc->readchunk + (dbl * SFRAME_SIZE * 4);
 	struct zt_transcoder_channel *ztc = NULL;
 	struct zt_transcode_header *zth = NULL;
 	struct dte_state *st = NULL;
@@ -724,9 +718,6 @@
 	unsigned int rcommand, rchannel, rlen, rtp_rseq, rtp_eseq;
 	u8 *chars = NULL;
 	unsigned int ztc_ndx;
-
-	readchunk = (volatile u8 *) wc->readchunk;
-	readchunk += dbl * SFRAME_SIZE;
 
 	o2 = dbl * 4;
 	o2 += ERING_SIZE * 4;
@@ -1369,7 +1360,7 @@
 		wc->freeregion = 1;
 	
 	/* Allocate enough memory for all TX buffers, RX buffers, and descriptors */
-	wc->writechunk = (int *) pci_alloc_consistent(pdev, PCI_WINDOW_SIZE, &wc->writedma);
+	wc->writechunk = pci_alloc_consistent(pdev, PCI_WINDOW_SIZE, &wc->writedma);
 	if (!wc->writechunk) {
 		module_printk("Unable to allocate DMA-able memory\n");
 		if (wc->freeregion)
@@ -1378,15 +1369,11 @@
 		return -ENOMEM;
 	}
 	
-	wc->readchunk = wc->writechunk + (SFRAME_SIZE * ERING_SIZE) / 4;	/* in doublewords */
-	wc->readdma = wc->writedma + (SFRAME_SIZE * ERING_SIZE);		/* in bytes */
-	
-	wc->descripchunk = wc->readchunk + (SFRAME_SIZE * ERING_SIZE) / 4;	/* in doublewords */
-	wc->descripdma = wc->readdma + (SFRAME_SIZE * ERING_SIZE);		/* in bytes */
-	
-	/* Initialize Write/Buffers to all blank data */
-	memset((void *) wc->writechunk, 0x00, SFRAME_SIZE * 2);
-	memset((void *) wc->readchunk, 0x00, SFRAME_SIZE * 2);
+	wc->readchunk = wc->writechunk + (SFRAME_SIZE * ERING_SIZE);
+	wc->readdma = wc->writedma + (SFRAME_SIZE * ERING_SIZE);
+	
+	wc->descripchunk = (u32 *) (wc->readchunk + (SFRAME_SIZE * ERING_SIZE));
+	wc->descripdma = wc->readdma + (SFRAME_SIZE * ERING_SIZE);
 	
 	init_waitqueue_head(&wc->regq);
 	



More information about the svn-commits mailing list