[svn-commits] sruffell: branch linux/sruffell/dahdi-linux-wctc4xxp r8687 - /linux/team/sruf...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon May 24 14:46:43 CDT 2010


Author: sruffell
Date: Mon May 24 14:46:41 2010
New Revision: 8687

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8687
Log:
wctc4xxp: Move from I/O space to memory-mapped registers.

Certain platforms have trouble with the registers mapped
from I/O space. DAHDI-627.

Modified:
    linux/team/sruffell/dahdi-linux-wctc4xxp/drivers/dahdi/wctc4xxp/base.c

Modified: linux/team/sruffell/dahdi-linux-wctc4xxp/drivers/dahdi/wctc4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-wctc4xxp/drivers/dahdi/wctc4xxp/base.c?view=diff&rev=8687&r1=8686&r2=8687
==============================================================================
--- linux/team/sruffell/dahdi-linux-wctc4xxp/drivers/dahdi/wctc4xxp/base.c (original)
+++ linux/team/sruffell/dahdi-linux-wctc4xxp/drivers/dahdi/wctc4xxp/base.c Mon May 24 14:46:41 2010
@@ -359,7 +359,7 @@
 	 * physical interface to the transcoding engine.  */
 	struct pci_dev *pdev;
 	unsigned int   intmask;
-	unsigned long  iobase;
+	void __iomem	*iobase;
 	struct wctc4xxp_descriptor_ring *txd;
 	struct wctc4xxp_descriptor_ring *rxd;
 
@@ -981,13 +981,14 @@
 static inline void
 __wctc4xxp_setctl(struct wcdte *wc, unsigned int addr, unsigned int val)
 {
-	outl(val, wc->iobase + addr);
+	writel(val, wc->iobase + addr);
+	readl(wc->iobase + addr);
 }
 
 static inline unsigned int
 __wctc4xxp_getctl(struct wcdte *wc, unsigned int addr)
 {
-	return inl(wc->iobase + addr);
+	return readl(wc->iobase + addr);
 }
 
 static inline void
@@ -3343,6 +3344,13 @@
 	return pos;
 }
 
+static void wctc4xxp_remove_from_device_list(struct wcdte *wc)
+{
+	spin_lock(&wctc4xxp_list_lock);
+	list_del(&wc->node);
+	spin_unlock(&wctc4xxp_list_lock);
+}
+
 struct wctc4xxp_desc {
 	const char *short_name;
 	const char *long_name;
@@ -3387,11 +3395,20 @@
 	position_on_list = wctc4xxp_add_to_device_list(wc);
 	snprintf(wc->board_name, sizeof(wc->board_name)-1, "%s%d",
 		d->short_name, position_on_list);
-	wc->iobase           = pci_resource_start(pdev, 0);
+	wc->iobase           = pci_iomap(pdev, 1, 0);
 	wc->pdev             = pdev;
 	wc->pos              = position_on_list;
 	wc->variety          = d->long_name;
 	wc->last_rx_seq_num  = -1;
+
+	if (!request_mem_region(pci_resource_start(pdev, 1),
+	    pci_resource_len(pdev, 1), wc->board_name)) {
+		dev_err(&pdev->dev, "IO Registers are in use by another "
+			"module.\n");
+		wctc4xxp_remove_from_device_list(wc);
+		kfree(wc);
+		return -EIO;
+	}
 
 	init_MUTEX(&wc->chansem);
 	spin_lock_init(&wc->reglock);
@@ -3408,18 +3425,13 @@
 #endif
 	DTE_PRINTK(INFO, "Attached to device at %s.\n", pci_name(wc->pdev));
 
-	/* Keep track of whether we need to free the region */
-	if (!request_region(wc->iobase, 0xff, wc->board_name)) {
-		/* \todo put in error message. */
-		DTE_PRINTK(WARNING,
-		    "Failed to reserve the I/O ports for this device.\n");
-		return -EIO;
-	}
-
 	init_waitqueue_head(&wc->waitq);
 
 	if (pci_set_dma_mask(wc->pdev, DMA_BIT_MASK(32))) {
-		release_region(wc->iobase, 0xff);
+		release_mem_region(pci_resource_start(wc->pdev, 1),
+			pci_resource_len(wc->pdev, 1));
+		if (wc->iobase)
+			pci_iounmap(wc->pdev, wc->iobase);
 		DTE_PRINTK(WARNING, "No suitable DMA available.\n");
 		return -EIO;
 	}
@@ -3582,10 +3594,11 @@
 	kfree(wc->txd);
 	wctc4xxp_cleanup_descriptor_ring(wc->rxd);
 	kfree(wc->rxd);
-	release_region(wc->iobase, 0xff);
-	spin_lock(&wctc4xxp_list_lock);
-	list_del(&wc->node);
-	spin_unlock(&wctc4xxp_list_lock);
+	release_mem_region(pci_resource_start(wc->pdev, 1),
+		pci_resource_len(wc->pdev, 1));
+	if (wc->iobase)
+		pci_iounmap(wc->pdev, wc->iobase);
+	wctc4xxp_remove_from_device_list(wc);
 	kfree(wc);
 	return res;
 }
@@ -3611,9 +3624,7 @@
 	if (!wc)
 		return;
 
-	spin_lock(&wctc4xxp_list_lock);
-	list_del(&wc->node);
-	spin_unlock(&wctc4xxp_list_lock);
+	wctc4xxp_remove_from_device_list(wc);
 
 	set_bit(DTE_SHUTDOWN, &wc->flags);
 	if (del_timer_sync(&wc->watchdog))
@@ -3641,7 +3652,10 @@
 	dahdi_transcoder_unregister(wc->uencode);
 
 	/* Free Resources */
-	release_region(wc->iobase, 0xff);
+	release_mem_region(pci_resource_start(wc->pdev, 1),
+		pci_resource_len(wc->pdev, 1));
+	if (wc->iobase)
+		pci_iounmap(wc->pdev, wc->iobase);
 	wctc4xxp_cleanup_descriptor_ring(wc->txd);
 	kfree(wc->txd);
 	wctc4xxp_cleanup_descriptor_ring(wc->rxd);




More information about the svn-commits mailing list