media: staging: atomisp: Use kvfree() instead of kfree()/vfree()
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Mon, 10 Jul 2017 19:27:28 +0000 (15:27 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 19 Jul 2017 20:26:57 +0000 (16:26 -0400)
Conditionally calling kfree()/vfree() can be replaced by a call to
kvfree() which handles both kmalloced memory and vmalloced memory.
The resulting wrapper function has been replaced with direct calls
to kvfree().

This change was made with the help of the following Coccinelle
semantic patch:
//<smpl>
@@
expression a;
@@
- if(...) { vfree(a); }
- else { kfree(a); }
+ kvfree(a);
// </smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h

index 97093baf28ac9a46043188511dd5f49990154bf8..7bf5dcd3a2d11665266b63c11d2e5ac2f8277dd1 100644 (file)
@@ -111,19 +111,6 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
        return ptr;
 }
 
-/*
- * Free buffer allocated with atomisp_kernel_malloc()/atomisp_kernel_zalloc
- * helper
- */
-void atomisp_kernel_free(void *ptr)
-{
-       /* Verify if buffer was allocated by vmalloc() or kmalloc() */
-       if (is_vmalloc_addr(ptr))
-               vfree(ptr);
-       else
-               kfree(ptr);
-}
-
 /*
  * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field.
  * subdev->priv is set in mrst.c
@@ -785,7 +772,7 @@ void atomisp_flush_params_queue(struct atomisp_video_pipe *pipe)
                                   struct atomisp_css_params_with_list, list);
                list_del(&param->list);
                atomisp_free_css_parameters(&param->params);
-               atomisp_kernel_free(param);
+               kvfree(param);
        }
 }
 
@@ -1132,7 +1119,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
                                asd->params.dvs_6axis = NULL;
                        atomisp_free_css_parameters(
                                &pipe->frame_params[vb->i]->params);
-                       atomisp_kernel_free(pipe->frame_params[vb->i]);
+                       kvfree(pipe->frame_params[vb->i]);
                        pipe->frame_params[vb->i] = NULL;
                }
 
@@ -4375,7 +4362,7 @@ apply_parameter_failed:
        if (css_param)
                atomisp_free_css_parameters(css_param);
        if (param)
-               atomisp_kernel_free(param);
+               kvfree(param);
 
        return ret;
 }
index 8e6d9df7ad1ac547b295075fe4199c3be558927e..1ccd91172f9823b881a75443ee1b5159e33a1012 100644 (file)
@@ -80,7 +80,6 @@ static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
 */
 void *atomisp_kernel_malloc(size_t bytes);
 void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem);
-void atomisp_kernel_free(void *ptr);
 
 /*
  * Interrupt functions
index ad2c610d2ce36e79a89ce545290c4f0e05118060..36f934d95651d535592d9c692e803f693aad9200 100644 (file)
@@ -1676,7 +1676,7 @@ int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd)
                                stream_info.metadata_info.size);
                if (!asd->params.metadata_user[i]) {
                        while (--i >= 0) {
-                               atomisp_kernel_free(asd->params.metadata_user[i]);
+                               kvfree(asd->params.metadata_user[i]);
                                asd->params.metadata_user[i] = NULL;
                        }
                        return -ENOMEM;
@@ -1692,7 +1692,7 @@ void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd)
 
        for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
                if (asd->params.metadata_user[i]) {
-                       atomisp_kernel_free(asd->params.metadata_user[i]);
+                       kvfree(asd->params.metadata_user[i]);
                        asd->params.metadata_user[i] = NULL;
                }
        }
index d3667132851bca6ce854c7c2014ce5ded1f23d6c..afced4f4eb6a1c05c908e471bdd6de542f51f4fd 100644 (file)
@@ -312,8 +312,6 @@ extern struct device *atomisp_dev;
 
 extern void *atomisp_kernel_malloc(size_t bytes);
 
-extern void atomisp_kernel_free(void *ptr);
-
 #define atomisp_is_wdt_running(a) timer_pending(&(a)->wdt)
 #ifdef ISP2401
 extern void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,