]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: vchiq_core: Refactor notify_bulks()
authorUmang Jain <umang.jain@ideasonboard.com>
Sun, 13 Oct 2024 11:21:26 +0000 (16:51 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Oct 2024 13:47:34 +0000 (15:47 +0200)
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>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20241013112128.397249-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c

index e9cd012e2b5f64cf28418013dda55f84c5bdd10e..d7ddbc97207a02a121e94f17759b97a4dfccab0a 100644 (file)
@@ -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++;