diff mbox series

[V2,2/3] staging: vchiq_core: Shorten bulk TX/RX pending dump

Message ID 20231029124837.119832-3-wahrenst@gmx.net (mailing list archive)
State New, archived
Headers show
Series staging: vchiq_arm: move state dump to debugfs | expand

Commit Message

Stefan Wahren Oct. 29, 2023, 12:48 p.m. UTC
The calculation for the bulk TX/RX pending is complex and
reaches 99 chars per line. So move the size determination
below the pending calculation and get the rid of the
ternary operator.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 .../interface/vchiq_arm/vchiq_core.c          | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

--
2.34.1

Comments

Laurent Pinchart Oct. 29, 2023, 11:46 p.m. UTC | #1
Hi Stefan,

Thank you for the patch.

On Sun, Oct 29, 2023 at 01:48:36PM +0100, Stefan Wahren wrote:
> The calculation for the bulk TX/RX pending is complex and
> reaches 99 chars per line. So move the size determination
> below the pending calculation and get the rid of the
> ternary operator.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  .../interface/vchiq_arm/vchiq_core.c          | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 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 94073f92651a..36c742a2f3b2 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> @@ -3447,7 +3447,7 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service)
>  		struct vchiq_service_quota *quota =
>  			&service->state->service_quotas[service->localport];
>  		int fourcc = service->base.fourcc;
> -		int tx_pending, rx_pending;
> +		int tx_pending, rx_pending, tx_size = 0, rx_size = 0;
> 
>  		if (service->remoteport != VCHIQ_PORT_FREE) {
>  			int len2 = scnprintf(remoteport, sizeof(remoteport),
> @@ -3472,18 +3472,23 @@ vchiq_dump_service_state(void *dump_context, struct vchiq_service *service)
> 
>  		tx_pending = service->bulk_tx.local_insert -
>  			service->bulk_tx.remote_insert;
> +		if (tx_pending) {
> +			unsigned int i = BULK_INDEX(service->bulk_tx.remove);
> +
> +			tx_size = service->bulk_tx.bulks[i].size;
> +		}
> 
>  		rx_pending = service->bulk_rx.local_insert -
>  			service->bulk_rx.remote_insert;
> +		if (rx_pending) {
> +			unsigned int i = BULK_INDEX(service->bulk_rx.remove);
> +
> +			rx_size = service->bulk_rx.bulks[i].size;
> +		}
> 
>  		len = scnprintf(buf, sizeof(buf),
>  				"  Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)",
> -				tx_pending,
> -				tx_pending ?
> -				service->bulk_tx.bulks[BULK_INDEX(service->bulk_tx.remove)].size :
> -				0, rx_pending, rx_pending ?
> -				service->bulk_rx.bulks[BULK_INDEX(service->bulk_rx.remove)].size :
> -				0);
> +				tx_pending, tx_size, rx_pending, rx_size);
> 
>  		if (VCHIQ_ENABLE_STATS) {
>  			err = vchiq_dump(dump_context, buf, len + 1);
diff mbox series

Patch

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 94073f92651a..36c742a2f3b2 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -3447,7 +3447,7 @@  vchiq_dump_service_state(void *dump_context, struct vchiq_service *service)
 		struct vchiq_service_quota *quota =
 			&service->state->service_quotas[service->localport];
 		int fourcc = service->base.fourcc;
-		int tx_pending, rx_pending;
+		int tx_pending, rx_pending, tx_size = 0, rx_size = 0;

 		if (service->remoteport != VCHIQ_PORT_FREE) {
 			int len2 = scnprintf(remoteport, sizeof(remoteport),
@@ -3472,18 +3472,23 @@  vchiq_dump_service_state(void *dump_context, struct vchiq_service *service)

 		tx_pending = service->bulk_tx.local_insert -
 			service->bulk_tx.remote_insert;
+		if (tx_pending) {
+			unsigned int i = BULK_INDEX(service->bulk_tx.remove);
+
+			tx_size = service->bulk_tx.bulks[i].size;
+		}

 		rx_pending = service->bulk_rx.local_insert -
 			service->bulk_rx.remote_insert;
+		if (rx_pending) {
+			unsigned int i = BULK_INDEX(service->bulk_rx.remove);
+
+			rx_size = service->bulk_rx.bulks[i].size;
+		}

 		len = scnprintf(buf, sizeof(buf),
 				"  Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)",
-				tx_pending,
-				tx_pending ?
-				service->bulk_tx.bulks[BULK_INDEX(service->bulk_tx.remove)].size :
-				0, rx_pending, rx_pending ?
-				service->bulk_rx.bulks[BULK_INDEX(service->bulk_rx.remove)].size :
-				0);
+				tx_pending, tx_size, rx_pending, rx_size);

 		if (VCHIQ_ENABLE_STATS) {
 			err = vchiq_dump(dump_context, buf, len + 1);