* [RFC] ion:change ion_cma_allocate return error value
@ 2015-01-27 6:04 Wang, Yalin
2015-01-27 7:26 ` Dan Carpenter
2015-01-28 18:45 ` 'gregkh@linuxfoundation.org'
0 siblings, 2 replies; 4+ messages in thread
From: Wang, Yalin @ 2015-01-27 6:04 UTC (permalink / raw)
To: 'gregkh@linuxfoundation.org',
'tranmanphong@gmail.com',
'fabio.estevam@freescale.com',
'prime.zeng@huawei.com',
'devel@driverdev.osuosl.org',
'linux-kernel@vger.kernel.org'
Cc: Gao, Neil
This patch change the error return value from -1 to -ENOMEM,
so that userspace can get the correct errno, otherwise,
-1 will be -EPERM, userspace will print permission deny for allocation
failure.
Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
drivers/staging/android/ion/ion_cma_heap.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
index f4211f1..55bcaec2 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -24,8 +24,6 @@
#include "ion.h"
#include "ion_priv.h"
-#define ION_CMA_ALLOCATE_FAILED -1
-
struct ion_cma_heap {
struct ion_heap heap;
struct device *dev;
@@ -59,7 +57,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer,
info = kzalloc(sizeof(struct ion_cma_buffer_info), GFP_KERNEL);
if (!info)
- return ION_CMA_ALLOCATE_FAILED;
+ return -ENOMEM;
info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
GFP_HIGHUSER | __GFP_ZERO);
@@ -87,7 +85,7 @@ free_mem:
dma_free_coherent(dev, len, info->cpu_addr, info->handle);
err:
kfree(info);
- return ION_CMA_ALLOCATE_FAILED;
+ return -ENOMEM;
}
static void ion_cma_free(struct ion_buffer *buffer)
--
2.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC] ion:change ion_cma_allocate return error value
2015-01-27 6:04 [RFC] ion:change ion_cma_allocate return error value Wang, Yalin
@ 2015-01-27 7:26 ` Dan Carpenter
2015-01-28 18:45 ` 'gregkh@linuxfoundation.org'
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-01-27 7:26 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'gregkh@linuxfoundation.org',
'tranmanphong@gmail.com',
'fabio.estevam@freescale.com',
'prime.zeng@huawei.com',
'devel@driverdev.osuosl.org',
'linux-kernel@vger.kernel.org',
Gao, Neil
On Tue, Jan 27, 2015 at 02:04:21PM +0800, Wang, Yalin wrote:
> This patch change the error return value from -1 to -ENOMEM,
> so that userspace can get the correct errno, otherwise,
> -1 will be -EPERM, userspace will print permission deny for allocation
> failure.
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Looks good.
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] ion:change ion_cma_allocate return error value
2015-01-27 6:04 [RFC] ion:change ion_cma_allocate return error value Wang, Yalin
2015-01-27 7:26 ` Dan Carpenter
@ 2015-01-28 18:45 ` 'gregkh@linuxfoundation.org'
2015-01-29 1:41 ` Wang, Yalin
1 sibling, 1 reply; 4+ messages in thread
From: 'gregkh@linuxfoundation.org' @ 2015-01-28 18:45 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'tranmanphong@gmail.com',
'fabio.estevam@freescale.com',
'prime.zeng@huawei.com',
'devel@driverdev.osuosl.org',
'linux-kernel@vger.kernel.org',
Gao, Neil
On Tue, Jan 27, 2015 at 02:04:21PM +0800, Wang, Yalin wrote:
> This patch change the error return value from -1 to -ENOMEM,
> so that userspace can get the correct errno, otherwise,
> -1 will be -EPERM, userspace will print permission deny for allocation
> failure.
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> ---
> drivers/staging/android/ion/ion_cma_heap.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Don't you also need to now change userspace code to properly handle
these errors?
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [RFC] ion:change ion_cma_allocate return error value
2015-01-28 18:45 ` 'gregkh@linuxfoundation.org'
@ 2015-01-29 1:41 ` Wang, Yalin
0 siblings, 0 replies; 4+ messages in thread
From: Wang, Yalin @ 2015-01-29 1:41 UTC (permalink / raw)
To: 'gregkh@linuxfoundation.org'
Cc: 'tranmanphong@gmail.com',
'fabio.estevam@freescale.com',
'prime.zeng@huawei.com',
'devel@driverdev.osuosl.org',
'linux-kernel@vger.kernel.org',
Gao, Neil
> -----Original Message-----
> From: 'gregkh@linuxfoundation.org' [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, January 29, 2015 2:45 AM
> To: Wang, Yalin
> Cc: 'tranmanphong@gmail.com'; 'fabio.estevam@freescale.com';
> 'prime.zeng@huawei.com'; 'devel@driverdev.osuosl.org'; 'linux-
> kernel@vger.kernel.org'; Gao, Neil
> Subject: Re: [RFC] ion:change ion_cma_allocate return error value
>
> On Tue, Jan 27, 2015 at 02:04:21PM +0800, Wang, Yalin wrote:
> > This patch change the error return value from -1 to -ENOMEM, so that
> > userspace can get the correct errno, otherwise,
> > -1 will be -EPERM, userspace will print permission deny for allocation
> > failure.
> >
> > Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
> > ---
> > drivers/staging/android/ion/ion_cma_heap.c | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
>
> Don't you also need to now change userspace code to properly handle these
> errors?
>
No, because userspace use strerror() to print errno,
It will print correct error string depending on kernel return
Errno.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-29 1:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 6:04 [RFC] ion:change ion_cma_allocate return error value Wang, Yalin
2015-01-27 7:26 ` Dan Carpenter
2015-01-28 18:45 ` 'gregkh@linuxfoundation.org'
2015-01-29 1:41 ` Wang, Yalin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.