mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/6] staging: vchiq: Lower indentation at various
@ 2024-10-13 11:21 Umang Jain
  2024-10-13 11:21 ` [PATCH v4 1/6] staging: vchiq_core: Locally cache cache_line_size information Umang Jain
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

Series is attempted to fix few alignments issues.                               
Also, it aims to lower indentation of various nested `if` conditional           
blocks without introducing any functional changes.                              
                                                                                
Changes in v4:
- Improve return value from service_notify_bulks(3/6)
- Drop 'service' and 'bulk' null check from 3/6 

Changes in v3:
- fix status (return value) in 4/6

Changes in v2:                                                                  
- Assimilated fixes from v1 which can make independent progress                 
- drop following patches from v1:                                               
  - [PATCH 2/8] staging: vchiq_core: Properly log dev_err()                     
  - [PATCH 6/8] staging: vchiq_arm: Lower indentation of a conditional block    
  - Will be handled separately                                                  
- Rework 4/8 from v1                                                            
  - Now included as "staging: vchiq_core: Refactor notify_bulks()"              
                                                                                
Link to v1:                                                                     
https://lore.kernel.org/linux-staging/20241011072210.494672-1-umang.jain@ideasonboard.com/T/#t

Umang Jain (6):
  staging: vchiq_core: Locally cache cache_line_size information
  staging: vchiq_core: Do not log debug in a separate scope
  staging: vchiq_core: Indent copy_message_data() on a single line
  staging: vchiq_core: Refactor notify_bulks()
  staging: vchiq_core: Lower indentation in parse_open()
  staging: vchiq_core: Lower indentation in vchiq_close_service_internal

 .../interface/vchiq_arm/vchiq_core.c          | 184 ++++++++++--------
 1 file changed, 99 insertions(+), 85 deletions(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 1/6] staging: vchiq_core: Locally cache cache_line_size information
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
@ 2024-10-13 11:21 ` Umang Jain
  2024-10-13 11:21 ` [PATCH v4 2/6] staging: vchiq_core: Do not log debug in a separate scope Umang Jain
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

Locally cache 'cache_line_size' information in a variable instead of
repeatedly accessing it from drv_mgmt->info. This helps to reflow lines
under 80 columns.

No functional change intended in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../interface/vchiq_arm/vchiq_core.c          | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 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 1e4b2978c186..e9b60dd8d419 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1490,6 +1490,7 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf,
 	size_t pagelist_size;
 	struct scatterlist *scatterlist, *sg;
 	int dma_buffers;
+	unsigned int cache_line_size;
 	dma_addr_t dma_addr;
 
 	if (count >= INT_MAX - PAGE_SIZE)
@@ -1638,10 +1639,10 @@ create_pagelist(struct vchiq_instance *instance, char *buf, char __user *ubuf,
 	}
 
 	/* Partial cache lines (fragments) require special measures */
+	cache_line_size = drv_mgmt->info->cache_line_size;
 	if ((type == PAGELIST_READ) &&
-	    ((pagelist->offset & (drv_mgmt->info->cache_line_size - 1)) ||
-	    ((pagelist->offset + pagelist->length) &
-	    (drv_mgmt->info->cache_line_size - 1)))) {
+	    ((pagelist->offset & (cache_line_size - 1)) ||
+	    ((pagelist->offset + pagelist->length) & (cache_line_size - 1)))) {
 		char *fragments;
 
 		if (down_interruptible(&drv_mgmt->free_fragments_sema)) {
@@ -1671,6 +1672,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel
 	struct pagelist *pagelist = pagelistinfo->pagelist;
 	struct page **pages = pagelistinfo->pages;
 	unsigned int num_pages = pagelistinfo->num_pages;
+	unsigned int cache_line_size;
 
 	dev_dbg(instance->state->dev, "arm: %pK, %d\n", pagelistinfo->pagelist, actual);
 
@@ -1685,16 +1687,17 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel
 	pagelistinfo->scatterlist_mapped = 0;
 
 	/* Deal with any partial cache lines (fragments) */
+	cache_line_size = drv_mgmt->info->cache_line_size;
 	if (pagelist->type >= PAGELIST_READ_WITH_FRAGMENTS && drv_mgmt->fragments_base) {
 		char *fragments = drv_mgmt->fragments_base +
 			(pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) *
 			drv_mgmt->fragments_size;
 		int head_bytes, tail_bytes;
 
-		head_bytes = (drv_mgmt->info->cache_line_size - pagelist->offset) &
-			(drv_mgmt->info->cache_line_size - 1);
+		head_bytes = (cache_line_size - pagelist->offset) &
+			     (cache_line_size - 1);
 		tail_bytes = (pagelist->offset + actual) &
-			(drv_mgmt->info->cache_line_size - 1);
+			     (cache_line_size - 1);
 
 		if ((actual >= 0) && (head_bytes != 0)) {
 			if (head_bytes > actual)
@@ -1707,8 +1710,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel
 		    (tail_bytes != 0))
 			memcpy_to_page(pages[num_pages - 1],
 				       (pagelist->offset + actual) &
-				       (PAGE_SIZE - 1) & ~(drv_mgmt->info->cache_line_size - 1),
-				       fragments + drv_mgmt->info->cache_line_size,
+				       (PAGE_SIZE - 1) & ~(cache_line_size - 1),
+				       fragments + cache_line_size,
 				       tail_bytes);
 
 		down(&drv_mgmt->free_fragments_mutex);
-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 2/6] staging: vchiq_core: Do not log debug in a separate scope
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
  2024-10-13 11:21 ` [PATCH v4 1/6] staging: vchiq_core: Locally cache cache_line_size information Umang Jain
@ 2024-10-13 11:21 ` Umang Jain
  2024-10-13 11:21 ` [PATCH v4 3/6] staging: vchiq_core: Indent copy_message_data() on a single line Umang Jain
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

Do not log a dev_dbg() with a separate scope. Drop the {..}
scope and align the dev_dbg() to make it more readable.

No functional changes intended in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../interface/vchiq_arm/vchiq_core.c            | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 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 e9b60dd8d419..0324dfe59dca 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -936,6 +936,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
 	struct vchiq_service_quota *quota = NULL;
 	struct vchiq_header *header;
 	int type = VCHIQ_MSG_TYPE(msgid);
+	int svc_fourcc;
 
 	size_t stride;
 
@@ -1128,17 +1129,13 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
 	header->msgid = msgid;
 	header->size = size;
 
-	{
-		int svc_fourcc;
-
-		svc_fourcc = service
-			? service->base.fourcc
-			: VCHIQ_MAKE_FOURCC('?', '?', '?', '?');
+	svc_fourcc = service ? service->base.fourcc
+			     : VCHIQ_MAKE_FOURCC('?', '?', '?', '?');
 
-		dev_dbg(state->dev, "core_msg: Sent Msg %s(%u) to %p4cc s:%u d:%d len:%zu\n",
-			msg_type_str(VCHIQ_MSG_TYPE(msgid)), VCHIQ_MSG_TYPE(msgid),
-			&svc_fourcc, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid), size);
-	}
+	dev_dbg(state->dev, "core_msg: Sent Msg %s(%u) to %p4cc s:%u d:%d len:%zu\n",
+		msg_type_str(VCHIQ_MSG_TYPE(msgid)),
+		VCHIQ_MSG_TYPE(msgid), &svc_fourcc,
+		VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid), size);
 
 	/* Make sure the new header is visible to the peer. */
 	wmb();
-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 3/6] staging: vchiq_core: Indent copy_message_data() on a single line
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
  2024-10-13 11:21 ` [PATCH v4 1/6] staging: vchiq_core: Locally cache cache_line_size information Umang Jain
  2024-10-13 11:21 ` [PATCH v4 2/6] staging: vchiq_core: Do not log debug in a separate scope Umang Jain
@ 2024-10-13 11:21 ` Umang Jain
  2024-10-13 11:21 ` [PATCH v4 4/6] staging: vchiq_core: Refactor notify_bulks() Umang Jain
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

Fix the copy_message_data() indentation in queue_message_sync().

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c   | 5 ++---
 1 file changed, 2 insertions(+), 3 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 0324dfe59dca..e9cd012e2b5f 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1197,9 +1197,8 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
 		state->id, msg_type_str(VCHIQ_MSG_TYPE(msgid)), header, size,
 		VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid));
 
-	callback_result =
-		copy_message_data(copy_callback, context,
-				  header->data, size);
+	callback_result = copy_message_data(copy_callback, context,
+					    header->data, size);
 
 	if (callback_result < 0) {
 		mutex_unlock(&state->slot_mutex);
-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 4/6] staging: vchiq_core: Refactor notify_bulks()
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
                   ` (2 preceding siblings ...)
  2024-10-13 11:21 ` [PATCH v4 3/6] staging: vchiq_core: Indent copy_message_data() on a single line Umang Jain
@ 2024-10-13 11:21 ` Umang Jain
  2024-10-13 11:21 ` [PATCH v4 5/6] staging: vchiq_core: Lower indentation in parse_open() Umang Jain
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

Move the statistics and bulk completion events handling  to a separate
function. This helps to improve readability for notify_bulks().

No functional changes intended in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 .../interface/vchiq_arm/vchiq_core.c          | 71 +++++++++++--------
 1 file changed, 40 insertions(+), 31 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 e9cd012e2b5f..d7ddbc97207a 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1309,6 +1309,43 @@ get_bulk_reason(struct vchiq_bulk *bulk)
 	return VCHIQ_BULK_RECEIVE_DONE;
 }
 
+static int service_notify_bulk(struct vchiq_service *service,
+			       struct vchiq_bulk *bulk)
+{
+	if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) {
+		if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
+			VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count);
+			VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes,
+						bulk->actual);
+		} else {
+			VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count);
+			VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes,
+						bulk->actual);
+		}
+	} else {
+		VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count);
+	}
+
+	if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) {
+		struct bulk_waiter *waiter;
+
+		spin_lock(&service->state->bulk_waiter_spinlock);
+		waiter = bulk->userdata;
+		if (waiter) {
+			waiter->actual = bulk->actual;
+			complete(&waiter->event);
+		}
+		spin_unlock(&service->state->bulk_waiter_spinlock);
+	} else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) {
+		enum vchiq_reason reason = get_bulk_reason(bulk);
+
+		return make_service_callback(service, reason, NULL,
+					     bulk->userdata);
+	}
+
+	return 0;
+}
+
 /* Called by the slot handler - don't hold the bulk mutex */
 static int
 notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
@@ -1333,37 +1370,9 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
 		 * requests, and non-terminated services
 		 */
 		if (bulk->data && service->instance) {
-			if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) {
-				if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
-					VCHIQ_SERVICE_STATS_INC(service, bulk_tx_count);
-					VCHIQ_SERVICE_STATS_ADD(service, bulk_tx_bytes,
-								bulk->actual);
-				} else {
-					VCHIQ_SERVICE_STATS_INC(service, bulk_rx_count);
-					VCHIQ_SERVICE_STATS_ADD(service, bulk_rx_bytes,
-								bulk->actual);
-				}
-			} else {
-				VCHIQ_SERVICE_STATS_INC(service, bulk_aborted_count);
-			}
-			if (bulk->mode == VCHIQ_BULK_MODE_BLOCKING) {
-				struct bulk_waiter *waiter;
-
-				spin_lock(&service->state->bulk_waiter_spinlock);
-				waiter = bulk->userdata;
-				if (waiter) {
-					waiter->actual = bulk->actual;
-					complete(&waiter->event);
-				}
-				spin_unlock(&service->state->bulk_waiter_spinlock);
-			} else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) {
-				enum vchiq_reason reason =
-						get_bulk_reason(bulk);
-				status = make_service_callback(service, reason,	NULL,
-							       bulk->userdata);
-				if (status == -EAGAIN)
-					break;
-			}
+			status = service_notify_bulk(service, bulk);
+			if (status == -EAGAIN)
+				break;
 		}
 
 		queue->remove++;
-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 5/6] staging: vchiq_core: Lower indentation in parse_open()
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
                   ` (3 preceding siblings ...)
  2024-10-13 11:21 ` [PATCH v4 4/6] staging: vchiq_core: Refactor notify_bulks() Umang Jain
@ 2024-10-13 11:21 ` Umang Jain
  2024-10-13 11:21 ` [PATCH v4 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal Umang Jain
  2024-10-13 12:21 ` [PATCH v4 0/6] staging: vchiq: Lower indentation at various Dan Carpenter
  6 siblings, 0 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

If the service is not in VCHIQ_SRVSTATE_LISTENING state, it is
implied that the message is dealt with and parse_open() should return.
If this is the case, simply jump the code flow to return site using
'goto done;' statement.

This helps to lower the indentation of
	if (service->srvstate == VCHIQ_SRVSTATE_LISTENING)
conditional branch.

No functional changes intended in this patch.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../interface/vchiq_arm/vchiq_core.c          | 48 ++++++++++---------
 1 file changed, 26 insertions(+), 22 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 d7ddbc97207a..36f08f078564 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1824,8 +1824,10 @@ static int
 parse_open(struct vchiq_state *state, struct vchiq_header *header)
 {
 	const struct vchiq_open_payload *payload;
+	struct vchiq_openack_payload ack_payload;
 	struct vchiq_service *service = NULL;
 	int msgid, size;
+	int openack_id;
 	unsigned int localport, remoteport, fourcc;
 	short version, version_min;
 
@@ -1860,34 +1862,36 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header)
 	}
 	service->peer_version = version;
 
-	if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) {
-		struct vchiq_openack_payload ack_payload = {
-			service->version
-		};
-		int openack_id = MAKE_OPENACK(service->localport, remoteport);
+	if (service->srvstate != VCHIQ_SRVSTATE_LISTENING)
+		goto done;
 
-		if (state->version_common <
-		    VCHIQ_VERSION_SYNCHRONOUS_MODE)
-			service->sync = 0;
+	ack_payload.version = service->version;
+	openack_id = MAKE_OPENACK(service->localport, remoteport);
 
-		/* Acknowledge the OPEN */
-		if (service->sync) {
-			if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback,
-					       &ack_payload, sizeof(ack_payload)) == -EAGAIN)
-				goto bail_not_ready;
+	if (state->version_common < VCHIQ_VERSION_SYNCHRONOUS_MODE)
+		service->sync = 0;
 
-			/* The service is now open */
-			set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC);
-		} else {
-			if (queue_message(state, NULL, openack_id, memcpy_copy_callback,
-					  &ack_payload, sizeof(ack_payload), 0) == -EINTR)
-				goto bail_not_ready;
+	/* Acknowledge the OPEN */
+	if (service->sync) {
+		if (queue_message_sync(state, NULL, openack_id,
+				       memcpy_copy_callback,
+				       &ack_payload,
+				       sizeof(ack_payload)) == -EAGAIN)
+			goto bail_not_ready;
 
-			/* The service is now open */
-			set_service_state(service, VCHIQ_SRVSTATE_OPEN);
-		}
+		/* The service is now open */
+		set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC);
+	} else {
+		if (queue_message(state, NULL, openack_id,
+				  memcpy_copy_callback, &ack_payload,
+				  sizeof(ack_payload), 0) == -EINTR)
+			goto bail_not_ready;
+
+		/* The service is now open */
+		set_service_state(service, VCHIQ_SRVSTATE_OPEN);
 	}
 
+done:
 	/* Success - the message has been dealt with */
 	vchiq_service_put(service);
 	return 1;
-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
                   ` (4 preceding siblings ...)
  2024-10-13 11:21 ` [PATCH v4 5/6] staging: vchiq_core: Lower indentation in parse_open() Umang Jain
@ 2024-10-13 11:21 ` Umang Jain
  2024-10-13 12:21 ` [PATCH v4 0/6] staging: vchiq: Lower indentation at various Dan Carpenter
  6 siblings, 0 replies; 8+ messages in thread
From: Umang Jain @ 2024-10-13 11:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Broadcom internal kernel review list
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Dan Carpenter, Laurent Pinchart, kernel-list,
	Stefan Wahren, Umang Jain

Reduce indentation of the conditional nesting in
vchiq_close_service_internal() switch case by checking the error paths
first and break early. This helps to reduce conditional branching and
reduce indentation levels.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 .../interface/vchiq_arm/vchiq_core.c          | 24 ++++++++++---------
 1 file changed, 13 insertions(+), 11 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 36f08f078564..3d347b425f20 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -3163,19 +3163,21 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd)
 		if (close_recvd) {
 			dev_err(state->dev, "core: (1) called in state %s\n",
 				srvstate_names[service->srvstate]);
-		} else if (is_server) {
-			if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) {
-				status = -EINVAL;
-			} else {
-				service->client_id = 0;
-				service->remoteport = VCHIQ_PORT_FREE;
-				if (service->srvstate == VCHIQ_SRVSTATE_CLOSEWAIT)
-					set_service_state(service, VCHIQ_SRVSTATE_LISTENING);
-			}
-			complete(&service->remove_event);
-		} else {
+			break;
+		} else if (!is_server) {
 			vchiq_free_service_internal(service);
+			break;
+		}
+
+		if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) {
+			status = -EINVAL;
+		} else {
+			service->client_id = 0;
+			service->remoteport = VCHIQ_PORT_FREE;
+			if (service->srvstate == VCHIQ_SRVSTATE_CLOSEWAIT)
+				set_service_state(service, VCHIQ_SRVSTATE_LISTENING);
 		}
+		complete(&service->remove_event);
 		break;
 	case VCHIQ_SRVSTATE_OPENING:
 		if (close_recvd) {
-- 
2.45.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 0/6] staging: vchiq: Lower indentation at various
  2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
                   ` (5 preceding siblings ...)
  2024-10-13 11:21 ` [PATCH v4 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal Umang Jain
@ 2024-10-13 12:21 ` Dan Carpenter
  6 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2024-10-13 12:21 UTC (permalink / raw)
  To: Umang Jain
  Cc: Greg Kroah-Hartman, Broadcom internal kernel review list,
	linux-rpi-kernel, linux-arm-kernel, linux-staging, linux-kernel,
	Kieran Bingham, Laurent Pinchart, kernel-list, Stefan Wahren

LGTM.

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-13 12:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-13 11:21 [PATCH v4 0/6] staging: vchiq: Lower indentation at various Umang Jain
2024-10-13 11:21 ` [PATCH v4 1/6] staging: vchiq_core: Locally cache cache_line_size information Umang Jain
2024-10-13 11:21 ` [PATCH v4 2/6] staging: vchiq_core: Do not log debug in a separate scope Umang Jain
2024-10-13 11:21 ` [PATCH v4 3/6] staging: vchiq_core: Indent copy_message_data() on a single line Umang Jain
2024-10-13 11:21 ` [PATCH v4 4/6] staging: vchiq_core: Refactor notify_bulks() Umang Jain
2024-10-13 11:21 ` [PATCH v4 5/6] staging: vchiq_core: Lower indentation in parse_open() Umang Jain
2024-10-13 11:21 ` [PATCH v4 6/6] staging: vchiq_core: Lower indentation in vchiq_close_service_internal Umang Jain
2024-10-13 12:21 ` [PATCH v4 0/6] staging: vchiq: Lower indentation at various Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®