[PATCH 3/3] drm: sti: rework init sequence

Chris Wilson chris at chris-wilson.co.uk
Mon Jun 20 15:38:44 UTC 2016


On Mon, Jun 20, 2016 at 05:22:57PM +0200, Benjamin Gaignard wrote:
>  static int sti_bind(struct device *dev)
>  {
> -	return drm_platform_init(&sti_driver, to_platform_device(dev));
> +	struct drm_device *ddev;
> +	int ret;
> +
> +	ddev = drm_dev_alloc(&sti_driver, dev);
> +	if (!ddev)
> +		return -ENOMEM;
> +
> +	drm_dev_set_unique(ddev, dev_name(dev));
> +
> +	ddev->platformdev = to_platform_device(dev);
> +
> +	ret = sti_init(ddev);
> +	if (ret)
> +		goto err_drm_dev_unref;
> +
> +	ret = component_bind_all(ddev->dev, ddev);
> +	if (ret)
> +		goto err_cleanup;
> +
> +	ret = drm_dev_register(ddev, 0);
> +	if (ret)
> +		goto err_register;

Instead of coupling compositor_debug_init into the first CRTC, you can
call it explicitly now (since it is not CRTC related but dev).

> +	drm_mode_config_reset(ddev);
> +
> +	return 0;
> +
> +err_register:
> +	drm_mode_config_cleanup(ddev);
> +err_cleanup:
> +	sti_cleanup(ddev);
> +err_drm_dev_unref:
> +	drm_dev_unref(ddev);
> +	return ret;
>  }
>  
>  static void sti_unbind(struct device *dev)
>  {
> -	drm_put_dev(dev_get_drvdata(dev));
> +	struct drm_device *ddev = dev_get_drvdata(dev);
> +
> +	drm_connector_unregister_all(ddev);

^ redundant.

> +	drm_dev_unregister(ddev);
> +	sti_cleanup(ddev);
> +	drm_dev_unref(ddev);
>  }

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the dri-devel mailing list