public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gujulan Elango, Hari Prasath (H.)" <hgujulan@visteon.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"arve@android.com" <arve@android.com>,
	"riandrews@android.com" <riandrews@android.com>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"tixy@linaro.org" <tixy@linaro.org>,
	"sriram@marirs.net.in" <sriram@marirs.net.in>
Cc: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCHv2] staging: android: ion: use the manged version of DMA memory allocation
Date: Wed, 3 Feb 2016 06:49:19 +0000	[thread overview]
Message-ID: <20160203065029.GA20263@IND12F0122> (raw)

From: Hari Prasath Gujulan Elango <hgujulan@visteon.com>

Use the managed version of the dma_alloc_coherent() i.e. the
dmam_alloc_coherent() & accordingly cleanup the error handling
part.Also,remove the references to dma_free_coherent

Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
---
	v2:kbuild test robot reported warnings on ununsed
	   variables.Those warnings are fixed.
---
 drivers/staging/android/ion/ion_cma_heap.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
index a3446da..8cd720b 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer,
 	if (!info)
 		return ION_CMA_ALLOCATE_FAILED;
 
-	info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
+	info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle),
 						GFP_HIGHUSER | __GFP_ZERO);
 
 	if (!info->cpu_addr) {
@@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer,
 
 	info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
 	if (!info->table)
-		goto free_mem;
+		goto err;
 
 	if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle,
 			    len))
@@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer,
 
 free_table:
 	kfree(info->table);
-free_mem:
-	dma_free_coherent(dev, len, info->cpu_addr, info->handle);
 err:
 	kfree(info);
 	return ION_CMA_ALLOCATE_FAILED;
@@ -92,13 +90,8 @@ err:
 
 static void ion_cma_free(struct ion_buffer *buffer)
 {
-	struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap);
-	struct device *dev = cma_heap->dev;
 	struct ion_cma_buffer_info *info = buffer->priv_virt;
 
-	dev_dbg(dev, "Release buffer %p\n", buffer);
-	/* release memory */
-	dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle);
 	/* release sg table */
 	sg_free_table(info->table);
 	kfree(info->table);
-- 
1.9.1

             reply	other threads:[~2016-02-03  6:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03  6:49 Gujulan Elango, Hari Prasath (H.) [this message]
2016-02-03 12:03 ` [PATCHv2] staging: android: ion: use the manged version of DMA memory allocation Robin Murphy
2016-02-03 18:11   ` Laura Abbott
2016-02-04  4:59     ` Gujulan Elango, Hari Prasath (H.)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160203065029.GA20263@IND12F0122 \
    --to=hgujulan@visteon.com \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riandrews@android.com \
    --cc=robin.murphy@arm.com \
    --cc=sriram@marirs.net.in \
    --cc=tixy@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox