[PATCH 3/3] staging: brcm80211: Coalesce osl_dma_alloc_consistent between fullmac and softmac

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

 



Merge the two different implementations of osl_dma_alloc_consistent.

Signed-off-by: Brett Rudley <brudley@xxxxxxxxxxxx>
---
 drivers/staging/brcm80211/include/linux_osl.h |   18 +++++++++---------
 drivers/staging/brcm80211/util/linux_osl.c    |   19 ++++++-------------
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/brcm80211/include/linux_osl.h b/drivers/staging/brcm80211/include/linux_osl.h
index 1e4a920..d114b1d 100644
--- a/drivers/staging/brcm80211/include/linux_osl.h
+++ b/drivers/staging/brcm80211/include/linux_osl.h
@@ -117,20 +117,20 @@ extern uint osl_malloced(osl_t *osh);
 #define	MALLOC_FAILED(osh)		osl_malloc_failed((osh))
 extern uint osl_malloc_failed(osl_t *osh);
 
+#define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
+extern uint osl_dma_consistent_align(void);
+
+extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align,
+				      uint *tot, unsigned long *pap);
+
 #ifdef BRCM_FULLMAC
-#define	DMA_CONSISTENT_ALIGN	PAGE_SIZE
 #define	DMA_ALLOC_CONSISTENT(osh, size, pap, dmah, alignbits) \
-	osl_dma_alloc_consistent((osh), (size), (pap))
-extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, unsigned long *pap);
+	osl_dma_alloc_consistent((osh), (size), (0), (tot), (pap))
 #else
-/* allocate/free shared (dma-able) consistent memory */
-#define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
 #define	DMA_ALLOC_CONSISTENT(osh, size, align, tot, pap, dmah) \
 	osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap))
-extern uint osl_dma_consistent_align(void);
-extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align,
-				      uint *tot, unsigned long *pap);
-#endif
+#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(osl_t *osh, void *va, uint size, unsigned long pa);
diff --git a/drivers/staging/brcm80211/util/linux_osl.c b/drivers/staging/brcm80211/util/linux_osl.c
index 35ede41..f90b91b 100644
--- a/drivers/staging/brcm80211/util/linux_osl.c
+++ b/drivers/staging/brcm80211/util/linux_osl.c
@@ -510,27 +510,20 @@ uint osl_dma_consistent_align(void)
 	return PAGE_SIZE;
 }
 
-#ifdef BRCM_FULLMAC
-void *osl_dma_alloc_consistent(osl_t *osh, uint size, unsigned long *pap)
-{
-	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
-
-	return pci_alloc_consistent(osh->pdev, size, (dma_addr_t *) pap);
-}
-#else /* !BRCM_FULLMAC */
 void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align_bits,
 			       uint *alloced, unsigned long *pap)
 {
-	u16 align = (1 << align_bits);
 	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
 
-	if (!ISALIGNED(DMA_CONSISTENT_ALIGN, align))
-		size += align;
-	*alloced = size;
+	if (align_bits) {
+		u16 align = (1 << align_bits);
+		if (!ISALIGNED(DMA_CONSISTENT_ALIGN, align))
+			size += align;
+		*alloced = size;
+	}
 
 	return pci_alloc_consistent(osh->pdev, size, (dma_addr_t *) pap);
 }
-#endif /* BRCM_FULLMAC */
 
 void osl_dma_free_consistent(osl_t *osh, void *va, uint size, unsigned long pa)
 {
-- 
1.6.3.3


_______________________________________________
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