[PATCH 2/6] staging: vchiq_core: Simplify bulk data preparatory functions

Umang Jain posted 6 patches 1 month, 1 week ago
[PATCH 2/6] staging: vchiq_core: Simplify bulk data preparatory functions
Posted by Umang Jain 1 month, 1 week ago
Two functions create_pagelist() and vchiq_prepare_bulk_data()
open code bulk data arguments ('size' and 'dir') in their function
signatures which can easily be obtained by struct vchiq_bulk pointer.

Retrieve the arguments from vchiq_bulk pointer instead and reduce
the number of arguments passed in create_pagelist() and
vchiq_bulk_prepare_data().

No functional changes intended in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 .../interface/vchiq_arm/vchiq_core.c             | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 7c6f09a9d917..62356a165696 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1482,8 +1482,7 @@ is_adjacent_block(u32 *addrs, dma_addr_t addr, unsigned int k)
  * cached area.
  */
 static struct vchiq_pagelist_info *
-create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk,
-		size_t count, unsigned short type)
+create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk)
 {
 	struct vchiq_drv_mgmt *drv_mgmt;
 	struct pagelist *pagelist;
@@ -1497,6 +1496,9 @@ create_pagelist(struct vchiq_instance *instance, struct vchiq_bulk *bulk,
 	int dma_buffers;
 	unsigned int cache_line_size;
 	dma_addr_t dma_addr;
+	size_t count = bulk->size;
+	unsigned short type = (bulk->dir == VCHIQ_BULK_RECEIVE)
+			      ? PAGELIST_READ : PAGELIST_WRITE;
 
 	if (count >= INT_MAX - PAGE_SIZE)
 		return NULL;
@@ -1740,15 +1742,11 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel
 }
 
 static int
-vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk *bulk,
-			int size, int dir)
+vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk *bulk)
 {
 	struct vchiq_pagelist_info *pagelistinfo;
 
-	pagelistinfo = create_pagelist(instance, bulk, size,
-				       (dir == VCHIQ_BULK_RECEIVE)
-				       ? PAGELIST_READ
-				       : PAGELIST_WRITE);
+	pagelistinfo = create_pagelist(instance, bulk);
 
 	if (!pagelistinfo)
 		return -ENOMEM;
@@ -3074,7 +3072,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
 	bulk->offset = offset;
 	bulk->uoffset = uoffset;
 
-	if (vchiq_prepare_bulk_data(service->instance, bulk, size, dir))
+	if (vchiq_prepare_bulk_data(service->instance, bulk))
 		goto unlock_error_exit;
 
 	/*
-- 
2.45.2