All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Wahren <stefan.wahren@i2se.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>
Cc: linux-staging@lists.linux.dev, Stefan Wahren <stefan.wahren@i2se.com>
Subject: [PATCH 10/10] staging: vchiq_core: split exit conditions
Date: Sun, 11 Apr 2021 20:11:40 +0200	[thread overview]
Message-ID: <1618164700-21150-11-git-send-email-stefan.wahren@i2se.com> (raw)
In-Reply-To: <1618164700-21150-1-git-send-email-stefan.wahren@i2se.com>

Some exit conditions are rather complex. So better split them up.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 .../vc04_services/interface/vchiq_arm/vchiq_core.c | 30 ++++++++++++++++------
 1 file changed, 22 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 f5bd5e2..517a8c9 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -3069,9 +3069,16 @@ enum vchiq_status vchiq_bulk_transfer(unsigned int handle,
 	enum vchiq_status status = VCHIQ_ERROR;
 	int payload[2];
 
-	if (!service || service->srvstate != VCHIQ_SRVSTATE_OPEN ||
-	    (!offset && !uoffset) ||
-	    vchiq_check_service(service) != VCHIQ_SUCCESS)
+	if (!service)
+		goto error_exit;
+
+	if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
+		goto error_exit;
+
+	if (!offset && !uoffset)
+		goto error_exit;
+
+	if (vchiq_check_service(service) != VCHIQ_SUCCESS)
 		goto error_exit;
 
 	switch (mode) {
@@ -3215,8 +3222,10 @@ vchiq_queue_message(unsigned int handle,
 	struct vchiq_service *service = find_service_by_handle(handle);
 	enum vchiq_status status = VCHIQ_ERROR;
 
-	if (!service ||
-		(vchiq_check_service(service) != VCHIQ_SUCCESS))
+	if (!service)
+		goto error_exit;
+
+	if (vchiq_check_service(service) != VCHIQ_SUCCESS)
 		goto error_exit;
 
 	if (!size) {
@@ -3327,10 +3336,15 @@ vchiq_get_peer_version(unsigned int handle, short *peer_version)
 	enum vchiq_status status = VCHIQ_ERROR;
 	struct vchiq_service *service = find_service_by_handle(handle);
 
-	if (!service ||
-	    (vchiq_check_service(service) != VCHIQ_SUCCESS) ||
-	    !peer_version)
+	if (!service)
+		goto exit;
+
+	if (vchiq_check_service(service) != VCHIQ_SUCCESS)
+		goto exit;
+
+	if (!peer_version)
 		goto exit;
+
 	*peer_version = service->peer_version;
 	status = VCHIQ_SUCCESS;
 
-- 
2.7.4


      parent reply	other threads:[~2021-04-11 18:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-11 18:11 [PATCH 00/10] staging: vchiq_core: improve code readability Stefan Wahren
2021-04-11 18:11 ` [PATCH 01/10] staging: vchiq_core: Simplify vchiq_send_remote_use* Stefan Wahren
2021-04-11 18:11 ` [PATCH 02/10] staging: vchiq_core: Shorten var name for service quota Stefan Wahren
2021-04-11 18:11 ` [PATCH 03/10] staging: vchiq_core: Get the rid off curly braces around cases Stefan Wahren
2021-04-11 18:11 ` [PATCH 04/10] staging: vchiq_core: Exit early in 2 functions Stefan Wahren
2021-04-11 18:11 ` [PATCH 05/10] staging: vchiq_core: introduce service skip Stefan Wahren
2021-04-11 18:11 ` [PATCH 06/10] staging: vchiq_core: improve readability of request_poll Stefan Wahren
2021-04-11 18:11 ` [PATCH 07/10] staging: vchiq_core: use BITSET_WORD macro Stefan Wahren
2021-04-11 18:11 ` [PATCH 08/10] staging: vchiq_core: introduce SLOT_QUEUE_INDEX_FROM_POS_MASKED Stefan Wahren
2021-04-11 18:11 ` [PATCH 09/10] staging: vchiq_core: fix if alignments Stefan Wahren
2021-04-11 18:11 ` Stefan Wahren [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1618164700-21150-11-git-send-email-stefan.wahren@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=nsaenz@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.