Message ID | 20241011072210.494672-5-umang.jain@ideasonboard.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | staging: vchiq: Lower indentation at various places | expand |
Hi Umang, Am 11.10.24 um 09:22 schrieb Umang Jain: > Lower indentation of 'if (bulk->data && service->instance)' > conditional block. This is achieved introducing a early check for > (!bulk->data || !service->instance) and using a goto label 'complete' > if it evaluates to true. > > No functional changes intended in this patch. > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > --- > .../interface/vchiq_arm/vchiq_core.c | 61 ++++++++++--------- > 1 file changed, 31 insertions(+), 30 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 15257cf66fa4..b95443043c27 100644 > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c > @@ -1326,44 +1326,45 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, > struct vchiq_bulk *bulk = > &queue->bulks[BULK_INDEX(queue->remove)]; > > + if (!bulk->data || !service->instance) > + goto complete; > + > /* > * Only generate callbacks for non-dummy bulk > * 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); > - } > + 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_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; > + 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; > + } > +complete: I would consider goto labels within a while loop as error prone and ugly. Maybe moving the enclosing code into a separate function would be a nicer approach? Regards > queue->remove++; > complete(&service->bulk_remove_event); > }
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 15257cf66fa4..b95443043c27 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1326,44 +1326,45 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, struct vchiq_bulk *bulk = &queue->bulks[BULK_INDEX(queue->remove)]; + if (!bulk->data || !service->instance) + goto complete; + /* * Only generate callbacks for non-dummy bulk * 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); - } + 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_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; + 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; + } +complete: queue->remove++; complete(&service->bulk_remove_event); }
Lower indentation of 'if (bulk->data && service->instance)' conditional block. This is achieved introducing a early check for (!bulk->data || !service->instance) and using a goto label 'complete' if it evaluates to true. No functional changes intended in this patch. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> --- .../interface/vchiq_arm/vchiq_core.c | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-)