[PATCH 05/10] drm/ast: dp501: Inline ast_dp501_connector_init()

Jocelyn Falempe jfalempe at redhat.com
Thu Sep 12 13:38:54 UTC 2024


On 11/09/2024 13:51, Thomas Zimmermann wrote:
> Inline ast_dp501_connector_init() into its only caller. The helper
> currently only does half of the connector-init work and is trivial
> enough to be inlined.
> 
> Also set the local variables for encoder and connector as late as
> possible, so that the compiler warns if we use them before having
> initialized the instance.

Thanks, it looks good to me.

Reviewed-by: Jocelyn Falempe <jfalempe at redhat.com>
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
>   drivers/gpu/drm/ast/ast_dp501.c | 43 ++++++++++++++++-----------------
>   1 file changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c
> index 99bf44eec7b3..abb03d14c338 100644
> --- a/drivers/gpu/drm/ast/ast_dp501.c
> +++ b/drivers/gpu/drm/ast/ast_dp501.c
> @@ -567,34 +567,22 @@ static const struct drm_connector_funcs ast_dp501_connector_funcs = {
>   	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>   };
>   
> -static int ast_dp501_connector_init(struct drm_device *dev, struct drm_connector *connector)
> -{
> -	int ret;
> -
> -	ret = drm_connector_init(dev, connector, &ast_dp501_connector_funcs,
> -				 DRM_MODE_CONNECTOR_DisplayPort);
> -	if (ret)
> -		return ret;
> -
> -	drm_connector_helper_add(connector, &ast_dp501_connector_helper_funcs);
> -
> -	connector->interlace_allowed = 0;
> -	connector->doublescan_allowed = 0;
> -
> -	connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
> -
> -	return 0;
> -}
> +/*
> + * Output
> + */
>   
>   int ast_dp501_output_init(struct ast_device *ast)
>   {
>   	struct drm_device *dev = &ast->base;
>   	struct drm_crtc *crtc = &ast->crtc;
> -	struct drm_encoder *encoder = &ast->output.dp501.encoder;
> -	struct ast_connector *ast_connector = &ast->output.dp501.connector;
> -	struct drm_connector *connector = &ast_connector->base;
> +	struct drm_encoder *encoder;
> +	struct ast_connector *ast_connector;
> +	struct drm_connector *connector;
>   	int ret;
>   
> +	/* encoder */
> +
> +	encoder = &ast->output.dp501.encoder;
>   	ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs,
>   			       DRM_MODE_ENCODER_TMDS, NULL);
>   	if (ret)
> @@ -603,9 +591,20 @@ int ast_dp501_output_init(struct ast_device *ast)
>   
>   	encoder->possible_crtcs = drm_crtc_mask(crtc);
>   
> -	ret = ast_dp501_connector_init(dev, connector);
> +	/* connector */
> +
> +	ast_connector = &ast->output.dp501.connector;
> +	connector = &ast_connector->base;
> +	ret = drm_connector_init(dev, connector, &ast_dp501_connector_funcs,
> +				 DRM_MODE_CONNECTOR_DisplayPort);
>   	if (ret)
>   		return ret;
> +	drm_connector_helper_add(connector, &ast_dp501_connector_helper_funcs);
> +
> +	connector->interlace_allowed = 0;
> +	connector->doublescan_allowed = 0;
> +	connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
> +
>   	ast_connector->physical_status = connector->status;
>   
>   	ret = drm_connector_attach_encoder(connector, encoder);



More information about the dri-devel mailing list