Fix checkpatch issues
Subsystems (4)
v2 cover Fix checkpatch issues
This patchset was created on Julia recommendation to remove 'out of memory' messages and unlikely checks.
* [1/10] kmalloc generates a backtrace on failure and it will show the same information as the removed messages.
* [2/10] unlikely checks are not necessary on NULL pointers after a memory allocation.
Also, new changes were made to improve the code from hmm_bo.c file. Some of the issues were already in the file, others were introduced on previous patches of this set.
These new changes are available on [3/10-10/10] patches.
Changes in v2:
* Nothing changed in 1/10
* New added 2/10 - 10/10
Georgiana Chelu (10):
Staging: media: atomisp: Use kmalloc_array instead of kmalloc
Staging: media: atomisp: Remove useless 'out of memory' messages
Staging: media: atomisp: Remove unlikely from NULL pointer check
Staging: media: atomisp: Adjust checks for null pointers
Staging: media: atomisp: Remove return statement from void function
Staging: media: atomisp: Add spaces around bitwise OR
Staging: media: atomisp: Remove braces {} for single statement blocks
Staging: media: atomisp: Align code with open parenthesis
Staging: media: atomisp: Merge quoted string split across lines
Staging: media: atomisp: Split lines wiht over 80 characters
.../media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 164 ++++++++++----------- 1 file changed, 76 insertions(+), 88 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/10 Staging: media: atomisp: Use kmalloc_array instead of kmalloc
Prefer kmalloc_array over kmalloc with multiply
because kmalloc_array performs additional checks
before memory allocation.
Fix the following issue reported by checkpatch.pl:
* WARNING: Prefer kmalloc_array over kmalloc with multiply
---
Changes in v2:
* nothing changed in the patch
* the patch was added to a patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +4 -4
@@ -725,7 +725,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, pgnr = bo->pgnr; - bo->page_obj =kmalloc (sizeof (struct hmm_page_object ) * pgnr, + bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) {dev_err (atomisp_dev,"out of memory for bo->page_obj\n" );
@@ -990,13 +990,13 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,struct vm_area_struct *vma;struct page **pages; - pages =kmalloc (sizeof (struct page *) * bo->pgnr,GFP_KERNEL ); + pages =kmalloc_array (bo->pgnr,sizeof (struct page *),GFP_KERNEL );if (unlikely (!pages)) {dev_err (atomisp_dev,"out of memory for pages...\n" );return -ENOMEM ; } - bo->page_obj =kmalloc (sizeof (struct hmm_page_object ) * bo->pgnr, + bo->page_obj =kmalloc_array (bo->pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) {dev_err (atomisp_dev,"out of memory for bo->page_obj...\n" );
@@ -1363,7 +1363,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) bo->status &= ~(HMM_BO_VMAPED |HMM_BO_VMAPED_CACHED ); } - pages =kmalloc (sizeof (*pages) * bo->pgnr,GFP_KERNEL ); + pages =kmalloc_array (bo->pgnr,sizeof (*pages),GFP_KERNEL );if (unlikely (!pages)) {mutex_unlock (&bo->mutex);dev_err (atomisp_dev,"out of memory for pages...\n" );
Signature · 1 line
2.7.4
PATCH v2 2/10 Staging: media: atomisp: Remove useless 'out of memory' messages
In reply to Georgiana CheluOOM (Out Of Memory Manager) reports memory allocation fails, so there is no need for the error messages.
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0 -4
@@ -728,7 +728,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) { -dev_err (atomisp_dev,"out of memory for bo->page_obj\n" );return -ENOMEM ; }
@@ -992,14 +991,12 @@ static int alloc_user_pages(struct hmm_buffer_object *bo, pages =kmalloc_array (bo->pgnr,sizeof (struct page *),GFP_KERNEL );if (unlikely (!pages)) { -dev_err (atomisp_dev,"out of memory for pages...\n" );return -ENOMEM ; } bo->page_obj =kmalloc_array (bo->pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) { -dev_err (atomisp_dev,"out of memory for bo->page_obj...\n" );kfree (pages);return -ENOMEM ; }
@@ -1366,7 +1363,6 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) pages =kmalloc_array (bo->pgnr,sizeof (*pages),GFP_KERNEL );if (unlikely (!pages)) {mutex_unlock (&bo->mutex); -dev_err (atomisp_dev,"out of memory for pages...\n" );return NULL ; }
Signature · 1 line
2.7.4
PATCH v2 4/10 Staging: media: atomisp: Adjust checks for null pointers
In reply to Georgiana CheluRewrite the comparison to NULL for better coding style.
Fix issue reported by checkpatch.pl:
* CHECK: Comparison to NULL could be written
---
Changes in v2:
* this is a new patch added to the patchset
.../staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +10 -10
@@ -106,7 +106,7 @@ struct hmm_buffer_object *__bo_search_and_remove_from_free_rbtree( this = rb_entry(node, struct hmm_buffer_object, node);if (this->pgnr == pgnr || - (this->pgnr > pgnr && this->node.rb_left ==NULL )) { + (this->pgnr > pgnr && !this->node.rb_left)) { goto remove_bo_and_return; }else {if (this->pgnr < pgnr) {
@@ -132,7 +132,7 @@ struct hmm_buffer_object *__bo_search_and_remove_from_free_rbtree(* 1. check if 'this->next' is NULL: * yes: erase 'this' node and rebalance rbtree, return 'this'. */ -if (this->next ==NULL ) { +if (!this->next) {rb_erase (&this->node, &this->bdev->free_rbtree);return this; }
@@ -160,11 +160,11 @@ struct hmm_buffer_object *__bo_search_by_addr(struct rb_root *root, bo = rb_entry(n, struct hmm_buffer_object, node);if (bo->start > start) { -if (n->rb_left ==NULL ) +if (!n->rb_left)return NULL ; n = n->rb_left; }else if (bo->start < start) { -if (n->rb_right ==NULL ) +if (!n->rb_right)return NULL ; n = n->rb_right; }else {
@@ -185,13 +185,13 @@ struct hmm_buffer_object *__bo_search_by_addr_in_range(struct rb_root *root, bo = rb_entry(n, struct hmm_buffer_object, node);if (bo->start > start) { -if (n->rb_left ==NULL ) +if (!n->rb_left)return NULL ; n = n->rb_left; }else {if (bo->end > start)return bo; -if (n->rb_right ==NULL ) +if (!n->rb_right)return NULL ; n = n->rb_right; }
@@ -298,14 +298,14 @@ static void __bo_take_off_handling(struct hmm_buffer_object *bo)* and does not have a linked list after bo, to take off this bo, * we just need erase bo directly and rebalance the free rbtree */ -if (bo->prev ==NULL && bo->next ==NULL ) { +if (!bo->prev && !bo->next) {rb_erase (&bo->node, &bdev->free_rbtree);/* 2. when bo->next != NULL && bo->prev == NULL, bo is a rbtree node, * and has a linked list,to take off this bo we need erase bo * first, then, insert bo->next into free rbtree and rebalance * the free rbtree */ - }else if (bo->prev ==NULL && bo->next !=NULL ) { + }else if (!bo->prev && bo->next) { bo->next->prev =NULL ;rb_erase (&bo->node, &bdev->free_rbtree);__bo_insert_to_free_rbtree (&bdev->free_rbtree, bo->next);
@@ -315,7 +315,7 @@ static void __bo_take_off_handling(struct hmm_buffer_object *bo)* node, to take off this bo, we just need set the "prev/next" * pointers to NULL, the free rbtree stays unchaged */ - }else if (bo->prev !=NULL && bo->next ==NULL ) { + }else if (bo->prev && !bo->next) { bo->prev->next =NULL ; bo->prev =NULL ;/* 4. when bo->prev != NULL && bo->next != NULL ,bo is not a rbtree
@@ -1005,7 +1005,7 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,down_read (¤t->mm->mmap_sem); vma =find_vma (current->mm, (unsigned long )userptr);up_read (¤t->mm->mmap_sem); -if (vma ==NULL ) { +if (!vma) {dev_err (atomisp_dev,"find_vma failed\n" );kfree (bo->page_obj);kfree (pages);
Signature · 1 line
2.7.4
PATCH v2 5/10 Staging: media: atomisp: Remove return statement from void function
In reply to Georgiana CheluThe return statement is not useful when it ends a void function.
Issue found by checkpatch.pl:
WARNING: void function return statements are not generally useful
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0 -4
@@ -520,7 +520,6 @@ void hmm_bo_release(struct hmm_buffer_object *bo)__bo_insert_to_free_rbtree (&bdev->free_rbtree, bo);mutex_unlock (&bdev->rbtree_mutex); -return ; }void hmm_bo_device_exit (struct hmm_bo_device *bdev)
@@ -700,8 +699,6 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo,break ; } } - -return ; }/*Allocate pages which will be used only by ISP*/
@@ -1411,7 +1408,6 @@ void hmm_bo_vunmap(struct hmm_buffer_object *bo) }mutex_unlock (&bo->mutex); -return ; }void hmm_bo_ref (struct hmm_buffer_object *bo)
Signature · 1 line
2.7.4
PATCH v2 3/10 Staging: media: atomisp: Remove unlikely from NULL pointer check
In reply to Georgiana CheluRemove unlikely because kmalloc uses it inside the source code.
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +4 -4
@@ -727,7 +727,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL ); -if (unlikely (!bo->page_obj)) { +if (!bo->page_obj) {return -ENOMEM ; }
@@ -990,13 +990,13 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,struct page **pages; pages =kmalloc_array (bo->pgnr,sizeof (struct page *),GFP_KERNEL ); -if (unlikely (!pages)) { +if (!pages) {return -ENOMEM ; } bo->page_obj =kmalloc_array (bo->pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL ); -if (unlikely (!bo->page_obj)) { +if (!bo->page_obj) {kfree (pages);return -ENOMEM ; }
@@ -1361,7 +1361,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) } pages =kmalloc_array (bo->pgnr,sizeof (*pages),GFP_KERNEL ); -if (unlikely (!pages)) { +if (!pages) {mutex_unlock (&bo->mutex);return NULL ; }
Signature · 1 line
2.7.4
PATCH v2 8/10 Staging: media: atomisp: Align code with open parenthesis
In reply to Georgiana CheluImprove the code readability by aligning the code
with the open parenthesis.c
Fix issue reported by checkpatch.pl
* CHECK: Alignment should match open parenthesis
---
Changes in v2:
* this is a new patch added to the patchset
.../media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 119 ++++++++++----------- 1 file changed, 59 insertions(+), 60 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +59 -60
@@ -70,11 +70,11 @@ struct hmm_buffer_object *__bo_alloc(struct kmem_cache *bo_cache) }static int __bo_init (struct hmm_bo_device *bdev,struct hmm_buffer_object *bo, -unsigned int pgnr) +unsigned int pgnr) {check_bodev_null_return (bdev, -EINVAL );var_equal_return (hmm_bo_device_inited (bdev),0 , -EINVAL , -"hmm_bo_device not inited yet.\n" ); +"hmm_bo_device not inited yet.\n" );/* prevent zero size buffer object */ if (pgnr ==0 ) {dev_err (atomisp_dev,"0 size buffer is not allowed.\n" );
@@ -106,7 +106,7 @@ struct hmm_buffer_object *__bo_search_and_remove_from_free_rbtree( this = rb_entry(node, struct hmm_buffer_object, node);if (this->pgnr == pgnr || - (this->pgnr > pgnr && !this->node.rb_left)) { + (this->pgnr > pgnr && !this->node.rb_left)) { goto remove_bo_and_return; }else {if (this->pgnr < pgnr) {
@@ -151,7 +151,7 @@ struct hmm_buffer_object *__bo_search_and_remove_from_free_rbtree( }struct hmm_buffer_object *__bo_search_by_addr (struct rb_root *root, -ia_css_ptr start) +ia_css_ptr start) {struct rb_node *n = root->rb_node;struct hmm_buffer_object *bo;
@@ -176,7 +176,7 @@ struct hmm_buffer_object *__bo_search_by_addr(struct rb_root *root, }struct hmm_buffer_object *__bo_search_by_addr_in_range (struct rb_root *root, -unsigned int start) +unsigned int start) {struct rb_node *n = root->rb_node;struct hmm_buffer_object *bo;
@@ -201,7 +201,7 @@ struct hmm_buffer_object *__bo_search_by_addr_in_range(struct rb_root *root, }static void __bo_insert_to_free_rbtree (struct rb_root *root, -struct hmm_buffer_object *bo) +struct hmm_buffer_object *bo) {struct rb_node **new = &(root->rb_node);struct rb_node *parent =NULL ;
@@ -332,7 +332,7 @@ static void __bo_take_off_handling(struct hmm_buffer_object *bo) }struct hmm_buffer_object *__bo_merge (struct hmm_buffer_object *bo, -struct hmm_buffer_object *next_bo) +struct hmm_buffer_object *next_bo) {struct hmm_bo_device *bdev;unsigned long flags;
@@ -354,9 +354,9 @@ struct hmm_buffer_object *__bo_merge(struct hmm_buffer_object *bo,* hmm_bo_device functions. */ int hmm_bo_device_init (struct hmm_bo_device *bdev, -struct isp_mmu_client *mmu_driver, -unsigned int vaddr_start, -unsigned int size) +struct isp_mmu_client *mmu_driver, +unsigned int vaddr_start, +unsigned int size) {struct hmm_buffer_object *bo;unsigned long flags;
@@ -384,7 +384,7 @@ int hmm_bo_device_init(struct hmm_bo_device *bdev, bdev->free_rbtree =RB_ROOT ; bdev->bo_cache =kmem_cache_create ("bo_cache" , -sizeof (struct hmm_buffer_object ),0 ,0 ,NULL ); +sizeof (struct hmm_buffer_object ),0 ,0 ,NULL );if (!bdev->bo_cache) {dev_err (atomisp_dev,"%s: create cache failed!\n" , __func__);isp_mmu_exit (&bdev->mmu);
@@ -416,14 +416,14 @@ int hmm_bo_device_init(struct hmm_bo_device *bdev, }struct hmm_buffer_object *hmm_bo_alloc (struct hmm_bo_device *bdev, -unsigned int pgnr) +unsigned int pgnr) {struct hmm_buffer_object *bo, *new_bo;struct rb_root *root = &bdev->free_rbtree;check_bodev_null_return (bdev,NULL );var_equal_return (hmm_bo_device_inited (bdev),0 ,NULL , -"hmm_bo_device not inited yet.\n" ); +"hmm_bo_device not inited yet.\n" );if (pgnr ==0 ) {dev_err (atomisp_dev,"0 size buffer is not allowed.\n" );
@@ -504,15 +504,15 @@ void hmm_bo_release(struct hmm_buffer_object *bo) next_bo = list_entry(bo->list.next, struct hmm_buffer_object, list);if (bo->list.prev != &bdev->entire_bo_list && - prev_bo->end == bo->start && - (prev_bo->status &HMM_BO_MASK ) ==HMM_BO_FREE ) { + prev_bo->end == bo->start && + (prev_bo->status &HMM_BO_MASK ) ==HMM_BO_FREE ) {__bo_take_off_handling (prev_bo); bo =__bo_merge (prev_bo, bo); }if (bo->list.next != &bdev->entire_bo_list && - next_bo->start == bo->end && - (next_bo->status &HMM_BO_MASK ) ==HMM_BO_FREE ) { + next_bo->start == bo->end && + (next_bo->status &HMM_BO_MASK ) ==HMM_BO_FREE ) {__bo_take_off_handling (next_bo); bo =__bo_merge (bo, next_bo); }
@@ -642,9 +642,9 @@ struct hmm_buffer_object *hmm_bo_device_search_vmap_start(static void free_private_bo_pages (struct hmm_buffer_object *bo, -struct hmm_pool *dypool, -struct hmm_pool *repool, -int free_pgnr) +struct hmm_pool *dypool, +struct hmm_pool *repool, +int free_pgnr) {int i, ret;
@@ -683,8 +683,7 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo, ret =set_pages_wb (bo->page_obj[i].page,1 );if (ret)dev_err (atomisp_dev, -"set page to WB err ...ret = %d\n" , - ret); +"set page to WB err ...ret = %d\n" , ret);/* W/A: set_pages_wb seldom return value = -EFAULT indicate that address of page is not in valid
@@ -703,10 +702,10 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo,/*Allocate pages which will be used only by ISP*/ static int alloc_private_pages (struct hmm_buffer_object *bo, -int from_highmem, -bool cached, -struct hmm_pool *dypool, -struct hmm_pool *repool) +int from_highmem, +bool cached, +struct hmm_pool *dypool, +struct hmm_pool *repool) {int ret;unsigned int pgnr, order, blk_pgnr, alloc_pgnr;
@@ -723,7 +722,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, pgnr = bo->pgnr; bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ), -GFP_KERNEL ); +GFP_KERNEL );if (!bo->page_obj)return -ENOMEM ;
@@ -735,8 +734,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo,*/ if (dypool->pops && dypool->pops->pool_alloc_pages) { alloc_pgnr = dypool->pops->pool_alloc_pages (dypool->pool_info, - bo->page_obj, pgnr, - cached); + bo->page_obj, pgnr, + cached); hmm_mem_stat.dyc_size -= alloc_pgnr;if (alloc_pgnr == pgnr)
@@ -822,8 +821,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, ret =set_pages_uc (pages, blk_pgnr);if (ret) {dev_err (atomisp_dev, -"set page uncacheable" -"failed.\n" ); +"set page uncacheable" +"failed.\n" );__free_pages (pages, order);
@@ -861,8 +860,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, }static void free_private_pages (struct hmm_buffer_object *bo, -struct hmm_pool *dypool, -struct hmm_pool *repool) +struct hmm_pool *dypool, +struct hmm_pool *repool) {free_private_bo_pages (bo, dypool, repool, bo->pgnr);
@@ -959,8 +958,8 @@ static int __get_pfnmap_pages(struct task_struct *tsk, struct mm_struct *mm, }static int get_pfnmap_pages (struct task_struct *tsk,struct mm_struct *mm, -unsigned long start,int nr_pages,int write,int force, -struct page **pages,struct vm_area_struct **vmas) +unsigned long start,int nr_pages,int write,int force, +struct page **pages,struct vm_area_struct **vmas) {int flags =FOLL_TOUCH ;
@@ -978,7 +977,7 @@ static int get_pfnmap_pages(struct task_struct *tsk, struct mm_struct *mm,* Convert user space virtual address into pages list */ static int alloc_user_pages (struct hmm_buffer_object *bo, -void *userptr,bool cached) +void *userptr,bool cached) {int page_nr;int i;
@@ -990,7 +989,7 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,return -ENOMEM ; bo->page_obj =kmalloc_array (bo->pgnr,sizeof (struct hmm_page_object ), -GFP_KERNEL ); +GFP_KERNEL );if (!bo->page_obj) {kfree (pages);return -ENOMEM ;
@@ -1032,9 +1031,9 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,/* can be written by caller, not forced */ if (page_nr != bo->pgnr) {dev_err (atomisp_dev, -"get_user_pages err: bo->pgnr = %d, " -"pgnr actually pinned = %d.\n" , - bo->pgnr, page_nr); +"get_user_pages err: bo->pgnr = %d, " +"pgnr actually pinned = %d.\n" , + bo->pgnr, page_nr); goto out_of_mem; }
@@ -1099,7 +1098,8 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,*/ if (type ==HMM_BO_PRIVATE ) { ret =alloc_private_pages (bo, from_highmem, - cached, &dynamic_pool, &reserved_pool); + cached, &dynamic_pool, + &reserved_pool); }else if (type ==HMM_BO_USER ) { ret =alloc_user_pages (bo, userptr, cached); }else {
@@ -1124,7 +1124,7 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo, status_err:mutex_unlock (&bo->mutex);dev_err (atomisp_dev, -"buffer object has already page allocated.\n" ); +"buffer object has already page allocated.\n" );return -EINVAL ; }
@@ -1155,7 +1155,7 @@ void hmm_bo_free_pages(struct hmm_buffer_object *bo) status_err2:mutex_unlock (&bo->mutex);dev_err (atomisp_dev, -"buffer object not page allocated yet.\n" ); +"buffer object not page allocated yet.\n" ); }int hmm_bo_page_allocated (struct hmm_buffer_object *bo)
@@ -1190,7 +1190,7 @@ int hmm_bo_get_page_info(struct hmm_buffer_object *bo, status_err:dev_err (atomisp_dev, -"buffer object not page allocated yet.\n" ); +"buffer object not page allocated yet.\n" );mutex_unlock (&bo->mutex);return -EINVAL ; }
@@ -1209,9 +1209,8 @@ int hmm_bo_bind(struct hmm_buffer_object *bo)mutex_lock (&bo->mutex); -check_bo_status_yes_goto (bo, -HMM_BO_PAGE_ALLOCED |HMM_BO_ALLOCED , - status_err1); +check_bo_status_yes_goto (bo,HMM_BO_PAGE_ALLOCED |HMM_BO_ALLOCED , + status_err1);check_bo_status_no_goto (bo,HMM_BO_BINDED , status_err2);
@@ -1241,7 +1240,7 @@ int hmm_bo_bind(struct hmm_buffer_object *bo)*/ if (bo->start !=0x0 )isp_mmu_flush_tlb_range (&bdev->mmu, bo->start, - (bo->pgnr <<PAGE_SHIFT )); + (bo->pgnr <<PAGE_SHIFT )); bo->status |=HMM_BO_BINDED ;
@@ -1259,7 +1258,7 @@ int hmm_bo_bind(struct hmm_buffer_object *bo)mutex_unlock (&bo->mutex);dev_err (atomisp_dev, -"setup MMU address mapping failed.\n" ); +"setup MMU address mapping failed.\n" );return ret; status_err2:
@@ -1269,7 +1268,7 @@ int hmm_bo_bind(struct hmm_buffer_object *bo) status_err1:mutex_unlock (&bo->mutex);dev_err (atomisp_dev, -"buffer object vm_node or page not allocated.\n" ); +"buffer object vm_node or page not allocated.\n" );return -EINVAL ; }
@@ -1287,9 +1286,9 @@ void hmm_bo_unbind(struct hmm_buffer_object *bo)mutex_lock (&bo->mutex);check_bo_status_yes_goto (bo, -HMM_BO_PAGE_ALLOCED | -HMM_BO_ALLOCED | -HMM_BO_BINDED , status_err); +HMM_BO_PAGE_ALLOCED | +HMM_BO_ALLOCED | +HMM_BO_BINDED , status_err); bdev = bo->bdev;
@@ -1316,7 +1315,7 @@ void hmm_bo_unbind(struct hmm_buffer_object *bo) status_err:mutex_unlock (&bo->mutex);dev_err (atomisp_dev, -"buffer vm or page not allocated or not binded yet.\n" ); +"buffer vm or page not allocated or not binded yet.\n" ); }int hmm_bo_binded (struct hmm_buffer_object *bo)
@@ -1365,7 +1364,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) pages[i] = bo->page_obj[i].page; bo->vmap_addr =vmap (pages, bo->pgnr,VM_MAP , - cached ?PAGE_KERNEL :PAGE_KERNEL_NOCACHE ); + cached ?PAGE_KERNEL :PAGE_KERNEL_NOCACHE );if (unlikely (!bo->vmap_addr)) {kfree (pages);mutex_unlock (&bo->mutex);
@@ -1498,8 +1497,8 @@ int hmm_bo_mmap(struct vm_area_struct *vma, struct hmm_buffer_object *bo)*/ if ((start +pgnr_to_size (pgnr)) != end) {dev_warn (atomisp_dev, -"vma's address space size not equal" -" to buffer object's size" ); +"vma's address space size not equal" +" to buffer object's size" );return -EINVAL ; }
@@ -1508,9 +1507,9 @@ int hmm_bo_mmap(struct vm_area_struct *vma, struct hmm_buffer_object *bo) pfn =page_to_pfn (bo->page_obj[i].page);if (remap_pfn_range (vma, virt, pfn,PAGE_SIZE ,PAGE_SHARED )) {dev_warn (atomisp_dev, -"remap_pfn_range failed:" -" virt = 0x%x, pfn = 0x%x," -" mapped_pgnr = %d\n" , virt, pfn,1 ); +"remap_pfn_range failed:" +" virt = 0x%x, pfn = 0x%x," +" mapped_pgnr = %d\n" , virt, pfn,1 );return -EINVAL ; } virt +=PAGE_SIZE ;
Signature · 1 line
2.7.4
PATCH v2 6/10 Staging: media: atomisp: Add spaces around bitwise OR
In reply to Georgiana CheluAdd spaces around operator to improve the code
readability.
Issue reported by checkpatch.pl script:
* CHECK: spaces preferred around that '|'
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +1 -1
@@ -1521,7 +1521,7 @@ int hmm_bo_mmap(struct vm_area_struct *vma, struct hmm_buffer_object *bo) vma->vm_private_data = bo; vma->vm_ops = &hmm_bo_vm_ops; - vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ; + vma->vm_flags |=VM_IO |VM_DONTEXPAND |VM_DONTDUMP ;/* * call hmm_bo_vm_open explictly.
Signature · 1 line
2.7.4
PATCH v2 7/10 Staging: media: atomisp: Remove braces {} for single statement blocks
In reply to Georgiana CheluEnhance the coding style by removing the
braces {} for single statement blocks.
Fix issue reported by checkpatch.pl script:
*WARNING: braces {} are not necessary for single statement blocks
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +2 -4
@@ -724,9 +724,8 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL ); -if (!bo->page_obj) { +if (!bo->page_obj)return -ENOMEM ; - } i =0 ; alloc_pgnr =0 ;
@@ -987,9 +986,8 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,struct page **pages; pages =kmalloc_array (bo->pgnr,sizeof (struct page *),GFP_KERNEL ); -if (!pages) { +if (!pages)return -ENOMEM ; - } bo->page_obj =kmalloc_array (bo->pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );
Signature · 1 line
2.7.4
PATCH v2 10/10 Staging: media: atomisp: Split lines wiht over 80 characters
In reply to Georgiana CheluLines with over 80 characters are difficult to read. Thus, improve the coding style by writing the code on multiple lines.
Issue found the checkpatch script:
* WARNING: line over 80 characters
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +7 -4
@@ -384,7 +384,8 @@ int hmm_bo_device_init(struct hmm_bo_device *bdev, bdev->free_rbtree =RB_ROOT ; bdev->bo_cache =kmem_cache_create ("bo_cache" , -sizeof (struct hmm_buffer_object ),0 ,0 ,NULL ); +sizeof (struct hmm_buffer_object ), +0 ,0 ,NULL );if (!bdev->bo_cache) {dev_err (atomisp_dev,"%s: create cache failed!\n" , __func__);isp_mmu_exit (&bdev->mmu);
@@ -683,7 +684,8 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo, ret =set_pages_wb (bo->page_obj[i].page,1 );if (ret)dev_err (atomisp_dev, -"set page to WB err ...ret = %d\n" , ret); +"set page to WB err ...ret = %d\n" , + ret);/* W/A: set_pages_wb seldom return value = -EFAULT indicate that address of page is not in valid
@@ -957,8 +959,9 @@ static int __get_pfnmap_pages(struct task_struct *tsk, struct mm_struct *mm, }static int get_pfnmap_pages (struct task_struct *tsk,struct mm_struct *mm, -unsigned long start,int nr_pages,int write,int force, -struct page **pages,struct vm_area_struct **vmas) +unsigned long start,int nr_pages,int write, +int force,struct page **pages, +struct vm_area_struct **vmas) {int flags =FOLL_TOUCH ;
Signature · 1 line
2.7.4
PATCH v2 9/10 Staging: media: atomisp: Merge quoted string split across lines
In reply to Georgiana CheluPrefer merging quoted strings on one line than splitting them, even if the line exceeds 80 characters. It is easier to read and grep for strings that are not split.
Warning found by the checkpatch.pl script:
* WARNING: quoted string split across lines
---
Changes in v2:
* this is a new patch added to the patchset
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +5 -9
@@ -821,8 +821,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, ret =set_pages_uc (pages, blk_pgnr);if (ret) {dev_err (atomisp_dev, -"set page uncacheable" -"failed.\n" ); +"set page uncacheable failed.\n" );__free_pages (pages, order);
@@ -1031,8 +1030,7 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,/* can be written by caller, not forced */ if (page_nr != bo->pgnr) {dev_err (atomisp_dev, -"get_user_pages err: bo->pgnr = %d, " -"pgnr actually pinned = %d.\n" , +"get_user_pages err: bo->pgnr = %d, pgnr actually pinned = %d.\n" , bo->pgnr, page_nr); goto out_of_mem; }
@@ -1497,8 +1495,7 @@ int hmm_bo_mmap(struct vm_area_struct *vma, struct hmm_buffer_object *bo)*/ if ((start +pgnr_to_size (pgnr)) != end) {dev_warn (atomisp_dev, -"vma's address space size not equal" -" to buffer object's size" ); +"vma's address space size not equal to buffer object's size" );return -EINVAL ; }
@@ -1507,9 +1504,8 @@ int hmm_bo_mmap(struct vm_area_struct *vma, struct hmm_buffer_object *bo) pfn =page_to_pfn (bo->page_obj[i].page);if (remap_pfn_range (vma, virt, pfn,PAGE_SIZE ,PAGE_SHARED )) {dev_warn (atomisp_dev, -"remap_pfn_range failed:" -" virt = 0x%x, pfn = 0x%x," -" mapped_pgnr = %d\n" , virt, pfn,1 ); +"remap_pfn_range failed: virt = 0x%x, pfn = 0x%x, mapped_pgnr = %d\n" , + virt, pfn,1 );return -EINVAL ; } virt +=PAGE_SIZE ;
Signature · 1 line
2.7.4
Greg Kroah-Hartman
maintainerRe: [Outreachy kernel] [PATCH v2 02/10] Staging: media: atomisp: Remove useless 'out of memory' messages
In reply to Georgiana CheluQuoted 17 lines · Georgiana Chelu
OOM (Out Of Memory Manager) reports memory allocation fails, so there is no need for the error messages.
Signed-off-by Georgiana Chelu <[email protected]>---
Changes in v2:
* this is a new patch added to the patchsetdrivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 4 ---- 1 file changed, 4 deletions(-)drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0
-0
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c static int alloc_private_pages(struct hmm_buffer_object *bo, · line 732
Quoted 6 lines
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0
-1@@ -728,7 +728,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) { -dev_err (atomisp_dev,"out of memory for bo->page_obj\n" );return -ENOMEM ; }
The { } should also be removed when you do this. Please fix that up here.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH v2 03/10] Staging: media: atomisp: Remove unlikely from NULL pointer check
In reply to Georgiana CheluQuoted 7 lines · Georgiana Chelu
Remove unlikely because kmalloc uses it inside the source code.
Signed-off-by Georgiana Chelu <[email protected]>---
Changes in v2:
* this is a new patch added to the patchset
As I didn't take patch 2, I can't take this one. Please fix up and resend the remaining patches in this series.
thanks,
greg k-h
Re: [Outreachy kernel] [PATCH v2 02/10] Staging: media: atomisp: Remove useless 'out of memory' messages
In reply to Greg Kroah-HartmanQuoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Georgiana Chelu
OOM (Out Of Memory Manager) reports memory allocation fails, so there is no need for the error messages.
Signed-off-by Georgiana Chelu <[email protected]>---
Changes in v2:
* this is a new patch added to the patchsetdrivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 4 ---- 1 file changed, 4 deletions(-)
Quoted 15 lines
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c static int alloc_private_pages(struct hmm_buffer_object *bo, · line 732
Quoted 11 lines
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0
-1@@ -728,7 +728,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) { -dev_err (atomisp_dev,"out of memory for bo->page_obj\n" );return -ENOMEM ; }The { } should also be removed when you do this. Please fix that up here.
This fix is done in
[PATCH v2 07/10] Staging: media: atomisp:
Remove braces {} for single statement blocks
Do you say that is better to remove the {} in 02/10?
Thank you,
Georgiana
Quoted 3 lines
thanks,
greg k-h
Re: [Outreachy kernel] [PATCH v2 02/10] Staging: media: atomisp: Remove useless 'out of memory' messages
Quoted 31 lines · Georgiana Chelu
Quoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Georgiana Chelu
OOM (Out Of Memory Manager) reports memory allocation fails, so there is no need for the error messages.
Signed-off-by Georgiana Chelu <[email protected]>---
Changes in v2:
* this is a new patch added to the patchsetdrivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 4 ---- 1 file changed, 4 deletions(-)Quoted 15 lines
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c static int alloc_private_pages(struct hmm_buffer_object *bo, · line 732
Quoted 11 lines
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0
-1@@ -728,7 +728,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) { -dev_err (atomisp_dev,"out of memory for bo->page_obj\n" );return -ENOMEM ; }The { } should also be removed when you do this. Please fix that up here.
Quoted 5 lines
This fix is done in
[PATCH v2 07/10] Staging: media: atomisp:
Remove braces {} for single statement blocksDo you say that is better to remove the {} in 02/10?
Yes. When you make a change, you should clean immediately up any checkpatch warnings that you introduce.
julia
Quoted 15 lines
Thank you,
GeorgianaQuoted 3 lines
thanks,
greg k-h
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CALta04wMbvf3BDh9%2B_7TT_VbnApMt3HfqwD%2B_4qSNBpY2xaUQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Re: [Outreachy kernel] [PATCH v2 02/10] Staging: media: atomisp: Remove useless 'out of memory' messages
Quoted 35 lines · Julia Lawall
Quoted 31 lines · Georgiana Chelu
Quoted 28 lines · Greg Kroah-Hartman
Quoted 17 lines · Georgiana Chelu
OOM (Out Of Memory Manager) reports memory allocation fails, so there is no need for the error messages.
Signed-off-by Georgiana Chelu <[email protected]>---
Changes in v2:
* this is a new patch added to the patchsetdrivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 4 ---- 1 file changed, 4 deletions(-)drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0
-0drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c static int alloc_private_pages(struct hmm_buffer_object *bo, · line 732
Quoted 6 lines
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +0
-1@@ -728,7 +728,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, bo->page_obj =kmalloc_array (pgnr,sizeof (struct hmm_page_object ),GFP_KERNEL );if (unlikely (!bo->page_obj)) { -dev_err (atomisp_dev,"out of memory for bo->page_obj\n" );return -ENOMEM ; }The { } should also be removed when you do this. Please fix that up here.
Quoted 9 lines
Quoted 5 lines
This fix is done in
[PATCH v2 07/10] Staging: media: atomisp:
Remove braces {} for single statement blocksDo you say that is better to remove the {} in 02/10?
Yes. When you make a change, you should clean immediately up any checkpatch warnings that you introduce.
I see .. Thank you very much! I will resend the patchset.
Georgiana
Quoted 17 lines
julia
Quoted 15 lines
Thank you,
GeorgianaQuoted 3 lines
thanks,
greg k-h
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CALta04wMbvf3BDh9%2B_7TT_VbnApMt3HfqwD%2B_4qSNBpY2xaUQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.