staging: vchiq_core: introduce poll_services_of_group
authorStefan Wahren <stefan.wahren@i2se.com>
Sat, 15 May 2021 19:10:45 +0000 (21:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 15:56:31 +0000 (17:56 +0200)
The function poll_services() has too many indention levels. So keep only
the group iteration loop and move the rest into a new function
poll_services_of_group().

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1621105859-30215-7-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c

index 2a83c2a..3e847d8 100644 (file)
@@ -1318,74 +1318,79 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
        return status;
 }
 
-/* Called by the slot handler thread */
 static void
-poll_services(struct vchiq_state *state)
+poll_services_of_group(struct vchiq_state *state, int group)
 {
-       int group, i;
-
-       for (group = 0; group < BITSET_SIZE(state->unused_service); group++) {
-               u32 flags;
-
-               flags = atomic_xchg(&state->poll_services[group], 0);
-               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);
+       u32 flags = atomic_xchg(&state->poll_services[group], 0);
+       int i;
 
-                                       /*
-                                        * 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);
+       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);
+
+                               /*
+                                * 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);
                }
        }
 }
 
+/* Called by the slot handler thread */
+static void
+poll_services(struct vchiq_state *state)
+{
+       int group;
+
+       for (group = 0; group < BITSET_SIZE(state->unused_service); group++)
+               poll_services_of_group(state, group);
+}
+
 /* Called with the bulk_mutex held */
 static void
 abort_outstanding_bulks(struct vchiq_service *service,