[dahdi-commits] rmeyerriecks: branch linux/mspiceland/dahdi-qfalc31 r7915 - in /linux/team/ms...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Wed Jan 13 16:33:57 CST 2010


Author: rmeyerriecks
Date: Wed Jan 13 16:33:55 2010
New Revision: 7915

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7915
Log:
Merged revisions 7778-7779,7807,7815,7843,7850,7867,7883 via svnmerge from 
https://origsvn.digium.com/svn/dahdi/linux/trunk

........
  r7778 | sruffell | 2010-01-08 14:48:02 -0600 (Fri, 08 Jan 2010) | 6 lines
  
  voicebus: Make 'struct voicebus' embeddable by the client driver strutures.
  
  In addition to making 'struct voicebus' embeddable, also add an
  'voicebus_operations' structure.  This was done so that a) remove the "context"
  pointer from struct voicebus, and also to show that handle_recieve/transmit are
  to be managed together.
........
  r7779 | sruffell | 2010-01-08 14:48:03 -0600 (Fri, 08 Jan 2010) | 7 lines
  
  voicebus: Remove framesize, buffer_cache, and cache_line members from struct.
  
  Framesize is the same on all the clients, so it can be removed from the 'struct
  voicebus' (and changed back again if needed).  Since the framesize is the same,
  each board doesn't need it's own buffer_cache, and cache_line is only used
  during startup and can be read directly from pci configuration space, so we
  don't need to keep it around in our context.
........
  r7807 | tzafrir | 2010-01-10 03:53:34 -0600 (Sun, 10 Jan 2010) | 7 lines
  
  xpp: fixes for drift calculation.
  
  Should help for the case of multiple quad-PRI Astribanks on a single
  system.
  
  xpp rev: 7666.
........
  r7815 | tzafrir | 2010-01-10 05:27:25 -0600 (Sun, 10 Jan 2010) | 4 lines
  
  xpp: USB_FW rev 7578
  
  Fixes various minor twinstar-related bugs.
........
  r7843 | tzafrir | 2010-01-11 07:18:10 -0600 (Mon, 11 Jan 2010) | 2 lines
  
  xpp: demote a message that generates some false alarms.
........
  r7850 | tzafrir | 2010-01-11 08:50:04 -0600 (Mon, 11 Jan 2010) | 2 lines
  
  Fail gracefully if we already have more than 1024 channels.
........
  r7867 | tzafrir | 2010-01-11 11:47:11 -0600 (Mon, 11 Jan 2010) | 2 lines
  
  live_dahdi: just make sure we have crc_ccitt on the system.
........
  r7883 | tzafrir | 2010-01-12 04:08:32 -0600 (Tue, 12 Jan 2010) | 5 lines
  
  xpp: xpd_fxo: two extra parameters regarding battery
  
  Make module parameters out of two constants to allow further tweaking in
  the detection of battery.
........

Modified:
    linux/team/mspiceland/dahdi-qfalc31/   (props changed)
    linux/team/mspiceland/dahdi-qfalc31/build_tools/live_dahdi
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/dahdi-base.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/GpakCust.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.h
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/vpmadtreg.h
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/base.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wcte12xp/base.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wcte12xp/wcte12xp.h
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/xpp/card_fxo.c
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/xpp/firmwares/USB_FW.hex
    linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/xpp/xbus-pcm.c

Propchange: linux/team/mspiceland/dahdi-qfalc31/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jan 13 16:33:55 2010
@@ -1,1 +1,1 @@
-/linux/trunk:1-7774
+/linux/trunk:1-7914

Modified: linux/team/mspiceland/dahdi-qfalc31/build_tools/live_dahdi
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/build_tools/live_dahdi?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/build_tools/live_dahdi (original)
+++ linux/team/mspiceland/dahdi-qfalc31/build_tools/live_dahdi Wed Jan 13 16:33:55 2010
@@ -196,6 +196,7 @@
 	# TODO: Find a way to use modprobe.
 	# Or implement a way to pass arguments to modules here (yuck)
 	set_modules_to_load
+	modprobe crc_ccitt || : # FIXME: Make this optional?
 	for module in $MODULES_LOAD; do
 		eval module_args="\$`basename ${module}`_ARGS"
 		insmod $MODULES_DIR/$module.ko $module_args

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/dahdi-base.c?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/dahdi-base.c Wed Jan 13 16:33:55 2010
@@ -5723,6 +5723,7 @@
 int dahdi_register(struct dahdi_span *span, int prefmaster)
 {
 	int x;
+	int res = 0;
 
 	if (!span)
 		return -EINVAL;
@@ -5768,7 +5769,12 @@
 
 	for (x = 0; x < span->channels; x++) {
 		span->chans[x]->span = span;
-		dahdi_chan_reg(span->chans[x]);
+		res = dahdi_chan_reg(span->chans[x]);
+		if (res) {
+			for (x--; x >= 0; x--)
+				dahdi_chan_unreg(span->chans[x]);
+			goto unreg_channels;
+		}
 	}
 
 #ifdef CONFIG_PROC_FS
@@ -5804,6 +5810,10 @@
 	}
 
 	return 0;
+
+unreg_channels:
+	spans[span->spanno] = NULL;
+	return res;
 }
 
 

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/GpakCust.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/GpakCust.c?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/GpakCust.c (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/GpakCust.c Wed Jan 13 16:33:55 2010
@@ -54,7 +54,7 @@
 static struct vpmadt032 *ifaces[MAX_DSP_CORES];
 
 #define vpm_info(vpm, format, arg...)         \
-        dev_info(&voicebus_get_pci_dev(vpm->vb)->dev , format , ## arg)
+	dev_info(&vpm->vb->pdev->dev , format , ## arg)
 
 static inline struct vpmadt032 *find_iface(const unsigned short dspid)
 {
@@ -609,13 +609,12 @@
 
 	res = vpmadtreg_loadfirmware(vb);
 	if (res) {
-		struct pci_dev *pdev = voicebus_get_pci_dev(vb);
-		dev_printk(KERN_INFO, &pdev->dev, "Failed to load the firmware.\n");
+		dev_info(&vb->pdev->dev, "Failed to load the firmware.\n");
 		return res;
 	}
 	vpm->curpage = -1;
 
-	dev_info(&voicebus_get_pci_dev(vb)->dev, "Booting VPMADT032\n");
+	dev_info(&vb->pdev->dev, "Booting VPMADT032\n");
 	set_bit(VPM150M_SWRESET, &vpm->control);
 	while (test_bit(VPM150M_SWRESET, &vpm->control))
 		msleep(1);

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.c Wed Jan 13 16:33:55 2010
@@ -41,33 +41,17 @@
 #include "vpmadtreg.h"
 #include "GpakCust.h"
 
-#define INTERRUPT 0	/* Run the deferred processing in the ISR. */
-#define TASKLET 1	/* Run in a tasklet. */
-#define TIMER 2		/* Run in a system timer. */
-#define WORKQUEUE 3	/* Run in a workqueue. */
-#ifndef VOICEBUS_DEFERRED
-#define VOICEBUS_DEFERRED INTERRUPT
-#endif
 #if VOICEBUS_DEFERRED == WORKQUEUE
 #define VOICEBUS_ALLOC_FLAGS GFP_KERNEL
 #else
 #define VOICEBUS_ALLOC_FLAGS GFP_ATOMIC
 #endif
 
-/* Define CONFIG_VOICEBUS_SYSFS to create some attributes under the pci device.
- * This is disabled by default because it hasn't been tested on the full range
- * of supported kernels. */
-#undef CONFIG_VOICEBUS_SYSFS
-
 #if VOICEBUS_DEFERRED == TIMER
 #if HZ < 1000
 /* \todo Put an error message here. */
 #endif
 #endif
-
-/*! The number of descriptors in both the tx and rx descriptor ring. */
-#define DRING_SIZE	(1 << 7)  /* Must be a power of 2 */
-#define DRING_MASK	(DRING_SIZE-1)
 
 /* Interrupt status' reported in SR_CSR5 */
 #define TX_COMPLETE_INTERRUPT 		0x00000001
@@ -111,6 +95,12 @@
 
 #define OWN_BIT (1 << 31)
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static kmem_cache_t *buffer_cache;
+#else
+static struct kmem_cache *buffer_cache;
+#endif
+
 /* In memory structure shared by the host and the adapter. */
 struct voicebus_descriptor {
 	volatile __le32 des0;
@@ -119,90 +109,9 @@
 	volatile __le32 container; /* Unused */
 } __attribute__((packed));
 
-struct voicebus_descriptor_list {
-	/* Pointer to an array of descriptors to give to hardware. */
-	struct voicebus_descriptor *desc;
-	/* Read completed buffers from the head. */
-	unsigned int 	head;
-	/* Write ready buffers to the tail. */
-	unsigned int 	tail;
-	/* Array to save the kernel virtual address of pending buffers. */
-	void  		*pending[DRING_SIZE];
-	/* PCI Bus address of the descriptor list. */
-	dma_addr_t	desc_dma;
-	/*! The number of buffers currently submitted to the hardware. */
-	atomic_t 	count;
-	/*! The number of bytes to pad each descriptor for cache alignment. */
-	unsigned int	padding;
-};
-
-/**
- * struct voicebus -
- *
- * @tx_idle_vbb:
- * @tx_idle_vbb_dma_addr:
- * @max_latency: Do not allow the driver to automatically insert more than this
- * 		 much latency to the tdm stream by default.
- * @count:	The number of non-idle buffers that we should be expecting.
- */
-struct voicebus {
-	/*! The system pci device for this VoiceBus interface. */
-	struct pci_dev *pdev;
-	/*! Protects access to card registers and this structure. You should
-	 * hold this lock before accessing most of the members of this data
-	 * structure or the card registers. */
-	spinlock_t lock;
-	/*! The size of the transmit and receive buffers for this card. */
-	u32 framesize;
-	/*! The number of u32s in the host system cache line. */
-	u8 cache_line_size;
-	/*! Pool to allocate memory for the tx and rx descriptor rings. */
-	struct voicebus_descriptor_list rxd;
-	struct voicebus_descriptor_list txd;
-	void 		*idle_vbb;
-	dma_addr_t	idle_vbb_dma_addr;
-	/*! Level of debugging information.  0=None, 5=Insane. */
-	atomic_t debuglevel;
-	/*! Cache of buffer objects. */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
-	kmem_cache_t *buffer_cache;
-#else
-	struct kmem_cache *buffer_cache;
-#endif
-	/*! Base address of the VoiceBus interface registers in I/O space. */
-	u32 iobase;
-	/*! The IRQ line for this VoiceBus interface. */
-	unsigned int irq;
-#if VOICEBUS_DEFERRED == WORKQUEUE
-	/*! Process buffers in the context of this workqueue. */
-	struct workqueue_struct *workqueue;
-	/*! Work item to process tx / rx buffers. */
-	struct work_struct workitem;
-#elif VOICEBUS_DEFERRED == TASKLET
-	/*! Process buffers in the context of a tasklet. */
-	struct tasklet_struct 	tasklet;
-#elif VOICEBUS_DEFERRED == TIMER
-	/*! Process buffers in a timer without generating interrupts. */
-	struct timer_list timer;
-#endif
-	/*! Callback function to board specific module to process frames. */
-	void (*handle_receive)(void *vbb, void *context);
-	void (*handle_transmit)(void *vbb, void *context);
-	/*! Data to pass to the receive and transmit callback. */
-	void *context;
-	struct completion stopped_completion;
-	/*! Flags */
-	unsigned long flags;
-	/*! Number of tx buffers to queue up before enabling interrupts. */
-	unsigned int 	min_tx_buffer_count;
-	unsigned int	max_latency;
-	void		*vbb_stash[DRING_SIZE];
-	unsigned int	count;
-};
-
 static inline void handle_transmit(struct voicebus *vb, void *vbb)
 {
-	vb->handle_transmit(vbb, vb->context);
+	vb->ops->handle_transmit(vb, vbb);
 }
 
 /*
@@ -285,6 +194,7 @@
 	int i;
 	struct voicebus_descriptor *d;
 	const u32 END_OF_RING = 0x02000000;
+	u8 cache_line_size;
 
 	BUG_ON(!dl);
 
@@ -294,9 +204,15 @@
 	 * cache-line sizes that we support.
 	 *
 	 */
-	if ((0x08 == vb->cache_line_size) || (0x10 == vb->cache_line_size) ||
-	    (0x20 == vb->cache_line_size)) {
-		dl->padding = (vb->cache_line_size*sizeof(u32)) - sizeof(*d);
+	if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+		dev_err(&vb->pdev->dev, "Failed read of cache line "
+			"size from PCI configuration space.\n");
+		return -EIO;
+	}
+
+	if ((0x08 == cache_line_size) || (0x10 == cache_line_size) ||
+	    (0x20 == cache_line_size)) {
+		dl->padding = (cache_line_size*sizeof(u32)) - sizeof(*d);
 	} else {
 		dl->padding = 0;
 	}
@@ -323,10 +239,11 @@
 vb_initialize_tx_descriptors(struct voicebus *vb)
 {
 	int i;
-	int des1 = 0xe4800000 | vb->framesize;
+	int des1 = 0xe4800000 | VOICEBUS_SFRAME_SIZE;
 	struct voicebus_descriptor *d;
 	struct voicebus_descriptor_list *dl = &vb->txd;
 	const u32 END_OF_RING = 0x02000000;
+	u8 cache_line_size;
 
 	WARN_ON(!dl);
 	WARN_ON((NULL == vb->idle_vbb) || (0 == vb->idle_vbb_dma_addr));
@@ -337,9 +254,15 @@
 	 * cache-line sizes that we support.
 	 *
 	 */
-	if ((0x08 == vb->cache_line_size) || (0x10 == vb->cache_line_size) ||
-	    (0x20 == vb->cache_line_size)) {
-		dl->padding = (vb->cache_line_size*sizeof(u32)) - sizeof(*d);
+	if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+		dev_err(&vb->pdev->dev, "Failed read of cache line "
+			"size from PCI configuration space.\n");
+		return -EIO;
+	}
+
+	if ((0x08 == cache_line_size) || (0x10 == cache_line_size) ||
+	    (0x20 == cache_line_size)) {
+		dl->padding = (cache_line_size*sizeof(u32)) - sizeof(*d);
 	} else {
 		dl->padding = 0;
 	}
@@ -367,7 +290,7 @@
 vb_initialize_rx_descriptors(struct voicebus *vb)
 {
 	return vb_initialize_descriptors(
-		vb, &vb->rxd, vb->framesize, DMA_FROM_DEVICE);
+		vb, &vb->rxd, VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
 }
 
 /*! \brief  Use to set the minimum number of buffers queued to the hardware
@@ -398,41 +321,6 @@
 }
 EXPORT_SYMBOL(voicebus_set_minlatency);
 
-void
-voicebus_get_handlers(struct voicebus *vb, void **handle_receive,
-	void **handle_transmit, void **context)
-{
-	LOCKS_VOICEBUS;
-	BUG_ON(!handle_receive);
-	BUG_ON(!handle_transmit);
-	BUG_ON(!context);
-	VBLOCK(vb);
-	*handle_receive = vb->handle_receive;
-	*handle_transmit = vb->handle_transmit;
-	*context = vb->context;
-	VBUNLOCK(vb);
-	return;
-}
-EXPORT_SYMBOL(voicebus_get_handlers);
-
-void
-voicebus_set_handlers(struct voicebus *vb,
-	void (*handle_receive)(void *buffer, void *context),
-	void (*handle_transmit)(void *buffer, void *context),
-	void *context)
-{
-	LOCKS_VOICEBUS;
-	BUG_ON(!handle_receive);
-	BUG_ON(!handle_transmit);
-	BUG_ON(!context);
-	VBLOCK(vb);
-	vb->handle_receive = handle_receive;
-	vb->handle_transmit = handle_transmit;
-	vb->context = context;
-	VBUNLOCK(vb);
-}
-EXPORT_SYMBOL(voicebus_set_handlers);
-
 /*! \brief Returns the number of buffers currently on the transmit queue. */
 int
 voicebus_current_latency(struct voicebus *vb)
@@ -530,7 +418,7 @@
 		if (d->buffer1 && (d->buffer1 != vb->idle_vbb_dma_addr)) {
 			WARN_ON(!dl->pending[i]);
 			dma_unmap_single(&vb->pdev->dev, d->buffer1,
-					 vb->framesize, DMA_TO_DEVICE);
+					 VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
 			voicebus_free(vb, dl->pending[i]);
 		}
 		d->buffer1 = vb->idle_vbb_dma_addr;
@@ -556,7 +444,7 @@
 		d = vb_descriptor(dl, i);
 		if (d->buffer1) {
 			dma_unmap_single(&vb->pdev->dev, d->buffer1,
-					 vb->framesize, DMA_FROM_DEVICE);
+					 VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
 			d->buffer1 = 0;
 			BUG_ON(!dl->pending[i]);
 			voicebus_free(vb, dl->pending[i]);
@@ -678,23 +566,9 @@
 voicebus_alloc(struct voicebus *vb)
 {
 	void *vbb;
-	vbb = kmem_cache_alloc(vb->buffer_cache, VOICEBUS_ALLOC_FLAGS);
+	vbb = kmem_cache_alloc(buffer_cache, VOICEBUS_ALLOC_FLAGS);
 	return vbb;
 }
-
-void
-voicebus_setdebuglevel(struct voicebus *vb, u32 level)
-{
-	atomic_set(&vb->debuglevel, level);
-}
-EXPORT_SYMBOL(voicebus_setdebuglevel);
-
-int
-voicebus_getdebuglevel(struct voicebus *vb)
-{
-	return atomic_read(&vb->debuglevel);
-}
-EXPORT_SYMBOL(voicebus_getdebuglevel);
 
 /*! \brief Resets the voicebus hardware interface. */
 static int
@@ -704,9 +578,16 @@
 	u32 reg;
 	u32 pci_access;
 	const u32 DEFAULT_PCI_ACCESS = 0xfff80002;
+	u8 cache_line_size;
 	BUG_ON(in_interrupt());
 
-	switch (vb->cache_line_size) {
+	if (pci_read_config_byte(vb->pdev, 0x0c, &cache_line_size)) {
+		dev_err(&vb->pdev->dev, "Failed read of cache line "
+			"size from PCI configuration space.\n");
+		return -EIO;
+	}
+
+	switch (cache_line_size) {
 	case 0x08:
 		pci_access = DEFAULT_PCI_ACCESS | (0x1 << 14);
 		break;
@@ -717,11 +598,11 @@
 		pci_access = DEFAULT_PCI_ACCESS | (0x3 << 14);
 		break;
 	default:
-		if (atomic_read(&vb->debuglevel)) {
+		if (*vb->debug) {
 			dev_warn(&vb->pdev->dev, "Host system set a cache "
 				 "size of %d which is not supported. "
 				 "Disabling memory write line and memory "
-				 "read line.\n", vb->cache_line_size);
+				 "read line.\n", cache_line_size);
 		}
 		pci_access = 0xfe584202;
 		break;
@@ -806,7 +687,7 @@
 	c = vbb;
 	printk(KERN_DEBUG "Packet %d\n", count);
 	printk(KERN_DEBUG "");
-	for (x = 1; x <= vb->framesize; ++x) {
+	for (x = 1; x <= VOICEBUS_SFRAME_SIZE; ++x) {
 		printk("%02x ", c[x]);
 		if (x % 16 == 0)
 			printk("\n");
@@ -836,7 +717,7 @@
 	dl->pending[dl->tail] = vbb;
 	dl->tail = (++(dl->tail)) & DRING_MASK;
 	d->buffer1 = dma_map_single(&vb->pdev->dev, vbb,
-				    vb->framesize, DMA_TO_DEVICE);
+				    VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
 	SET_OWNED(d); /* That's it until the hardware is done with it. */
 	atomic_inc(&dl->count);
 	return 0;
@@ -866,7 +747,7 @@
 	dl->pending[tail] = vbb;
 	dl->tail = (++tail) & DRING_MASK;
 	d->buffer1 = dma_map_single(&vb->pdev->dev, vbb,
-				    vb->framesize, DMA_FROM_DEVICE);
+				    VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
 	SET_OWNED(d); /* That's it until the hardware is done with it. */
 	atomic_inc(&dl->count);
 	return 0;
@@ -899,7 +780,7 @@
 		return NULL;
 
 	dma_unmap_single(&vb->pdev->dev, d->buffer1,
-			 vb->framesize, DMA_TO_DEVICE);
+			 VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
 
 	vbb = dl->pending[head];
 	dl->head = (++head) & DRING_MASK;
@@ -923,7 +804,7 @@
 		return NULL;
 
 	dma_unmap_single(&vb->pdev->dev, d->buffer1,
-			 vb->framesize, DMA_FROM_DEVICE);
+			 VOICEBUS_SFRAME_SIZE, DMA_FROM_DEVICE);
 	vbb = dl->pending[head];
 	dl->head = (++head) & DRING_MASK;
 	d->buffer1 = 0;
@@ -938,7 +819,7 @@
 void
 voicebus_free(struct voicebus *vb, void *vbb)
 {
-	kmem_cache_free(vb->buffer_cache, vbb);
+	kmem_cache_free(buffer_cache, vbb);
 }
 
 /*!
@@ -1023,10 +904,6 @@
 	int i;
 	void *vbb;
 	int ret;
-
-	WARN_ON(pci_get_drvdata(vb->pdev) != vb);
-	if (pci_get_drvdata(vb->pdev) != vb)
-		return -EFAULT;
 
 	if (!vb_is_stopped(vb))
 		return -EBUSY;
@@ -1229,13 +1106,11 @@
 	vb_free_descriptors(vb, &vb->txd);
 	vb_free_descriptors(vb, &vb->rxd);
 	if (vb->idle_vbb_dma_addr) {
-		dma_free_coherent(&vb->pdev->dev, vb->framesize,
+		dma_free_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
 				  vb->idle_vbb, vb->idle_vbb_dma_addr);
 	}
-	kmem_cache_destroy(vb->buffer_cache);
 	release_region(vb->iobase, 0xff);
 	pci_disable_device(vb->pdev);
-	kfree(vb);
 }
 EXPORT_SYMBOL(voicebus_release);
 
@@ -1371,7 +1246,7 @@
 		WARN_ON(d->buffer1 == vb->idle_vbb_dma_addr);
 		WARN_ON(!dl->pending[dl->head]);
 		dma_unmap_single(&vb->pdev->dev, d->buffer1,
-				 vb->framesize, DMA_TO_DEVICE);
+				 VOICEBUS_SFRAME_SIZE, DMA_TO_DEVICE);
 		vbb = dl->pending[dl->head];
 		atomic_dec(&dl->count);
 		--behind;
@@ -1518,7 +1393,7 @@
 	 * the caller, but this needs more work.... */
 	while ((vb->vbb_stash[0] = vb_get_completed_rxb(vb))) {
 		if (vb->count) {
-			vb->handle_receive(vb->vbb_stash[0], vb->context);
+			vb->ops->handle_receive(vb, vb->vbb_stash[0]);
 			--vb->count;
 		}
 		vb_submit_rxb(vb, vb->vbb_stash[0]);
@@ -1662,45 +1537,25 @@
  * \todo Complete this description.
  */
 int
-voicebus_init(struct pci_dev *pdev, u32 framesize, const char *board_name,
-		  void (*handle_receive)(void *vbb, void *context),
-		  void (*handle_transmit)(void *vbb, void *context),
-		  void *context,
-		  u32 debuglevel,
-		  struct voicebus **vbp
-		  )
+voicebus_init(struct voicebus *vb, const char *board_name)
 {
 	int retval = 0;
-	struct voicebus *vb;
-
-	BUG_ON(NULL == pdev);
+
+	BUG_ON(NULL == vb);
 	BUG_ON(NULL == board_name);
-	BUG_ON(0 == framesize);
-	BUG_ON(NULL == handle_receive);
-	BUG_ON(NULL == handle_transmit);
+	BUG_ON(NULL == vb->ops);
+	BUG_ON(NULL == vb->pdev);
+	BUG_ON(NULL == vb->debug);
 
 	/* ----------------------------------------------------------------
 	   Initialize the pure software constructs.
 	   ---------------------------------------------------------------- */
-	*vbp = NULL;
-	vb = kmalloc(sizeof(*vb), GFP_KERNEL);
-	if (NULL == vb) {
-		dev_dbg(&vb->pdev->dev, "Failed to allocate memory for "
-			"voicebus interface.\n");
-		retval = -ENOMEM;
-		goto cleanup;
-	}
-	memset(vb, 0, sizeof(*vb));
-	vb->pdev = pdev;
-	pci_set_drvdata(pdev, vb);
-	voicebus_setdebuglevel(vb, debuglevel);
 	vb->max_latency = VOICEBUS_DEFAULT_MAXLATENCY;
 
 	spin_lock_init(&vb->lock);
 	init_completion(&vb->stopped_completion);
 	set_bit(STOP, &vb->flags);
 	clear_bit(IN_DEFERRED_PROCESSING, &vb->flags);
-	vb->framesize = framesize;
 	vb->min_tx_buffer_count = VOICEBUS_DEFAULT_LATENCY;
 
 #if VOICEBUS_DEFERRED == WORKQUEUE
@@ -1725,34 +1580,6 @@
 	vb->timer.data = (unsigned long)vb;
 #endif
 
-	vb->handle_receive = handle_receive;
-	vb->handle_transmit = handle_transmit;
-	vb->context = context;
-
-	/* \todo This cache should be shared by all instances supported by
-	 * this driver. */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
-	vb->buffer_cache = kmem_cache_create(board_name, vb->framesize, 0,
-#if defined(CONFIG_SLUB) && (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 22))
-				SLAB_HWCACHE_ALIGN | SLAB_STORE_USER, NULL, NULL);
-#else
-				SLAB_HWCACHE_ALIGN, NULL, NULL);
-#endif
-#else
-#ifdef DEBUG
-	vb->buffer_cache = kmem_cache_create(board_name, vb->framesize, 0,
-				SLAB_HWCACHE_ALIGN | SLAB_STORE_USER |
-				SLAB_POISON | SLAB_DEBUG_FREE, NULL);
-#else
-	vb->buffer_cache = kmem_cache_create(board_name, vb->framesize, 0,
-				SLAB_HWCACHE_ALIGN, NULL);
-#endif
-#endif
-	if (NULL == vb->buffer_cache) {
-		dev_err(&vb->pdev->dev, "Failed to allocate buffer cache.\n");
-		goto cleanup;
-	}
-
 #ifdef CONFIG_VOICEBUS_SYSFS
 	dev_dbg(&vb->pdev->dev, "Creating sysfs attributes.\n");
 	retval = device_create_file(&vb->pdev->dev,
@@ -1771,13 +1598,7 @@
 		goto cleanup;
 	}
 
-	if (pci_read_config_byte(vb->pdev, 0x0c, &vb->cache_line_size)) {
-		dev_err(&vb->pdev->dev, "Failed read of cache line "
-			"size from PCI configuration space.\n");
-		goto cleanup;
-	}
-
-	if (pci_enable_device(pdev)) {
+	if (pci_enable_device(vb->pdev)) {
 		dev_err(&vb->pdev->dev, "Failed call to pci_enable_device.\n");
 		retval = -EIO;
 		goto cleanup;
@@ -1785,12 +1606,12 @@
 
 	/* \todo This driver should be modified to use the memory mapped I/O
 	   as opposed to IO space for portability and performance. */
-	if (0 == (pci_resource_flags(pdev, 0)&IORESOURCE_IO)) {
+	if (0 == (pci_resource_flags(vb->pdev, 0)&IORESOURCE_IO)) {
 		dev_err(&vb->pdev->dev, "BAR0 is not IO Memory.\n");
 		retval = -EIO;
 		goto cleanup;
 	}
-	vb->iobase = pci_resource_start(pdev, 0);
+	vb->iobase = pci_resource_start(vb->pdev, 0);
 	if (NULL == request_region(vb->iobase, 0xff, board_name)) {
 		dev_err(&vb->pdev->dev, "IO Registers are in use by another "
 			"module.\n");
@@ -1798,7 +1619,7 @@
 		goto cleanup;
 	}
 
-	vb->idle_vbb = dma_alloc_coherent(&vb->pdev->dev, vb->framesize,
+	vb->idle_vbb = dma_alloc_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
 					  &vb->idle_vbb_dma_addr, GFP_KERNEL);
 
 	retval = vb_initialize_tx_descriptors(vb);
@@ -1812,17 +1633,17 @@
 	/* ----------------------------------------------------------------
 	   Configure the hardware interface.
 	   ---------------------------------------------------------------- */
-	if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
+	if (pci_set_dma_mask(vb->pdev, DMA_BIT_MASK(32))) {
 		release_region(vb->iobase, 0xff);
 		dev_warn(&vb->pdev->dev, "No suitable DMA available.\n");
 		goto cleanup;
 	}
 
-	pci_set_master(pdev);
+	pci_set_master(vb->pdev);
 	vb_enable_io_access(vb);
 
 #if VOICEBUS_DEFERRED != TIMER
-	retval = request_irq(pdev->irq, vb_isr, DAHDI_IRQ_SHARED,
+	retval = request_irq(vb->pdev->irq, vb_isr, DAHDI_IRQ_SHARED,
 			     board_name, vb);
 	if (retval) {
 		dev_warn(&vb->pdev->dev, "Failed to request interrupt line.\n");
@@ -1830,17 +1651,12 @@
 	}
 #endif
 
-	*vbp = vb;
 	return retval;
 cleanup:
-	if (NULL == vb)
-		return retval;
 
 #if VOICEBUS_DEFERRED == WORKQUEUE
-
 	if (vb->workqueue)
 		destroy_workqueue(vb->workqueue);
-
 #elif VOICEBUS_DEFERRED == TASKLET
 	tasklet_kill(&vb->tasklet);
 #endif
@@ -1852,11 +1668,8 @@
 	if (vb->rxd.desc)
 		vb_free_descriptors(vb, &vb->rxd);
 
-	dma_free_coherent(&vb->pdev->dev, vb->framesize,
+	dma_free_coherent(&vb->pdev->dev, VOICEBUS_SFRAME_SIZE,
 			  vb->idle_vbb, vb->idle_vbb_dma_addr);
-
-	if (vb->buffer_cache)
-		kmem_cache_destroy(vb->buffer_cache);
 
 	if (vb->iobase)
 		release_region(vb->iobase, 0xff);
@@ -1864,7 +1677,6 @@
 	if (vb->pdev)
 		pci_disable_device(vb->pdev);
 
-	kfree(vb);
 	WARN_ON(0 == retval);
 	return retval;
 }
@@ -1878,12 +1690,6 @@
 	return vb->pdev;
 }
 EXPORT_SYMBOL(voicebus_get_pci_dev);
-
-void *voicebus_pci_dev_to_context(struct pci_dev *pdev)
-{
-	return ((struct voicebus *)pci_get_drvdata(pdev))->context;
-}
-EXPORT_SYMBOL(voicebus_pci_dev_to_context);
 
 static spinlock_t loader_list_lock;
 static struct list_head binary_loader_list;
@@ -1963,11 +1769,41 @@
 int __init voicebus_module_init(void)
 {
 	int res;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
+	buffer_cache = kmem_cache_create(THIS_MODULE->name,
+					 VOICEBUS_SFRAME_SIZE, 0,
+#if defined(CONFIG_SLUB) && (LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 22))
+					 SLAB_HWCACHE_ALIGN |
+					 SLAB_STORE_USER, NULL,
+					 NULL);
+#else
+					 SLAB_HWCACHE_ALIGN, NULL,
+					 NULL);
+#endif
+#else
+#ifdef DEBUG
+	buffer_cache = kmem_cache_create(THIS_MODULE->name,
+					 VOICEBUS_SFRAME_SIZE, 0,
+					 SLAB_HWCACHE_ALIGN | SLAB_STORE_USER |
+					 SLAB_POISON | SLAB_DEBUG_FREE, NULL);
+#else
+	buffer_cache = kmem_cache_create(THIS_MODULE->name,
+					 VOICEBUS_SFRAME_SIZE, 0,
+					 SLAB_HWCACHE_ALIGN, NULL);
+#endif
+#endif
+
+	if (NULL == buffer_cache) {
+		printk(KERN_ERR "%s: Failed to allocate buffer cache.\n",
+		       THIS_MODULE->name);
+		return -ENOMEM;
+	}
+
 	/* This registration with dahdi.ko will fail since the span is not
 	 * defined, but it will make sure that this module is a dependency of
 	 * dahdi.ko, so that when it is being unloded, this module will be
-	 * unloaded as well.
-	 */
+	 * unloaded as well. */
 	dahdi_register(0, 0);
 	INIT_LIST_HEAD(&binary_loader_list);
 	spin_lock_init(&loader_list_lock);
@@ -1979,6 +1815,7 @@
 
 void __exit voicebus_module_cleanup(void)
 {
+	kmem_cache_destroy(buffer_cache);
 	WARN_ON(!list_empty(&binary_loader_list));
 }
 

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.h?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.h (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/voicebus.h Wed Jan 13 16:33:55 2010
@@ -29,29 +29,81 @@
 #ifndef __VOICEBUS_H__
 #define __VOICEBUS_H__
 
+#define VOICEBUS_DEFAULT_LATENCY	3
+#define VOICEBUS_DEFAULT_MAXLATENCY	25
+#define VOICEBUS_MAXLATENCY_BUMP	6
+
+#define VOICEBUS_SFRAME_SIZE 1004
+
+/*! The number of descriptors in both the tx and rx descriptor ring. */
+#define DRING_SIZE	(1 << 7)  /* Must be a power of 2 */
+#define DRING_MASK	(DRING_SIZE-1)
+
+/* Define CONFIG_VOICEBUS_SYSFS to create some attributes under the pci device.
+ * This is disabled by default because it hasn't been tested on the full range
+ * of supported kernels. */
+#undef CONFIG_VOICEBUS_SYSFS
+
+#define INTERRUPT 0	/* Run the deferred processing in the ISR. */
+#define TASKLET   1	/* Run in a tasklet. */
+#define TIMER	  2	/* Run in a system timer. */
+#define WORKQUEUE 3	/* Run in a workqueue. */
+
+#ifndef VOICEBUS_DEFERRED
+#define VOICEBUS_DEFERRED INTERRUPT
+#endif
+
 struct voicebus;
 
-#define VOICEBUS_DEFAULT_LATENCY 3
-#define VOICEBUS_DEFAULT_MAXLATENCY 25
-#define VOICEBUS_MAXLATENCY_BUMP 6
+struct voicebus_operations {
+	void (*handle_receive)(struct voicebus *vb, void *vbb);
+	void (*handle_transmit)(struct voicebus *vb, void *vbb);
+};
 
-void voicebus_setdebuglevel(struct voicebus *vb, u32 level);
-int voicebus_getdebuglevel(struct voicebus *vb);
-struct pci_dev *voicebus_get_pci_dev(struct voicebus *vb);
-void *voicebus_pci_dev_to_context(struct pci_dev *pdev);
-int voicebus_init(struct pci_dev* pdev, u32 framesize, 
-                  const char *board_name,
-		  void (*handle_receive)(void *buffer, void *context),
-		  void (*handle_transmit)(void *buffer, void *context),
-		  void *context, 
-		  u32 debuglevel,
-		  struct voicebus **vb_p);
-void voicebus_get_handlers(struct voicebus *vb, void **handle_receive,
-	void **handle_transmit, void **context);
-void voicebus_set_handlers(struct voicebus *vb,
-	void (*handle_receive)(void *buffer, void *context),
-	void (*handle_transmit)(void *buffer, void *context),
-	void *context);
+/**
+ * struct voicebus_descriptor_list - A single descriptor list.
+ */
+struct voicebus_descriptor_list {
+	struct voicebus_descriptor *desc;
+	unsigned int 	head;
+	unsigned int 	tail;
+	void  		*pending[DRING_SIZE];
+	dma_addr_t	desc_dma;
+	atomic_t 	count;
+	unsigned int	padding;
+};
+
+/**
+ * struct voicebus - Represents physical interface to voicebus card.
+ *
+ */
+struct voicebus {
+	struct pci_dev		*pdev;
+	spinlock_t		lock;
+	struct voicebus_descriptor_list rxd;
+	struct voicebus_descriptor_list txd;
+	void			*idle_vbb;
+	dma_addr_t		idle_vbb_dma_addr;
+	const int		*debug;
+	u32			iobase;
+#if VOICEBUS_DEFERRED == WORKQUEUE
+	struct workqueue_struct *workqueue;
+	struct work_struct	workitem;
+#elif VOICEBUS_DEFERRED == TASKLET
+	struct tasklet_struct 	tasklet;
+#elif VOICEBUS_DEFERRED == TIMER
+	struct timer_list	timer;
+#endif
+	const struct voicebus_operations *ops;
+	struct completion	stopped_completion;
+	unsigned long		flags;
+	unsigned int		min_tx_buffer_count;
+	unsigned int		max_latency;
+	void			*vbb_stash[DRING_SIZE];
+	unsigned int		count;
+};
+
+int voicebus_init(struct voicebus *vb, const char *board_name);
 void voicebus_release(struct voicebus *vb);
 int voicebus_start(struct voicebus *vb);
 int voicebus_stop(struct voicebus *vb);

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/vpmadtreg.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/vpmadtreg.h?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/vpmadtreg.h (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/voicebus/vpmadtreg.h Wed Jan 13 16:33:55 2010
@@ -21,9 +21,6 @@
 #ifndef __VPMADTREG_H__
 #define __VPMADTREG_H__
 
-struct vpmadt032;
-struct voicebus;
-
 struct vpmadt_loader {
 	struct module *owner;
 	struct list_head node;

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c Wed Jan 13 16:33:55 2010
@@ -66,55 +66,59 @@
 
 struct private_context {
 	struct voicebus *vb;
-	void *old_rx;
-	void *old_tx;
-	void *old_context;
 	void *pvt;
 	struct completion done;
 };
 
 static void init_private_context(struct private_context *ctx)
 {
-	memset(ctx, 0, sizeof(ctx));
 	init_completion(&ctx->done);
 }
 
-static void handle_receive(void *vbb, void *context)
+static void handle_receive(struct voicebus *vb, void *vbb)
 {
-	struct private_context *ctx = context;
+	struct private_context *ctx = pci_get_drvdata(vb->pdev);
 	__vpmadt032_receive(ctx->pvt, vbb);
 	if (__vpmadt032_done(ctx->pvt))
 		complete(&ctx->done);
 }
 
-static void handle_transmit(void *vbb, void *context)
+static void handle_transmit(struct voicebus *vb, void *vbb)
 {
-	struct private_context *ctx = context;
+	struct private_context *ctx = pci_get_drvdata(vb->pdev);
 	__vpmadt032_transmit(ctx->pvt, vbb);
 	voicebus_transmit(ctx->vb, vbb);
 }
+
+static const struct voicebus_operations loader_operations = {
+	.handle_receive = handle_receive,
+	.handle_transmit = handle_transmit,
+};
 
 static int vpmadt032_load_firmware(struct voicebus *vb)
 {
 	int ret = 0;
 	struct private_context *ctx;
-	struct pci_dev *pdev = voicebus_get_pci_dev(vb);
+	const struct voicebus_operations *old;
+	void *old_drvdata;
 	might_sleep();
-	ctx = kmalloc(sizeof(struct private_context), GFP_KERNEL);
+	ctx = kzalloc(sizeof(struct private_context), GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
 	init_private_context(ctx);
 	ctx->vb = vb;
 	ret = __vpmadt032_start_load(
-			0, pdev->vendor << 16 | pdev->device,
+			0, vb->pdev->vendor << 16 | vb->pdev->device,
 			&ctx->pvt);
 	if (ret)
 		goto error_exit;
-	voicebus_get_handlers(vb, &ctx->old_rx, &ctx->old_tx,
-		&ctx->old_context);
-	voicebus_set_handlers(vb, handle_receive, handle_transmit, ctx);
+	old_drvdata = pci_get_drvdata(vb->pdev);
+	pci_set_drvdata(vb->pdev, ctx);
+	old = vb->ops;
+	vb->ops = &loader_operations;
 	wait_for_completion(&ctx->done);
-	voicebus_set_handlers(vb, ctx->old_rx, ctx->old_tx, ctx->old_context);
+	vb->ops = old;
+	pci_set_drvdata(vb->pdev, old_drvdata);
 	__vpmadt032_cleanup(ctx->pvt);
 error_exit:
 	kfree(ctx);

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/base.c Wed Jan 13 16:33:55 2010
@@ -63,6 +63,10 @@
 
 #include "voicebus/GpakCust.h"
 #include "voicebus/GpakApi.h"
+
+#if VOICEBUS_SFRAME_SIZE != SFRAME_SIZE
+#error SFRAME_SIZE must match the VOICEBUS_SFRAME_SIZE
+#endif
 
 /*
   Experimental max loop current limit for the proslic
@@ -1798,20 +1802,20 @@
 	}
 }
 
-static void handle_receive(void* vbb, void* context)
-{
-	struct wctdm *wc = context;
+static void handle_receive(struct voicebus *vb, void* vbb)
+{
+	struct wctdm *wc = container_of(vb, struct wctdm, vb);
 	wctdm_receiveprep(wc, vbb);
 }
 
-static void handle_transmit(void* vbb, void* context)
-{
-	struct wctdm *wc = context;
+static void handle_transmit(struct voicebus *vb, void* vbb)
+{
+	struct wctdm *wc = container_of(vb, struct wctdm, vb);
 	memset(vbb, 0, SFRAME_SIZE);
 	wctdm_transmitprep(wc, vbb);
 	wctdm_isr_misc(wc);
 	wc->intcount++;
-	voicebus_transmit(wc->vb, vbb);
+	voicebus_transmit(&wc->vb, vbb);
 }
 
 static int wctdm_voicedaa_insane(struct wctdm *wc, int card)
@@ -3268,7 +3272,7 @@
 static int wctdm_initialize(struct wctdm *wc)
 {
 	int x;
-	struct pci_dev *pdev = voicebus_get_pci_dev(wc->vb);
+	struct pci_dev *pdev = wc->vb.pdev;
 
 	/* DAHDI stuff */
 	sprintf(wc->span.name, "WCTDM/%d", wc->pos);
@@ -3663,7 +3667,7 @@
 		wc->vpmadt032->setchanconfig_from_state = setchanconfig_from_state;
 		wc->vpmadt032->options.channels = wc->span.channels;
 		get_default_portconfig(&portconfig);
-		res = vpmadt032_init(wc->vpmadt032, wc->vb);
+		res = vpmadt032_init(wc->vpmadt032, &wc->vb);
 		if (res) {
 			vpmadt032_free(wc->vpmadt032);
 			wc->vpmadt032 = NULL;
@@ -3702,6 +3706,11 @@
 	}
 	kfree(wc);
 }
+
+static const struct voicebus_operations voicebus_operations = {
+	.handle_receive = handle_receive,
+	.handle_transmit = handle_transmit,
+};
 
 static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -3730,16 +3739,19 @@
 
 	snprintf(wc->board_name, sizeof(wc->board_name)-1, "%s%d",
 		 wctdm_driver.name, i);
-	ret = voicebus_init(pdev, SFRAME_SIZE, wc->board_name,
-		handle_receive, handle_transmit, wc, debug, &wc->vb);
+
+	pci_set_drvdata(pdev, wc);
+	wc->vb.ops = &voicebus_operations;
+	wc->vb.pdev = pdev;
+	wc->vb.debug = &debug;
+	ret = voicebus_init(&wc->vb, wc->board_name);
 	if (ret) {
 		kfree(wc);
 		return ret;
 	}
-	BUG_ON(!wc->vb);
 
 	if (VOICEBUS_DEFAULT_LATENCY != latency) {
-		voicebus_set_minlatency(wc->vb, latency);
+		voicebus_set_minlatency(&wc->vb, latency);
 	}
 
 	spin_lock_init(&wc->reglock);
@@ -3768,17 +3780,15 @@
 
 
 	if (wctdm_initialize(wc)) {
-		voicebus_release(wc->vb);
-		wc->vb = NULL;
+		voicebus_release(&wc->vb);
 		kfree(wc);
 		return -EIO;
 	}
 
-	voicebus_lock_latency(wc->vb);
-
-	if (voicebus_start(wc->vb)) {
+	voicebus_lock_latency(&wc->vb);
+
+	if (voicebus_start(&wc->vb))
 		BUG_ON(1);
-	}
 	
 	/* Now track down what modules are installed */
 	wctdm_locate_modules(wc);
@@ -3797,7 +3807,7 @@
 	printk(KERN_INFO "Found a Wildcard TDM: %s (%d modules)\n",
 	       wc->desc->name, wc->desc->ports);
 	
-	voicebus_unlock_latency(wc->vb);
+	voicebus_unlock_latency(&wc->vb);
 	return 0;
 }
 
@@ -3809,8 +3819,7 @@
 		dahdi_unregister(&wc->span);
 	}
 
-	voicebus_release(wc->vb);
-	wc->vb = NULL;
+	voicebus_release(&wc->vb);
 
 	spin_lock(&ifacelock);
 	for (i = 0; i < WC_MAX_IFACES; i++)
@@ -3824,7 +3833,7 @@
 
 static void __devexit wctdm_remove_one(struct pci_dev *pdev)
 {
-	struct wctdm *wc = voicebus_pci_dev_to_context(pdev);
+	struct wctdm *wc = pci_get_drvdata(pdev);
 	struct vpmadt032 *vpm = wc->vpmadt032;
 
 	if (wc) {
@@ -3834,7 +3843,7 @@
 			flush_scheduled_work();
 		}
 
-		voicebus_stop(wc->vb);
+		voicebus_stop(&wc->vb);
 
 		if (vpm) {
 			vpmadt032_free(wc->vpmadt032);

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=7915&r1=7914&r2=7915
==============================================================================
--- linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Wed Jan 13 16:33:55 2010
@@ -53,9 +53,9 @@
 #define FLAG_3215	(1 << 0)
 #define FLAG_EXPRESS	(1 << 1)
 
-#define EFRAME_SIZE	108
-#define ERING_SIZE 16		/* Maximum ring size */
-#define EFRAME_GAP 20
+#define EFRAME_SIZE 108L
+#define ERING_SIZE 16L		/* Maximum ring size */
+#define EFRAME_GAP 20L
 #define SFRAME_SIZE ((EFRAME_SIZE * DAHDI_CHUNKSIZE) + (EFRAME_GAP * (DAHDI_CHUNKSIZE - 1)))
 
 #define MAX_ALARMS 10
@@ -227,7 +227,7 @@
 	int echocanpos;
 	int blinktimer;
 #endif	
-	struct voicebus *vb;
+	struct voicebus vb;
 	struct dahdi_chan *chans[NUM_CARDS];
 	struct dahdi_echocan_state *ec[NUM_CARDS];
 	int initialized;

Modified: linux/team/mspiceland/dahdi-qfalc31/drivers/dahdi/wcte12xp/base.c

[... 1342 lines stripped ...]



More information about the dahdi-commits mailing list