All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v2 01/30] drm: omapdrm: Split init and cleanup from probe and remove functions
Date: Tue, 13 Feb 2018 14:00:19 +0200	[thread overview]
Message-ID: <20180213120048.21603-2-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20180213120048.21603-1-laurent.pinchart@ideasonboard.com>

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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 83 +++++++++++++++++++++++---------------
 drivers/gpu/drm/omapdrm/omap_drv.h |  2 +
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index dd68b2556f5b..b571cc04e08d 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -510,24 +510,16 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
 	{ /* 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;
-	struct omap_drm_private *priv;
 	struct drm_device *ddev;
 	unsigned int i;
 	int ret;
 
-	DBG("%s", pdev->name);
-
-	if (omapdss_is_initialized() == false)
-		return -EPROBE_DEFER;
+	DBG("%s", dev_name(dev));
 
-	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;
-	}
+	priv->dev = dev;
 
 	omap_crtc_pre_init();
 
@@ -535,13 +527,6 @@ static int pdev_probe(struct platform_device *pdev)
 	if (ret)
 		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();
 
 	soc = soc_device_match(omapdrm_soc_devices);
@@ -552,14 +537,14 @@ static int pdev_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&priv->obj_list);
 
 	/* 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)) {
 		ret = PTR_ERR(ddev);
-		goto err_free_priv;
+		goto err_destroy_wq;
 	}
 
+	priv->ddev = ddev;
 	ddev->dev_private = priv;
-	platform_set_drvdata(pdev, ddev);
 
 	/* Get memory bandwidth limits */
 	if (priv->dispc_ops->get_memory_bandwidth_limit)
@@ -570,14 +555,14 @@ static int pdev_probe(struct platform_device *pdev)
 
 	ret = omap_modeset_init(ddev);
 	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;
 	}
 
 	/* Initialize vblank handling, start with all CRTCs disabled. */
 	ret = drm_vblank_init(ddev, priv->num_crtcs);
 	if (ret) {
-		dev_err(&pdev->dev, "could not init vblank\n");
+		dev_err(priv->dev, "could not init vblank\n");
 		goto err_cleanup_modeset;
 	}
 
@@ -610,20 +595,17 @@ static int pdev_probe(struct platform_device *pdev)
 err_free_drm_dev:
 	omap_gem_deinit(ddev);
 	drm_dev_unref(ddev);
-err_free_priv:
+err_destroy_wq:
 	destroy_workqueue(priv->wq);
-	kfree(priv);
-err_disconnect_dssdevs:
 	omap_disconnect_dssdevs();
 err_crtc_uninit:
 	omap_crtc_pre_uninit();
 	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 omap_drm_private *priv = ddev->dev_private;
+	struct drm_device *ddev = priv->ddev;
 
 	DBG("");
 
@@ -645,10 +627,45 @@ static int pdev_remove(struct platform_device *pdev)
 	drm_dev_unref(ddev);
 
 	destroy_workqueue(priv->wq);
-	kfree(priv);
 
 	omap_disconnect_dssdevs();
 	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;
 }
@@ -692,7 +709,8 @@ static int omap_drm_resume_all_displays(void)
 
 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);
 
@@ -705,7 +723,8 @@ static int omap_drm_suspend(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);
 	omap_drm_resume_all_displays();
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index ba322c519999..49351bb3731e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -46,6 +46,8 @@
 struct omap_drm_usergart;
 
 struct omap_drm_private {
+	struct drm_device *ddev;
+	struct device *dev;
 	u32 omaprev;
 
 	const struct dispc_ops *dispc_ops;
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-02-13 12:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 12:00 [PATCH v2 00/30] omapdrm: Allocate objects dynamically Laurent Pinchart
2018-02-13 12:00 ` Laurent Pinchart [this message]
2018-02-13 12:00 ` [PATCH v2 02/30] drm: omapdrm: dss: Expose DSS data in a dss_device structure Laurent Pinchart
2018-02-13 20:05   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 03/30] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 04/30] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable() Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 05/30] drm: omapdrm: dss: Pass DSS pointer to dss_sdi_*() functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 06/30] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 07/30] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source() Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 08/30] drm: omapdrm: dss: Pass DSS pointer to dss clock functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 09/30] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 10/30] drm: omapdrm: dss: Allocate the DSS private data structure dynamically Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 11/30] drm: omapdrm: dss: Support passing private data to debugfs show handlers Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 12/30] drm: omapdrm: dss: Store the registered plls array in struct dss_device Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 13/30] drm: omapdrm: dss: Store the debugfs root directory " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 14/30] drm: omapdrm: dss: Don't unnecessarily cast to dev to pdev and back Laurent Pinchart
2018-02-13 20:23   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 15/30] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 16/30] drm: omapdrm: dsi: Combine two commonly used inline functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 17/30] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 18/30] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 19/30] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 20/30] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 21/30] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops Laurent Pinchart
2018-02-13 20:58   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 22/30] drm: omapdrm: dss: Store DSS device pointer in the omapdrm private data Laurent Pinchart
2018-02-13 21:25   ` Sebastian Reichel
2018-02-14  8:31   ` Tomi Valkeinen
2018-02-14 15:34     ` Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 23/30] drm: omapdrm: dss: Store dispc ops in dss_device structure Laurent Pinchart
2018-02-13 21:32   ` Sebastian Reichel
2018-02-13 12:00 ` [PATCH v2 24/30] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 25/30] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 26/30] drm: omapdrm: dispc: Allocate the dispc private data structure dynamically Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 27/30] drm: omapdrm: hdmi4: Allocate the omap_hdmi " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 28/30] drm: omapdrm: hdmi5: " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 29/30] drm: omapdrm: sdi: Allocate the sdi private " Laurent Pinchart
2018-02-13 12:00 ` [PATCH v2 30/30] drm: omapdrm: venc: Allocate the venc " Laurent Pinchart
2018-02-14 13:24 ` [PATCH v2 00/30] omapdrm: Allocate objects dynamically Tomi Valkeinen
2018-02-14 15:39   ` Laurent Pinchart
2018-02-14 15:52     ` Tomi Valkeinen
2018-02-28  8:35 ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180213120048.21603-2-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.