mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-15 23:25:07 +00:00
drm/omap: Allocate drm_device earlier and unref it as last step
If we allocate the drm_device earlier we can just return the error code without the need to use goto. Do the unref of the drm_device as a last step when cleaning up. This will make the drm_device available longer for us and makes sure that we only free up the memory when all other cleanups have been already done. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
This commit is contained in:
parent
5b394b2ddf
commit
fb96b67c8a
1 changed files with 13 additions and 16 deletions
|
@ -525,6 +525,14 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
|
||||||
|
|
||||||
DBG("%s", dev_name(dev));
|
DBG("%s", dev_name(dev));
|
||||||
|
|
||||||
|
/* Allocate and initialize the DRM device. */
|
||||||
|
ddev = drm_dev_alloc(&omap_drm_driver, dev);
|
||||||
|
if (IS_ERR(ddev))
|
||||||
|
return PTR_ERR(ddev);
|
||||||
|
|
||||||
|
priv->ddev = ddev;
|
||||||
|
ddev->dev_private = priv;
|
||||||
|
|
||||||
priv->dev = dev;
|
priv->dev = dev;
|
||||||
priv->dss = omapdss_get_dss();
|
priv->dss = omapdss_get_dss();
|
||||||
priv->dispc = dispc_get_dispc(priv->dss);
|
priv->dispc = dispc_get_dispc(priv->dss);
|
||||||
|
@ -543,16 +551,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
|
||||||
mutex_init(&priv->list_lock);
|
mutex_init(&priv->list_lock);
|
||||||
INIT_LIST_HEAD(&priv->obj_list);
|
INIT_LIST_HEAD(&priv->obj_list);
|
||||||
|
|
||||||
/* Allocate and initialize the DRM device. */
|
|
||||||
ddev = drm_dev_alloc(&omap_drm_driver, priv->dev);
|
|
||||||
if (IS_ERR(ddev)) {
|
|
||||||
ret = PTR_ERR(ddev);
|
|
||||||
goto err_destroy_wq;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->ddev = ddev;
|
|
||||||
ddev->dev_private = priv;
|
|
||||||
|
|
||||||
/* Get memory bandwidth limits */
|
/* Get memory bandwidth limits */
|
||||||
if (priv->dispc_ops->get_memory_bandwidth_limit)
|
if (priv->dispc_ops->get_memory_bandwidth_limit)
|
||||||
priv->max_bandwidth =
|
priv->max_bandwidth =
|
||||||
|
@ -563,7 +561,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
|
||||||
ret = omap_modeset_init(ddev);
|
ret = omap_modeset_init(ddev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
|
dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
|
||||||
goto err_free_drm_dev;
|
goto err_gem_deinit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize vblank handling, start with all CRTCs disabled. */
|
/* Initialize vblank handling, start with all CRTCs disabled. */
|
||||||
|
@ -599,14 +597,13 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
|
||||||
err_cleanup_modeset:
|
err_cleanup_modeset:
|
||||||
drm_mode_config_cleanup(ddev);
|
drm_mode_config_cleanup(ddev);
|
||||||
omap_drm_irq_uninstall(ddev);
|
omap_drm_irq_uninstall(ddev);
|
||||||
err_free_drm_dev:
|
err_gem_deinit:
|
||||||
omap_gem_deinit(ddev);
|
omap_gem_deinit(ddev);
|
||||||
drm_dev_unref(ddev);
|
|
||||||
err_destroy_wq:
|
|
||||||
destroy_workqueue(priv->wq);
|
destroy_workqueue(priv->wq);
|
||||||
omap_disconnect_dssdevs();
|
omap_disconnect_dssdevs();
|
||||||
err_crtc_uninit:
|
err_crtc_uninit:
|
||||||
omap_crtc_pre_uninit();
|
omap_crtc_pre_uninit();
|
||||||
|
drm_dev_unref(ddev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,12 +627,12 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
|
||||||
omap_drm_irq_uninstall(ddev);
|
omap_drm_irq_uninstall(ddev);
|
||||||
omap_gem_deinit(ddev);
|
omap_gem_deinit(ddev);
|
||||||
|
|
||||||
drm_dev_unref(ddev);
|
|
||||||
|
|
||||||
destroy_workqueue(priv->wq);
|
destroy_workqueue(priv->wq);
|
||||||
|
|
||||||
omap_disconnect_dssdevs();
|
omap_disconnect_dssdevs();
|
||||||
omap_crtc_pre_uninit();
|
omap_crtc_pre_uninit();
|
||||||
|
|
||||||
|
drm_dev_unref(ddev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pdev_probe(struct platform_device *pdev)
|
static int pdev_probe(struct platform_device *pdev)
|
||||||
|
|
Loading…
Reference in a new issue