[PATCH -next] drm: Small optimization to intel_dp_mst_atomic_master_trans_check

Ville Syrjälä ville.syrjala at linux.intel.com
Mon Oct 25 14:46:26 UTC 2021


On Thu, Oct 21, 2021 at 10:22:43PM -0400, He Ying wrote:
> If we want to return from for_each_intel_connector_iter(), one
> way is calling drm_connector_list_iter_end() before returning
> to avoid memleak. The other way is just breaking from the bracket
> and then returning after the outside drm_connector_list_iter_end().
> Obviously, the second way makes code smaller and more clear.
> Apply it to the function intel_dp_mst_atomic_master_trans_check().

Matches what we seem to be doing everywhere else.
Applied to drm-intel-next. Thanks.

> 
> Signed-off-by: He Ying <heying24 at huawei.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp_mst.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index 8d13d7b26a25..bbecbbbcb10d 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -231,6 +231,7 @@ intel_dp_mst_atomic_master_trans_check(struct intel_connector *connector,
>  	struct drm_i915_private *dev_priv = to_i915(state->base.dev);
>  	struct drm_connector_list_iter connector_list_iter;
>  	struct intel_connector *connector_iter;
> +	int ret = 0;
>  
>  	if (DISPLAY_VER(dev_priv) < 12)
>  		return  0;
> @@ -243,7 +244,6 @@ intel_dp_mst_atomic_master_trans_check(struct intel_connector *connector,
>  		struct intel_digital_connector_state *conn_iter_state;
>  		struct intel_crtc_state *crtc_state;
>  		struct intel_crtc *crtc;
> -		int ret;
>  
>  		if (connector_iter->mst_port != connector->mst_port ||
>  		    connector_iter == connector)
> @@ -252,8 +252,8 @@ intel_dp_mst_atomic_master_trans_check(struct intel_connector *connector,
>  		conn_iter_state = intel_atomic_get_digital_connector_state(state,
>  									   connector_iter);
>  		if (IS_ERR(conn_iter_state)) {
> -			drm_connector_list_iter_end(&connector_list_iter);
> -			return PTR_ERR(conn_iter_state);
> +			ret = PTR_ERR(conn_iter_state);
> +			break;
>  		}
>  
>  		if (!conn_iter_state->base.crtc)
> @@ -262,20 +262,18 @@ intel_dp_mst_atomic_master_trans_check(struct intel_connector *connector,
>  		crtc = to_intel_crtc(conn_iter_state->base.crtc);
>  		crtc_state = intel_atomic_get_crtc_state(&state->base, crtc);
>  		if (IS_ERR(crtc_state)) {
> -			drm_connector_list_iter_end(&connector_list_iter);
> -			return PTR_ERR(crtc_state);
> +			ret = PTR_ERR(crtc_state);
> +			break;
>  		}
>  
>  		ret = drm_atomic_add_affected_planes(&state->base, &crtc->base);
> -		if (ret) {
> -			drm_connector_list_iter_end(&connector_list_iter);
> -			return ret;
> -		}
> +		if (ret)
> +			break;
>  		crtc_state->uapi.mode_changed = true;
>  	}
>  	drm_connector_list_iter_end(&connector_list_iter);
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int
> -- 
> 2.17.1

-- 
Ville Syrjälä
Intel


More information about the dri-devel mailing list