Re: [PATCH 03/10] staging: vchiq_core: introduce get_bulk_reason

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

 



On Thu, Apr 22, 2021 at 10:07:49PM +0200, Stefan Wahren wrote:
> Nesting multiple ternary operators over multiple lines isn't easy to
> read. Move this logic into a separate inline function.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@xxxxxxxx>
> ---
>  .../vc04_services/interface/vchiq_arm/vchiq_core.c | 35 ++++++++++++++--------
>  1 file changed, 22 insertions(+), 13 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 8a1e6f5..3a72c36 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
> @@ -1226,6 +1226,22 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info,
>  	mutex_unlock(&state->recycle_mutex);
>  }
>  
> +static inline enum vchiq_reason
> +get_bulk_reason(struct vchiq_bulk *bulk)
> +{
> +	if (bulk->dir == VCHIQ_BULK_TRANSMIT) {
> +		if (bulk->actual == VCHIQ_BULK_ACTUAL_ABORTED)
> +			return VCHIQ_BULK_TRANSMIT_ABORTED;
> +
> +		return VCHIQ_BULK_TRANSMIT_DONE;
> +	}
> +
> +	if (bulk->actual == VCHIQ_BULK_ACTUAL_ABORTED)
> +		return VCHIQ_BULK_RECEIVE_ABORTED;
> +
> +	return VCHIQ_BULK_RECEIVE_DONE;
> +}
> +
>  /* Called by the slot handler - don't hold the bulk mutex */
>  static enum vchiq_status
>  notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
> @@ -1281,16 +1297,8 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue,
>  					spin_unlock(&bulk_waiter_spinlock);
>  				} else if (bulk->mode ==
>  					VCHIQ_BULK_MODE_CALLBACK) {
> -					enum vchiq_reason reason = (bulk->dir ==
> -						VCHIQ_BULK_TRANSMIT) ?
> -						((bulk->actual ==
> -						VCHIQ_BULK_ACTUAL_ABORTED) ?
> -						VCHIQ_BULK_TRANSMIT_ABORTED :
> -						VCHIQ_BULK_TRANSMIT_DONE) :
> -						((bulk->actual ==
> -						VCHIQ_BULK_ACTUAL_ABORTED) ?
> -						VCHIQ_BULK_RECEIVE_ABORTED :
> -						VCHIQ_BULK_RECEIVE_DONE);
> +					enum vchiq_reason reason =
> +							get_bulk_reason(bulk);
>  					status = make_service_callback(service,
>  						reason,	NULL, bulk->userdata);
>  					if (status == VCHIQ_RETRY)
> @@ -2622,9 +2630,10 @@ do_abort_bulks(struct vchiq_service *service)
>  	mutex_unlock(&service->bulk_mutex);
>  
>  	status = notify_bulks(service, &service->bulk_tx, 0/*!retry_poll*/);
> -	if (status == VCHIQ_SUCCESS)
> -		status = notify_bulks(service, &service->bulk_rx,
> -			0/*!retry_poll*/);
> +	if (status != VCHIQ_SUCCESS)
> +		return 0;
> +
> +	status = notify_bulks(service, &service->bulk_rx, 0/*!retry_poll*/);
>  	return (status == VCHIQ_SUCCESS);
>  }

Hi Stefan,

this change seem to be unrelated ti what's pointed out in changelog.
Should it be put in a separate patch?

>  
> -- 
> 2.7.4
> 
> 

thank you,

fabio




[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