[PATCH 07/20] staging: vchiq_core: avoid indention in poll_services_of_group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



By converting the first and the third if statement into continue early
the function poll_services_of_group() can avoid 2 indention levels.

Signed-off-by: Stefan Wahren <stefan.wahren@xxxxxxxx>
---
 .../vc04_services/interface/vchiq_arm/vchiq_core.c | 97 ++++++++++------------
 1 file changed, 46 insertions(+), 51 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 3e847d8..b3e81ac 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1325,59 +1325,54 @@ poll_services_of_group(struct vchiq_state *state, int group)
 	int i;
 
 	for (i = 0; flags; i++) {
-		if (flags & BIT(i)) {
-			struct vchiq_service *service =
-				find_service_by_port(state,
-					(group<<5) + i);
-			u32 service_flags;
-
-			flags &= ~BIT(i);
-			if (!service)
-				continue;
-			service_flags =
-				atomic_xchg(&service->poll_flags, 0);
-			if (service_flags &
-				BIT(VCHIQ_POLL_REMOVE)) {
-				vchiq_log_info(vchiq_core_log_level,
-					"%d: ps - remove %d<->%d",
-					state->id, service->localport,
-					service->remoteport);
+		struct vchiq_service *service;
+		u32 service_flags;
 
-				/*
-				 * Make it look like a client, because
-				 * it must be removed and not left in
-				 * the LISTENING state.
-				 */
-				service->public_fourcc =
-					VCHIQ_FOURCC_INVALID;
-
-				if (vchiq_close_service_internal(
-					service, 0/*!close_recvd*/) !=
-					VCHIQ_SUCCESS)
-					request_poll(state, service,
-						VCHIQ_POLL_REMOVE);
-			} else if (service_flags &
-				BIT(VCHIQ_POLL_TERMINATE)) {
-				vchiq_log_info(vchiq_core_log_level,
-					"%d: ps - terminate %d<->%d",
-					state->id, service->localport,
-					service->remoteport);
-				if (vchiq_close_service_internal(
-					service, 0/*!close_recvd*/) !=
-					VCHIQ_SUCCESS)
-					request_poll(state, service,
-						VCHIQ_POLL_TERMINATE);
-			}
-			if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY))
-				notify_bulks(service,
-					&service->bulk_tx,
-					1/*retry_poll*/);
-			if (service_flags & BIT(VCHIQ_POLL_RXNOTIFY))
-				notify_bulks(service,
-					&service->bulk_rx,
-					1/*retry_poll*/);
-			unlock_service(service);
+		if ((flags & BIT(i)) == 0)
+			continue;
+
+		service = find_service_by_port(state, (group << 5) + i);
+		flags &= ~BIT(i);
+
+		if (!service)
+			continue;
+
+		service_flags = atomic_xchg(&service->poll_flags, 0);
+		if ((service_flags & BIT(VCHIQ_POLL_REMOVE)) == 0)
+			continue;
+
+		vchiq_log_info(vchiq_core_log_level, "%d: ps - remove %d<->%d",
+			       state->id, service->localport,
+			       service->remoteport);
+
+		/*
+		 * Make it look like a client, because
+		 * it must be removed and not left in
+		 * the LISTENING state.
+		 */
+		service->public_fourcc = VCHIQ_FOURCC_INVALID;
+
+		if (vchiq_close_service_internal(service, 0/*!close_recvd*/) !=
+						 VCHIQ_SUCCESS) {
+			request_poll(state, service, VCHIQ_POLL_REMOVE);
+		} else if (service_flags & BIT(VCHIQ_POLL_TERMINATE)) {
+			vchiq_log_info(vchiq_core_log_level,
+				"%d: ps - terminate %d<->%d",
+				state->id, service->localport,
+				service->remoteport);
+			if (vchiq_close_service_internal(
+				service, 0/*!close_recvd*/) !=
+				VCHIQ_SUCCESS)
+				request_poll(state, service,
+					     VCHIQ_POLL_TERMINATE);
 		}
+		if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY))
+			notify_bulks(service, &service->bulk_tx,
+				     1/*retry_poll*/);
+		if (service_flags & BIT(VCHIQ_POLL_RXNOTIFY))
+			notify_bulks(service, &service->bulk_rx,
+				     1/*retry_poll*/);
+		unlock_service(service);
 	}
 }
 
-- 
2.7.4





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux