Commit a82f0347 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Tomi Valkeinen

drm: omapdrm: Split init and cleanup from probe and remove functions

When merging the omapdrm and omapdss drivers there will be not omapdrm
platform device anymore, and thus no associated probe and remove
functions. To prepare for that, split all the initialization code from
the probe function to make it usable without a platform device.
Similarly, split the cleanup code from the remove function.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
parent bafa89fc
...@@ -510,24 +510,16 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = { ...@@ -510,24 +510,16 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
{ /* sentinel */ } { /* sentinel */ }
}; };
static int pdev_probe(struct platform_device *pdev) static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
{ {
const struct soc_device_attribute *soc; const struct soc_device_attribute *soc;
struct omap_drm_private *priv;
struct drm_device *ddev; struct drm_device *ddev;
unsigned int i; unsigned int i;
int ret; int ret;
DBG("%s", pdev->name); DBG("%s", dev_name(dev));
if (omapdss_is_initialized() == false)
return -EPROBE_DEFER;
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); priv->dev = dev;
if (ret) {
dev_err(&pdev->dev, "Failed to set the DMA mask\n");
return ret;
}
omap_crtc_pre_init(); omap_crtc_pre_init();
...@@ -535,13 +527,6 @@ static int pdev_probe(struct platform_device *pdev) ...@@ -535,13 +527,6 @@ static int pdev_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err_crtc_uninit; goto err_crtc_uninit;
/* Allocate and initialize the driver private structure. */
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
ret = -ENOMEM;
goto err_disconnect_dssdevs;
}
priv->dispc_ops = dispc_get_ops(); priv->dispc_ops = dispc_get_ops();
soc = soc_device_match(omapdrm_soc_devices); soc = soc_device_match(omapdrm_soc_devices);
...@@ -552,14 +537,14 @@ static int pdev_probe(struct platform_device *pdev) ...@@ -552,14 +537,14 @@ static int pdev_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&priv->obj_list); INIT_LIST_HEAD(&priv->obj_list);
/* Allocate and initialize the DRM device. */ /* Allocate and initialize the DRM device. */
ddev = drm_dev_alloc(&omap_drm_driver, &pdev->dev); ddev = drm_dev_alloc(&omap_drm_driver, priv->dev);
if (IS_ERR(ddev)) { if (IS_ERR(ddev)) {
ret = PTR_ERR(ddev); ret = PTR_ERR(ddev);
goto err_free_priv; goto err_destroy_wq;
} }
priv->ddev = ddev;
ddev->dev_private = priv; ddev->dev_private = priv;
platform_set_drvdata(pdev, ddev);
/* Get memory bandwidth limits */ /* Get memory bandwidth limits */
if (priv->dispc_ops->get_memory_bandwidth_limit) if (priv->dispc_ops->get_memory_bandwidth_limit)
...@@ -570,14 +555,14 @@ static int pdev_probe(struct platform_device *pdev) ...@@ -570,14 +555,14 @@ static int pdev_probe(struct platform_device *pdev)
ret = omap_modeset_init(ddev); ret = omap_modeset_init(ddev);
if (ret) { if (ret) {
dev_err(&pdev->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_free_drm_dev;
} }
/* Initialize vblank handling, start with all CRTCs disabled. */ /* Initialize vblank handling, start with all CRTCs disabled. */
ret = drm_vblank_init(ddev, priv->num_crtcs); ret = drm_vblank_init(ddev, priv->num_crtcs);
if (ret) { if (ret) {
dev_err(&pdev->dev, "could not init vblank\n"); dev_err(priv->dev, "could not init vblank\n");
goto err_cleanup_modeset; goto err_cleanup_modeset;
} }
...@@ -610,20 +595,17 @@ static int pdev_probe(struct platform_device *pdev) ...@@ -610,20 +595,17 @@ static int pdev_probe(struct platform_device *pdev)
err_free_drm_dev: err_free_drm_dev:
omap_gem_deinit(ddev); omap_gem_deinit(ddev);
drm_dev_unref(ddev); drm_dev_unref(ddev);
err_free_priv: err_destroy_wq:
destroy_workqueue(priv->wq); destroy_workqueue(priv->wq);
kfree(priv);
err_disconnect_dssdevs:
omap_disconnect_dssdevs(); omap_disconnect_dssdevs();
err_crtc_uninit: err_crtc_uninit:
omap_crtc_pre_uninit(); omap_crtc_pre_uninit();
return ret; return ret;
} }
static int pdev_remove(struct platform_device *pdev) static void omapdrm_cleanup(struct omap_drm_private *priv)
{ {
struct drm_device *ddev = platform_get_drvdata(pdev); struct drm_device *ddev = priv->ddev;
struct omap_drm_private *priv = ddev->dev_private;
DBG(""); DBG("");
...@@ -645,10 +627,45 @@ static int pdev_remove(struct platform_device *pdev) ...@@ -645,10 +627,45 @@ static int pdev_remove(struct platform_device *pdev)
drm_dev_unref(ddev); drm_dev_unref(ddev);
destroy_workqueue(priv->wq); destroy_workqueue(priv->wq);
kfree(priv);
omap_disconnect_dssdevs(); omap_disconnect_dssdevs();
omap_crtc_pre_uninit(); omap_crtc_pre_uninit();
}
static int pdev_probe(struct platform_device *pdev)
{
struct omap_drm_private *priv;
int ret;
if (omapdss_is_initialized() == false)
return -EPROBE_DEFER;
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pdev->dev, "Failed to set the DMA mask\n");
return ret;
}
/* Allocate and initialize the driver private structure. */
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
platform_set_drvdata(pdev, priv);
ret = omapdrm_init(priv, &pdev->dev);
if (ret < 0)
kfree(priv);
return ret;
}
static int pdev_remove(struct platform_device *pdev)
{
struct omap_drm_private *priv = platform_get_drvdata(pdev);
omapdrm_cleanup(priv);
kfree(priv);
return 0; return 0;
} }
...@@ -692,7 +709,8 @@ static int omap_drm_resume_all_displays(void) ...@@ -692,7 +709,8 @@ static int omap_drm_resume_all_displays(void)
static int omap_drm_suspend(struct device *dev) static int omap_drm_suspend(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct omap_drm_private *priv = dev_get_drvdata(dev);
struct drm_device *drm_dev = priv->ddev;
drm_kms_helper_poll_disable(drm_dev); drm_kms_helper_poll_disable(drm_dev);
...@@ -705,7 +723,8 @@ static int omap_drm_suspend(struct device *dev) ...@@ -705,7 +723,8 @@ static int omap_drm_suspend(struct device *dev)
static int omap_drm_resume(struct device *dev) static int omap_drm_resume(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct omap_drm_private *priv = dev_get_drvdata(dev);
struct drm_device *drm_dev = priv->ddev;
drm_modeset_lock_all(drm_dev); drm_modeset_lock_all(drm_dev);
omap_drm_resume_all_displays(); omap_drm_resume_all_displays();
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
struct omap_drm_usergart; struct omap_drm_usergart;
struct omap_drm_private { struct omap_drm_private {
struct drm_device *ddev;
struct device *dev;
u32 omaprev; u32 omaprev;
const struct dispc_ops *dispc_ops; const struct dispc_ops *dispc_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment