[PATCH v2 5/5] drm/udl: Remove struct udl_connector

Jani Nikula jani.nikula at linux.intel.com
Fri May 10 12:20:33 UTC 2024


On Wed, 10 Apr 2024, Thomas Zimmermann <tzimmermann at suse.de> wrote:
> Udl's struct udl_connector is an empty wrapper around struct
> drm_connector. Remove it. Allocate the connector as part of struct
> udl_device and inline the init function into its only caller.
>
> v2:
> - fix return value in udl_modeset_init() (Dan)
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>

The patch does what it says on the box, but I don't know the driver
enough to say if this is the reasonable thing to do. With that,

Reviewed-by: Jani Nikula <jani.nikula at intel.com>

> ---
>  drivers/gpu/drm/udl/udl_drv.h     | 10 +------
>  drivers/gpu/drm/udl/udl_modeset.c | 49 +++++++------------------------
>  2 files changed, 11 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
> index f112cfb270f31..1eb716d9dad57 100644
> --- a/drivers/gpu/drm/udl/udl_drv.h
> +++ b/drivers/gpu/drm/udl/udl_drv.h
> @@ -49,15 +49,6 @@ struct urb_list {
>  	size_t size;
>  };
>  
> -struct udl_connector {
> -	struct drm_connector connector;
> -};
> -
> -static inline struct udl_connector *to_udl_connector(struct drm_connector *connector)
> -{
> -	return container_of(connector, struct udl_connector, connector);
> -}
> -
>  struct udl_device {
>  	struct drm_device drm;
>  	struct device *dev;
> @@ -66,6 +57,7 @@ struct udl_device {
>  	struct drm_plane primary_plane;
>  	struct drm_crtc crtc;
>  	struct drm_encoder encoder;
> +	struct drm_connector connector;
>  
>  	struct mutex gem_lock;
>  
> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
> index 4236ce57f5945..bbb04f98886a2 100644
> --- a/drivers/gpu/drm/udl/udl_modeset.c
> +++ b/drivers/gpu/drm/udl/udl_modeset.c
> @@ -444,49 +444,14 @@ static const struct drm_connector_helper_funcs udl_connector_helper_funcs = {
>  	.detect_ctx = udl_connector_helper_detect_ctx,
>  };
>  
> -static void udl_connector_destroy(struct drm_connector *connector)
> -{
> -	struct udl_connector *udl_connector = to_udl_connector(connector);
> -
> -	drm_connector_cleanup(connector);
> -	kfree(udl_connector);
> -}
> -
>  static const struct drm_connector_funcs udl_connector_funcs = {
>  	.reset = drm_atomic_helper_connector_reset,
>  	.fill_modes = drm_helper_probe_single_connector_modes,
> -	.destroy = udl_connector_destroy,
> +	.destroy = drm_connector_cleanup,
>  	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
>  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>  };
>  
> -struct drm_connector *udl_connector_init(struct drm_device *dev)
> -{
> -	struct udl_connector *udl_connector;
> -	struct drm_connector *connector;
> -	int ret;
> -
> -	udl_connector = kzalloc(sizeof(*udl_connector), GFP_KERNEL);
> -	if (!udl_connector)
> -		return ERR_PTR(-ENOMEM);
> -
> -	connector = &udl_connector->connector;
> -	ret = drm_connector_init(dev, connector, &udl_connector_funcs, DRM_MODE_CONNECTOR_VGA);
> -	if (ret)
> -		goto err_kfree;
> -
> -	drm_connector_helper_add(connector, &udl_connector_helper_funcs);
> -
> -	connector->polled = DRM_CONNECTOR_POLL_CONNECT |
> -			    DRM_CONNECTOR_POLL_DISCONNECT;
> -
> -	return connector;
> -
> -err_kfree:
> -	kfree(udl_connector);
> -	return ERR_PTR(ret);
> -}
> -
>  /*
>   * Modesetting
>   */
> @@ -556,9 +521,15 @@ int udl_modeset_init(struct drm_device *dev)
>  		return ret;
>  	encoder->possible_crtcs = drm_crtc_mask(crtc);
>  
> -	connector = udl_connector_init(dev);
> -	if (IS_ERR(connector))
> -		return PTR_ERR(connector);
> +	connector = &udl->connector;
> +	ret = drm_connector_init(dev, connector, &udl_connector_funcs, DRM_MODE_CONNECTOR_VGA);
> +	if (ret)
> +		return ret;
> +	drm_connector_helper_add(connector, &udl_connector_helper_funcs);
> +
> +	connector->polled = DRM_CONNECTOR_POLL_CONNECT |
> +			    DRM_CONNECTOR_POLL_DISCONNECT;
> +
>  	ret = drm_connector_attach_encoder(connector, encoder);
>  	if (ret)
>  		return ret;

-- 
Jani Nikula, Intel


More information about the dri-devel mailing list