[svn-commits] fjoe: freebsd/trunk r8326 - in /freebsd/trunk/drivers/dahdi: wcb4xxp/ wct4xxp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 10 10:58:23 CST 2010


Author: fjoe
Date: Wed Mar 10 10:58:19 2010
New Revision: 8326

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8326
Log:
- Use dahdi_pci_device_id_lookup()
- Enable tunables

Modified:
    freebsd/trunk/drivers/dahdi/wcb4xxp/base.c
    freebsd/trunk/drivers/dahdi/wct4xxp/base.c

Modified: freebsd/trunk/drivers/dahdi/wcb4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcb4xxp/base.c?view=diff&rev=8326&r1=8325&r2=8326
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcb4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wcb4xxp/base.c Wed Mar 10 10:58:19 2010
@@ -31,6 +31,8 @@
 #include <machine/bus.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
+
+#define MODULE_PARAM_PREFIX "dahdi.wcb4xxp"
 
 #ifdef mb
 #undef mb
@@ -3014,33 +3016,13 @@
 	return (0);
 }
 
-static struct pci_device_id *
-b4xxp_pci_device_id_lookup(device_t dev)
-{
-	struct pci_device_id *id;
-	uint16_t vendor = pci_get_vendor(dev);
-	uint16_t device = pci_get_device(dev);
-	uint16_t subvendor = pci_get_subvendor(dev);
-	uint16_t subdevice = pci_get_subdevice(dev);
-
-	for (id = b4xx_ids; id->vendor != 0; id++) {
-		if ((id->vendor == PCI_ANY_ID || id->vendor == vendor) &&
-		    (id->device == PCI_ANY_ID || id->device == device) &&
-		    (id->subvendor == PCI_ANY_ID || id->subvendor == subvendor) &&
-		    (id->subdevice == PCI_ANY_ID || id->subdevice == subdevice))
-			return id;
-	}
-
-	return NULL;
-}
-
 static int
 b4xxp_device_probe(device_t dev)
 {
-        struct pci_device_id *id;
+	struct pci_device_id *id;
 	struct devtype *dt;
 
-	id = b4xxp_pci_device_id_lookup(dev);
+	id = dahdi_pci_device_id_lookup(dev, b4xx_ids);
 	if (id == NULL)
 		return ENXIO;
 
@@ -3056,11 +3038,11 @@
 b4xxp_device_attach(device_t dev)
 {
 	int res;
-        struct pci_device_id *id;
+	struct pci_device_id *id;
 	struct devtype *dt;
 	struct b4xxp *b4;
 
-	id = b4xxp_pci_device_id_lookup(dev);
+	id = dahdi_pci_device_id_lookup(dev, b4xx_ids);
 	if (id == NULL)
 		return ENXIO;
 
@@ -3115,21 +3097,21 @@
 static int
 b4xxp_device_shutdown(device_t dev)
 {
-	DPRINTF(dev, "wcb4xxp shutdown\n");
+	DPRINTF(dev, "%s shutdown\n", device_get_name(dev));
 	return (0);
 }
 
 static int
 b4xxp_device_suspend(device_t dev)
 {
-	DPRINTF(dev, "wcb4xxp suspend\n");
+	DPRINTF(dev, "%s suspend\n", device_get_name(dev));
 	return (0);
 }
 
 static int
 b4xxp_device_resume(device_t dev)
 {
-	DPRINTF(dev, "wcb4xxp resume\n");
+	DPRINTF(dev, "%s resume\n", device_get_name(dev));
 	return (0);
 }
 
@@ -3283,20 +3265,24 @@
 #endif
 	pci_unregister_driver(&b4xx_driver);
 }
+#endif /* !__FreeBSD__ */
 
 module_param(debug, int, S_IRUGO | S_IWUSR);
 module_param(spanfilter, int, S_IRUGO | S_IWUSR);
 #ifdef LOOKBACK_SUPPORTED
 module_param(loopback, int, S_IRUGO | S_IWUSR);
 #endif
+#if !defined(__FreeBSD__)
 module_param(milliwatt, int, S_IRUGO | S_IWUSR);
 module_param(pedanticpci, int, S_IRUGO);
+#endif
 module_param(teignorered, int, S_IRUGO | S_IWUSR);
 module_param(alarmdebounce, int, S_IRUGO | S_IWUSR);
 module_param(vpmsupport, int, S_IRUGO);
 module_param(timer_1_ms, int, S_IRUGO | S_IWUSR);
 module_param(timer_3_ms, int, S_IRUGO | S_IWUSR);
 
+#if !defined(__FreeBSD__)
 MODULE_PARM_DESC(debug, "bitmap: 1=general 2=dtmf 4=regops 8=fops 16=ec 32=st state 64=hdlc 128=alarm");
 MODULE_PARM_DESC(spanfilter, "debug filter for spans. bitmap: 1=port 1, 2=port 2, 4=port 3, 8=port 4");
 #ifdef LOOKBACK_SUPPORTED

Modified: freebsd/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=8326&r1=8325&r2=8326
==============================================================================
--- freebsd/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wct4xxp/base.c Wed Mar 10 10:58:19 2010
@@ -40,6 +40,8 @@
 #include <dev/pci/pcivar.h>
 
 #define DPRINTF(dev, fmt, args...)      device_rlprintf(20, dev, fmt, ##args)
+
+#define MODULE_PARAM_PREFIX "dahdi.wct4xxp"
 
 static int
 t4_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr);
@@ -387,13 +389,13 @@
 	uint32_t writedma;
 	bus_dma_tag_t   write_dma_tag;
 	bus_dmamap_t    write_dma_map;
-#else
+#else /* !__FreeBSD__ */
 	dma_addr_t 	readdma;
 	dma_addr_t	writedma;
 	unsigned long memaddr;		/* Base address of card */
 	unsigned long memlen;
 	__iomem volatile unsigned int *membase;	/* Base address of card */
-#endif
+#endif /* !__FreeBSD__ */
 
 	/* Add this for our softlockup protector */
 	unsigned int oct_rw_count;
@@ -3470,11 +3472,11 @@
 	uint32_t writedma;
 	bus_dma_tag_t   write_dma_tag;
 	bus_dmamap_t    write_dma_map;
-#else
+#else /* !__FreeBSD__ */
 	volatile unsigned int *oldalloc;
 	dma_addr_t oldaddr;
 	int oldbufs;
-#endif
+#endif /* !__FreeBSD__ */
 
 	spin_lock_irqsave(&wc->reglock, flags);
 
@@ -3525,9 +3527,9 @@
 #if defined(__FreeBSD__)
 	t4_dma_free(&write_dma_tag, &write_dma_map, &writechunk, &writedma);
 	t4_dma_free(&read_dma_tag, &read_dma_map, &readchunk, &readdma);
-#else /* !__FreeBSD__ */
+#else
 	pci_free_consistent(wc->dev, T4_BASE_SIZE * oldbufs * 2, (void *)oldalloc, oldaddr);
-#endif /* !__FreeBSD__ */
+#endif
 
 	printk("Increased latency to %d\n", newlatency);
 
@@ -4618,33 +4620,74 @@
 	return (0);
 }
 
-static struct pci_device_id *
-t4_pci_device_id_lookup(device_t dev)
-{
-	struct pci_device_id *id;
-	uint16_t vendor = pci_get_vendor(dev);
-	uint16_t device = pci_get_device(dev);
-	uint16_t subvendor = pci_get_subvendor(dev);
-	uint16_t subdevice = pci_get_subdevice(dev);
-
-	for (id = t4_pci_tbl; id->vendor != 0; id++) {
-		if ((id->vendor == PCI_ANY_ID || id->vendor == vendor) &&
-		    (id->device == PCI_ANY_ID || id->device == device) &&
-		    (id->subvendor == PCI_ANY_ID || id->subvendor == subvendor) &&
-		    (id->subdevice == PCI_ANY_ID || id->subdevice == subdevice))
-			return id;
-	}
-
-	return NULL;
+static void
+t4_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+	uint32_t *paddr = arg;
+	*paddr = segs->ds_addr;
+}
+
+static int
+t4_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
+{
+	int res;
+
+	res = bus_dma_tag_create(NULL, 8, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
+	if (res)
+		return res;
+
+	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
+	if (res) {
+		bus_dma_tag_destroy(*ptag);
+		*ptag = NULL;
+		return res;
+	}
+
+	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, t4_dma_map_addr, ppaddr, 0);
+	if (res) {
+		bus_dmamem_free(*ptag, *pvaddr, *pmap);
+		*pvaddr = NULL;
+
+		bus_dmamap_destroy(*ptag, *pmap);
+		*pmap = NULL;
+
+		bus_dma_tag_destroy(*ptag);
+		*ptag = NULL;
+		return res;
+	}
+
+	return 0;
+}
+
+static void
+t4_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
+{
+	if (*ppaddr != 0) {
+		bus_dmamap_unload(*ptag, *pmap);
+		*ppaddr = 0;
+	}
+	if (*pvaddr != NULL) {
+		bus_dmamem_free(*ptag, *pvaddr, *pmap);
+		*pvaddr = NULL;
+
+		bus_dmamap_destroy(*ptag, *pmap);
+		*pmap = NULL;
+	}
+	if (*ptag != NULL) {
+		bus_dma_tag_destroy(*ptag);
+		*ptag = NULL;
+	}
 }
 
 static int
 t4_device_probe(device_t dev)
 {
-        struct pci_device_id *id;
+	struct pci_device_id *id;
 	struct devtype *dt;
 
-	id = t4_pci_device_id_lookup(dev);
+	id = dahdi_pci_device_id_lookup(dev, t4_pci_tbl);
 	if (id == NULL)
 		return ENXIO;
 
@@ -4656,76 +4699,15 @@
 	return (0);
 }
 
-static void
-t4_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
-	uint32_t *paddr = arg;
-	*paddr = segs->ds_addr;
-}
-
-static int
-t4_dma_allocate(int size, bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	int res;
-
-	res = bus_dma_tag_create(NULL, 8, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, ptag);
-	if (res)
-		return res;
-
-	res = bus_dmamem_alloc(*ptag, pvaddr, BUS_DMA_NOWAIT | BUS_DMA_ZERO, pmap);
-	if (res) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return res;
-	}
-
-	res = bus_dmamap_load(*ptag, *pmap, *pvaddr, size, t4_dma_map_addr, ppaddr, 0);
-	if (res) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-		return res;
-	}
-
-	return 0;
-}
-
-static void
-t4_dma_free(bus_dma_tag_t *ptag, bus_dmamap_t *pmap, void **pvaddr, uint32_t *ppaddr)
-{
-	if (*ppaddr != 0) {
-		bus_dmamap_unload(*ptag, *pmap);
-		*ppaddr = 0;
-	}
-	if (*pvaddr != NULL) {
-		bus_dmamem_free(*ptag, *pvaddr, *pmap);
-		*pvaddr = NULL;
-
-		bus_dmamap_destroy(*ptag, *pmap);
-		*pmap = NULL;
-	}
-	if (*ptag != NULL) {
-		bus_dma_tag_destroy(*ptag);
-		*ptag = NULL;
-	}
-}
-
 static int
 t4_device_attach(device_t dev)
 {
 	int res;
-        struct pci_device_id *id;
+	struct pci_device_id *id;
 	struct devtype *dt;
 	struct t4 *wc;
 
-	id = t4_pci_device_id_lookup(dev);
+	id = dahdi_pci_device_id_lookup(dev, t4_pci_tbl);
 	if (id == NULL)
 		return ENXIO;
 
@@ -4775,21 +4757,21 @@
 static int
 t4_device_shutdown(device_t dev)
 {
-	DPRINTF(dev, "wct4xxp shutdown\n");
+	DPRINTF(dev, "%s shutdown\n", device_get_name(dev));
 	return (0);
 }
 
 static int
 t4_device_suspend(device_t dev)
 {
-	DPRINTF(dev, "wct4xxp suspend\n");
+	DPRINTF(dev, "%s suspend\n", device_get_name(dev));
 	return (0);
 }
 
 static int
 t4_device_resume(device_t dev)
 {
-	DPRINTF(dev, "wct4xxp resume\n");
+	DPRINTF(dev, "%s resume\n", device_get_name(dev));
 	return (0);
 }
 
@@ -4815,8 +4797,7 @@
 MODULE_DEPEND(wct4xxp, pci, 1, 1, 1);
 MODULE_DEPEND(wct4xxp, dahdi, 1, 1, 1);
 MODULE_DEPEND(wct4xxp, firmware, 1, 1, 1);
-
-#else
+#else /* !__FreeBSD__ */
 static int
 t4_setup_intr(struct t4 *wc, struct devtype *dt)
 {
@@ -4957,6 +4938,7 @@
 MODULE_DESCRIPTION("Wildcard Dual-/Quad-port Digital Card Driver");
 MODULE_ALIAS("wct2xxp");
 MODULE_LICENSE("GPL v2");
+#endif /* !__FreeBSD__ */
 
 module_param(pedanticpci, int, 0600);
 module_param(debug, int, 0600);
@@ -4977,8 +4959,9 @@
 module_param(dtmfthreshold, int, 0600);
 #endif
 
+#if !defined(__FreeBSD__)
 MODULE_DEVICE_TABLE(pci, t4_pci_tbl);
 
 module_init(t4_init);
 module_exit(t4_cleanup);
-#endif
+#endif /* !__FreeBSD__ */




More information about the svn-commits mailing list