atomisp: remove most of the uses of atomisp_kernel_malloc
authorAlan Cox <alan@linux.intel.com>
Wed, 12 Apr 2017 18:21:05 +0000 (19:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Apr 2017 08:06:26 +0000 (10:06 +0200)
They can be replaced by kmalloc. There are a few that do need to pick kmalloc
or vmalloc. Those we leave for the moment.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_dynamic_pool.c
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_reserved_pool.c

index 2e20a81091f4d262980a2d9781b3ff01e4d43466..65868429cf18da7b48238406c25f689a7f276321 100644 (file)
@@ -1669,11 +1669,7 @@ int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd)
 
 int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd)
 {
-#ifndef ISP2401
-       int i; /* Coverity CID 298003 - index var must be signed */
-#else
        int i;
-#endif
 
        /* We allocate the cpu-side buffer used for communication with user
         * space */
index 6c4ab5aa2a8d7ca2cb7650d5f458e664f8af5367..40ac3582fb7aba8ee9b58c8b8805626af20a1f4c 100644 (file)
@@ -724,8 +724,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,
 
        pgnr = bo->pgnr;
 
-       bo->page_obj = atomisp_kernel_malloc(
-                               sizeof(struct hmm_page_object) * pgnr);
+       bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr,
+                               GFP_KERNEL);
        if (unlikely(!bo->page_obj)) {
                dev_err(atomisp_dev, "out of memory for bo->page_obj\n");
                return -ENOMEM;
@@ -859,7 +859,7 @@ cleanup:
        alloc_pgnr = i;
        free_private_bo_pages(bo, dypool, repool, alloc_pgnr);
 
-       atomisp_kernel_free(bo->page_obj);
+       kfree(bo->page_obj);
 
        return -ENOMEM;
 }
@@ -870,7 +870,7 @@ static void free_private_pages(struct hmm_buffer_object *bo,
 {
        free_private_bo_pages(bo, dypool, repool, bo->pgnr);
 
-       atomisp_kernel_free(bo->page_obj);
+       kfree(bo->page_obj);
 }
 
 /*
@@ -989,17 +989,17 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
        struct vm_area_struct *vma;
        struct page **pages;
 
-       pages = atomisp_kernel_malloc(sizeof(struct page *) * bo->pgnr);
+       pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL);
        if (unlikely(!pages)) {
                dev_err(atomisp_dev, "out of memory for pages...\n");
                return -ENOMEM;
        }
 
-       bo->page_obj = atomisp_kernel_malloc(
-                               sizeof(struct hmm_page_object) * bo->pgnr);
+       bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr,
+               GFP_KERNEL);
        if (unlikely(!bo->page_obj)) {
                dev_err(atomisp_dev, "out of memory for bo->page_obj...\n");
-               atomisp_kernel_free(pages);
+               kfree(pages);
                return -ENOMEM;
        }
 
@@ -1009,8 +1009,8 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
        up_read(&current->mm->mmap_sem);
        if (vma == NULL) {
                dev_err(atomisp_dev, "find_vma failed\n");
-               atomisp_kernel_free(bo->page_obj);
-               atomisp_kernel_free(pages);
+               kfree(bo->page_obj);
+               kfree(pages);
                mutex_lock(&bo->mutex);
                return -EFAULT;
        }
@@ -1050,15 +1050,15 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
                bo->page_obj[i].type = HMM_PAGE_TYPE_GENERAL;
        }
        hmm_mem_stat.usr_size += bo->pgnr;
-       atomisp_kernel_free(pages);
+       kfree(pages);
 
        return 0;
 
 out_of_mem:
        for (i = 0; i < page_nr; i++)
                put_page(pages[i]);
-       atomisp_kernel_free(pages);
-       atomisp_kernel_free(bo->page_obj);
+       kfree(pages);
+       kfree(bo->page_obj);
 
        return -ENOMEM;
 }
@@ -1071,7 +1071,7 @@ static void free_user_pages(struct hmm_buffer_object *bo)
                put_page(bo->page_obj[i].page);
        hmm_mem_stat.usr_size -= bo->pgnr;
 
-       atomisp_kernel_free(bo->page_obj);
+       kfree(bo->page_obj);
 }
 
 /*
@@ -1362,7 +1362,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached)
                bo->status &= ~(HMM_BO_VMAPED | HMM_BO_VMAPED_CACHED);
        }
 
-       pages = atomisp_kernel_malloc(sizeof(*pages) * bo->pgnr);
+       pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL);
        if (unlikely(!pages)) {
                mutex_unlock(&bo->mutex);
                dev_err(atomisp_dev, "out of memory for pages...\n");
@@ -1375,14 +1375,14 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached)
        bo->vmap_addr = vmap(pages, bo->pgnr, VM_MAP,
                cached ? PAGE_KERNEL : PAGE_KERNEL_NOCACHE);
        if (unlikely(!bo->vmap_addr)) {
-               atomisp_kernel_free(pages);
+               kfree(pages);
                mutex_unlock(&bo->mutex);
                dev_err(atomisp_dev, "vmap failed...\n");
                return NULL;
        }
        bo->status |= (cached ? HMM_BO_VMAPED_CACHED : HMM_BO_VMAPED);
 
-       atomisp_kernel_free(pages);
+       kfree(pages);
 
        mutex_unlock(&bo->mutex);
        return bo->vmap_addr;
index 6e540cc2e451e2da6bcabe91a9b5cf362859e0a8..639b8cdf7a5e79f2bd7bb223d01d07193306cbab 100644 (file)
@@ -149,8 +149,8 @@ static int hmm_dynamic_pool_init(void **pool, unsigned int pool_size)
        if (pool_size == 0)
                return 0;
 
-       dypool_info = atomisp_kernel_malloc(
-                                       sizeof(struct hmm_dynamic_pool_info));
+       dypool_info = kmalloc(sizeof(struct hmm_dynamic_pool_info),
+               GFP_KERNEL);
        if (unlikely(!dypool_info)) {
                dev_err(atomisp_dev, "out of memory for repool_info.\n");
                return -ENOMEM;
@@ -160,7 +160,7 @@ static int hmm_dynamic_pool_init(void **pool, unsigned int pool_size)
                                                sizeof(struct hmm_page), 0,
                                                SLAB_HWCACHE_ALIGN, NULL);
        if (!dypool_info->pgptr_cache) {
-               atomisp_kernel_free(dypool_info);
+               kfree(dypool_info);
                return -ENOMEM;
        }
 
@@ -217,7 +217,7 @@ static void hmm_dynamic_pool_exit(void **pool)
 
        kmem_cache_destroy(dypool_info->pgptr_cache);
 
-       atomisp_kernel_free(dypool_info);
+       kfree(dypool_info);
 
        *pool = NULL;
 }
index 590ff7bc6c5f1ffc4fb40695d89da6e4961b434a..4000c05652e1f7d24e947bc6dee82aafe96d837f 100644 (file)
@@ -89,18 +89,18 @@ static int hmm_reserved_pool_setup(struct hmm_reserved_pool_info **repool_info,
 {
        struct hmm_reserved_pool_info *pool_info;
 
-       pool_info = atomisp_kernel_malloc(
-                                       sizeof(struct hmm_reserved_pool_info));
+       pool_info = kmalloc(sizeof(struct hmm_reserved_pool_info),
+                               GFP_KERNEL);
        if (unlikely(!pool_info)) {
                dev_err(atomisp_dev, "out of memory for repool_info.\n");
                return -ENOMEM;
        }
 
-       pool_info->pages = atomisp_kernel_malloc(
-                                       sizeof(struct page *) * pool_size);
+       pool_info->pages = kmalloc(sizeof(struct page *) * pool_size,
+                       GFP_KERNEL);
        if (unlikely(!pool_info->pages)) {
                dev_err(atomisp_dev, "out of memory for repool_info->pages.\n");
-               atomisp_kernel_free(pool_info);
+               kfree(pool_info);
                return -ENOMEM;
        }
 
@@ -233,8 +233,8 @@ static void hmm_reserved_pool_exit(void **pool)
                        __free_pages(repool_info->pages[i], 0);
        }
 
-       atomisp_kernel_free(repool_info->pages);
-       atomisp_kernel_free(repool_info);
+       kfree(repool_info->pages);
+       kfree(repool_info);
 
        *pool = NULL;
 }