[PATCH 02/21] staging: brcm80211: Remove abstraction of pci_(alloc/free)_consistent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Brett Rudley <brudley@xxxxxxxxxxxx>

The abstraction for allocating and freeing dma descriptor memory
has been removed and replaced by usage of pci_alloc_consistent and
pci_free_consistent.

Reviewed-by: Roland Vossen <rvossen@xxxxxxxxxxxx>
Signed-off-by: Arend van Spriel <arend@xxxxxxxxxxxx>
---
 drivers/staging/brcm80211/include/osl.h    |   16 -----------
 drivers/staging/brcm80211/util/hnddma.c    |   40 +++++++++++++++++++---------
 drivers/staging/brcm80211/util/linux_osl.c |   22 ---------------
 3 files changed, 27 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/brcm80211/include/osl.h b/drivers/staging/brcm80211/include/osl.h
index 49015bd..c3800d0 100644
--- a/drivers/staging/brcm80211/include/osl.h
+++ b/drivers/staging/brcm80211/include/osl.h
@@ -50,22 +50,6 @@ extern uint osl_pci_slot(struct osl_info *osh);
 
 #define BUS_SWAP32(v)		(v)
 
-extern void *osl_dma_alloc_consistent(struct osl_info *osh, uint size,
-				      u16 align, uint *tot, unsigned long *pap);
-
-#ifdef BRCM_FULLMAC
-#define	DMA_ALLOC_CONSISTENT(osh, size, pap, dmah, alignbits) \
-	osl_dma_alloc_consistent((osh), (size), (0), (tot), (pap))
-#else
-#define	DMA_ALLOC_CONSISTENT(osh, size, align, tot, pap, dmah) \
-	osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap))
-#endif /* BRCM_FULLMAC */
-
-#define	DMA_FREE_CONSISTENT(osh, va, size, pa, dmah) \
-	osl_dma_free_consistent((osh), (void *)(va), (size), (pa))
-extern void osl_dma_free_consistent(struct osl_info *osh, void *va,
-				    uint size, unsigned long pa);
-
 /* map/unmap direction */
 #define	DMA_TX	1		/* TX direction for DMA */
 #define	DMA_RX	2		/* RX direction for DMA */
diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c
index a5e887e..5e8d3db 100644
--- a/drivers/staging/brcm80211/util/hnddma.c
+++ b/drivers/staging/brcm80211/util/hnddma.c
@@ -32,6 +32,10 @@
 #include <asm/addrspace.h>
 #endif
 
+#ifdef BRCM_FULLMAC
+#error "hnddma.c shouldn't be needed for FULLMAC"
+#endif
+
 /* debug/trace */
 #ifdef BCMDBG
 #define	DMA_ERROR(args) \
@@ -527,6 +531,18 @@ static bool _dma_alloc(dma_info_t *di, uint direction)
 	return dma64_alloc(di, direction);
 }
 
+void *dma_alloc_consistent(struct osl_info *osh, uint size, u16 align_bits,
+			       uint *alloced, unsigned long *pap)
+{
+	if (align_bits) {
+		u16 align = (1 << align_bits);
+		if (!IS_ALIGNED(PAGE_SIZE, align))
+			size += align;
+		*alloced = size;
+	}
+	return pci_alloc_consistent(osh->pdev, size, (dma_addr_t *) pap);
+}
+
 /* !! may be called with core in reset */
 static void _dma_detach(dma_info_t *di)
 {
@@ -539,15 +555,13 @@ static void _dma_detach(dma_info_t *di)
 
 	/* free dma descriptor rings */
 	if (di->txd64)
-		DMA_FREE_CONSISTENT(di->osh,
-				    ((s8 *)di->txd64 -
-				    di->txdalign), di->txdalloc,
-				    (di->txdpaorig), &di->tx_dmah);
+		pci_free_consistent(di->osh->pdev, di->txdalloc,
+				    ((s8 *)di->txd64 - di->txdalign),
+				    (di->txdpaorig));
 	if (di->rxd64)
-		DMA_FREE_CONSISTENT(di->osh,
-				    ((s8 *)di->rxd64 -
-				    di->rxdalign), di->rxdalloc,
-				    (di->rxdpaorig), &di->rx_dmah);
+		pci_free_consistent(di->osh->pdev, di->rxdalloc,
+				    ((s8 *)di->rxd64 - di->rxdalign),
+				    (di->rxdpaorig));
 
 	/* free packet pointer vectors */
 	if (di->txp)
@@ -1080,8 +1094,8 @@ static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size,
 	u32 desc_strtaddr;
 	u32 alignbytes = 1 << *alignbits;
 
-	va = DMA_ALLOC_CONSISTENT(osh, size, *alignbits, alloced, descpa,
-		dmah);
+	va = dma_alloc_consistent(osh, size, *alignbits, alloced, descpa);
+
 	if (NULL == va)
 		return NULL;
 
@@ -1089,9 +1103,9 @@ static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size,
 	if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr
 							& boundary)) {
 		*alignbits = dma_align_sizetobits(size);
-		DMA_FREE_CONSISTENT(osh, va, size, *descpa, dmah);
-		va = DMA_ALLOC_CONSISTENT(osh, size, *alignbits, alloced,
-					  descpa, dmah);
+		pci_free_consistent(osh->pdev, size, va, *descpa);
+		va = dma_alloc_consistent(osh, size, *alignbits,
+			alloced, descpa);
 	}
 	return va;
 }
diff --git a/drivers/staging/brcm80211/util/linux_osl.c b/drivers/staging/brcm80211/util/linux_osl.c
index c0b06f9..bcbce6e 100644
--- a/drivers/staging/brcm80211/util/linux_osl.c
+++ b/drivers/staging/brcm80211/util/linux_osl.c
@@ -139,28 +139,6 @@ uint osl_pci_slot(struct osl_info *osh)
 	return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn);
 }
 
-void *osl_dma_alloc_consistent(struct osl_info *osh, uint size, u16 align_bits,
-			       uint *alloced, unsigned long *pap)
-{
-	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
-
-	if (align_bits) {
-		u16 align = (1 << align_bits);
-		if (!IS_ALIGNED(PAGE_SIZE, align))
-			size += align;
-		*alloced = size;
-	}
-	return pci_alloc_consistent(osh->pdev, size, (dma_addr_t *) pap);
-}
-
-void osl_dma_free_consistent(struct osl_info *osh, void *va, uint size,
-			     unsigned long pa)
-{
-	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
-
-	pci_free_consistent(osh->pdev, size, va, (dma_addr_t) pa);
-}
-
 #if defined(BCMDBG_ASSERT)
 void osl_assert(char *exp, char *file, int line)
 {
-- 
1.7.1


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux