Subject: [PATCH 03/12] uio: uio_pruss: use dmam_alloc_coherent()

From: Andre Heider <[email-masked]>
Date: Sun, 29 Jun 2014 18:21:38 +0200

Replace dma_alloc_coherent() with dmam_alloc_coherent() and remove the
dma_free_coherent() call.

This shaves off 2 vars in the driver data struct.

Signed-off-by: Andre Heider <[email-masked]>
---
 drivers/uio/uio_pruss.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 9ee8fef..c7753b9 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -63,10 +63,8 @@ struct uio_pruss_dev {
 	struct uio_info *info;
 	struct clk *pruss_clk;
 	dma_addr_t sram_paddr;
-	dma_addr_t ddr_paddr;
 	void __iomem *prussio_vaddr;
 	unsigned long sram_vaddr;
-	void *ddr_vaddr;
 	unsigned int hostirq_start;
 	unsigned int pintc_base;
 	struct gen_pool *sram_pool;
@@ -100,10 +98,6 @@ static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev)
 		uio_unregister_device(p);
 		kfree(p->name);
 	}
-	if (gdev->ddr_vaddr) {
-		dma_free_coherent(dev, extram_pool_sz, gdev->ddr_vaddr,
-			gdev->ddr_paddr);
-	}
 	if (gdev->sram_vaddr)
 		gen_pool_free(gdev->sram_pool,
 			      gdev->sram_vaddr,
@@ -119,6 +113,7 @@ static int pruss_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	int ret = -ENODEV, cnt = 0;
 	struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
+	dma_addr_t ddr_paddr;
 
 	gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
 	if (!gdev)
@@ -155,9 +150,8 @@ static int pruss_probe(struct platform_device *pdev)
 		}
 	}
 
-	gdev->ddr_vaddr = dma_alloc_coherent(dev, extram_pool_sz,
-				&(gdev->ddr_paddr), GFP_KERNEL | GFP_DMA);
-	if (!gdev->ddr_vaddr) {
+	if (!dmam_alloc_coherent(dev, extram_pool_sz, &ddr_paddr,
+				 GFP_KERNEL | GFP_DMA)) {
 		dev_err(dev, "Could not allocate external memory\n");
 		goto out_free;
 	}
@@ -174,7 +168,7 @@ static int pruss_probe(struct platform_device *pdev)
 		p->mem[1].size = sram_pool_sz;
 		p->mem[1].memtype = UIO_MEM_PHYS;
 
-		p->mem[2].addr = gdev->ddr_paddr;
+		p->mem[2].addr = ddr_paddr;
 		p->mem[2].size = extram_pool_sz;
 		p->mem[2].memtype = UIO_MEM_PHYS;
 
-- 
1.7.10.4