From aacd178373413163d051d75c0fcabe65bcc74cea Mon Sep 17 00:00:00 2001 From: Jaewon Kim Date: Fri, 9 Dec 2016 14:05:30 +0900 Subject: staging: android: ion: return -ENOMEM in ion_cma_heap allocation failure Initial Commit 349c9e138551 ("gpu: ion: add CMA heap") returns -1 in allocation failure. The returned value is passed up to userspace through ioctl. So user can misunderstand error reason as -EPERM(1) rather than -ENOMEM(12). This patch simply changed this to return -ENOMEM. Signed-off-by: Jaewon Kim Acked-by: Laura Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_cma_heap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging/android') diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 6c7de74bc7ab..22b958259dea 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); @@ -88,7 +86,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) -- cgit v1.2.3-59-g8ed1b From 34f973de38d51d5fe264644aced9c33afca7e8a5 Mon Sep 17 00:00:00 2001 From: Bogdan Purcareata Date: Fri, 13 Jan 2017 00:01:53 +0200 Subject: staging: android/ion: Split function call Fix checkpatch error of line exceeding 80 characters. Signed-off-by: Bogdan Purcareata Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion-ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging/android') diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c index 7e7431d8d49f..9ff815ad1cb1 100644 --- a/drivers/staging/android/ion/ion-ioctl.c +++ b/drivers/staging/android/ion/ion-ioctl.c @@ -111,7 +111,8 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct ion_handle *handle; mutex_lock(&client->lock); - handle = ion_handle_get_by_id_nolock(client, data.handle.handle); + handle = ion_handle_get_by_id_nolock(client, + data.handle.handle); if (IS_ERR(handle)) { mutex_unlock(&client->lock); return PTR_ERR(handle); -- cgit v1.2.3-59-g8ed1b From 250c23fc78252844fb35c2a054babbe78de96553 Mon Sep 17 00:00:00 2001 From: Bogdan Purcareata Date: Fri, 13 Jan 2017 00:01:54 +0200 Subject: staging: android/ion: Don't use return in void function Return statements are superfluous in void functions, and checkpatch complains about them too. Remove offending return. Signed-off-by: Bogdan Purcareata Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_of.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging/android') diff --git a/drivers/staging/android/ion/ion_of.c b/drivers/staging/android/ion/ion_of.c index 46b2bb99bfd6..7791c705ea31 100644 --- a/drivers/staging/android/ion/ion_of.c +++ b/drivers/staging/android/ion/ion_of.c @@ -161,7 +161,6 @@ static int rmem_ion_device_init(struct reserved_mem *rmem, struct device *dev) static void rmem_ion_device_release(struct reserved_mem *rmem, struct device *dev) { - return; } static const struct reserved_mem_ops rmem_dma_ops = { -- cgit v1.2.3-59-g8ed1b From d71f1be79569970046287af5bc2cfce9d5ab4c50 Mon Sep 17 00:00:00 2001 From: Bogdan Purcareata Date: Fri, 13 Jan 2017 00:01:55 +0200 Subject: staging: android/ion: Align comment mark Fix missing space right before multiple line comment closing. Signed-off-by: Bogdan Purcareata Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/android') diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 3c3b3245275d..00d8b53b608e 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -54,7 +54,7 @@ * handle, used for debugging * @pid: pid of last client to reference this buffer in a * handle, used for debugging -*/ + */ struct ion_buffer { struct kref ref; union { -- cgit v1.2.3-59-g8ed1b From 68108516d7a163e6cb444eca3d59113f834a26cf Mon Sep 17 00:00:00 2001 From: Bogdan Purcareata Date: Fri, 13 Jan 2017 00:01:56 +0200 Subject: staging: android/ion: Use variable names in header Populate header function signatures with variable names as well, not just variable types. Signed-off-by: Bogdan Purcareata Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_priv.h | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'drivers/staging/android') diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 00d8b53b608e..5b3059c78431 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -287,10 +287,10 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap); * some helpers for common operations on buffers using the sg_table * and vaddr fields */ -void *ion_heap_map_kernel(struct ion_heap *, struct ion_buffer *); -void ion_heap_unmap_kernel(struct ion_heap *, struct ion_buffer *); -int ion_heap_map_user(struct ion_heap *, struct ion_buffer *, - struct vm_area_struct *); +void *ion_heap_map_kernel(struct ion_heap *heap, struct ion_buffer *buffer); +void ion_heap_unmap_kernel(struct ion_heap *heap, struct ion_buffer *buffer); +int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, + struct vm_area_struct *vma); int ion_heap_buffer_zero(struct ion_buffer *buffer); int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot); @@ -371,21 +371,21 @@ size_t ion_heap_freelist_size(struct ion_heap *heap); * heaps as appropriate. */ -struct ion_heap *ion_heap_create(struct ion_platform_heap *); -void ion_heap_destroy(struct ion_heap *); -struct ion_heap *ion_system_heap_create(struct ion_platform_heap *); -void ion_system_heap_destroy(struct ion_heap *); +struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data); +void ion_heap_destroy(struct ion_heap *heap); +struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused); +void ion_system_heap_destroy(struct ion_heap *heap); -struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *); -void ion_system_contig_heap_destroy(struct ion_heap *); +struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *heap); +void ion_system_contig_heap_destroy(struct ion_heap *heap); -struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *); -void ion_carveout_heap_destroy(struct ion_heap *); +struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *heap_data); +void ion_carveout_heap_destroy(struct ion_heap *heap); -struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *); -void ion_chunk_heap_destroy(struct ion_heap *); -struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *); -void ion_cma_heap_destroy(struct ion_heap *); +struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data); +void ion_chunk_heap_destroy(struct ion_heap *heap); +struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *data); +void ion_cma_heap_destroy(struct ion_heap *heap); /** * functions for creating and destroying a heap pool -- allows you @@ -427,9 +427,9 @@ struct ion_page_pool { struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order, bool cached); -void ion_page_pool_destroy(struct ion_page_pool *); -struct page *ion_page_pool_alloc(struct ion_page_pool *); -void ion_page_pool_free(struct ion_page_pool *, struct page *); +void ion_page_pool_destroy(struct ion_page_pool *pool); +struct page *ion_page_pool_alloc(struct ion_page_pool *pool); +void ion_page_pool_free(struct ion_page_pool *pool, struct page *page); /** ion_page_pool_shrink - shrinks the size of the memory cached in the pool * @pool: the pool -- cgit v1.2.3-59-g8ed1b From 8a0e4b9e469c7bbaa206d81e2e7515e1abb1aa00 Mon Sep 17 00:00:00 2001 From: "Youngdo, Lee" Date: Sat, 11 Feb 2017 00:29:15 +0900 Subject: staging: android: ion: fix coding style issue Replaced sizeof(struct foo) into sizeof(*ptr), found by checkpatch.pl. Signed-off-by: Youngdo, Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_cma_heap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/android') diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 22b958259dea..6c4068523781 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -55,7 +55,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (align > PAGE_SIZE) return -EINVAL; - info = kzalloc(sizeof(struct ion_cma_buffer_info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -67,7 +67,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, goto err; } - info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); + info->table = kmalloc(sizeof(*info->table), GFP_KERNEL); if (!info->table) goto free_mem; @@ -140,7 +140,7 @@ struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *data) { struct ion_cma_heap *cma_heap; - cma_heap = kzalloc(sizeof(struct ion_cma_heap), GFP_KERNEL); + cma_heap = kzalloc(sizeof(*cma_heap), GFP_KERNEL); if (!cma_heap) return ERR_PTR(-ENOMEM); -- cgit v1.2.3-59-g8ed1b