diff mbox series

[v4,5/6] drm/omap: dss: Move platform_device_register from core.c to dss.c probe

Message ID 60fa139e76020d244f0a4d5bd9807201a91d1f85.1518084092.git.jsarha@ti.com
State New
Headers show
Series drm/omap: Make omapdss API more generic + related patches | expand

Commit Message

Jyri Sarha Feb. 8, 2018, 10:21 a.m. UTC
Register the omapdrm device when we know that dss device probe going
to succeed. This avoids DSS6 and DSS2 omapdrm device registration from
colliding with each other.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 drivers/gpu/drm/omapdrm/dss/core.c | 26 ++------------------------
 drivers/gpu/drm/omapdrm/dss/dss.c  | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c
index acef7ec..6c9f667 100644
--- a/drivers/gpu/drm/omapdrm/dss/core.c
+++ b/drivers/gpu/drm/omapdrm/dss/core.c
@@ -45,36 +45,14 @@ 
 #endif
 };
 
-static struct platform_device *omap_drm_device;
-
 static int __init omap_dss_init(void)
 {
-	int r;
-
-	r = platform_register_drivers(omap_dss_drivers,
-				      ARRAY_SIZE(omap_dss_drivers));
-	if (r)
-		goto err_reg;
-
-	omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0);
-	if (IS_ERR(omap_drm_device)) {
-		r = PTR_ERR(omap_drm_device);
-		goto err_reg;
-	}
-
-	return 0;
-
-err_reg:
-	platform_unregister_drivers(omap_dss_drivers,
-				    ARRAY_SIZE(omap_dss_drivers));
-
-	return r;
+	return platform_register_drivers(omap_dss_drivers,
+					 ARRAY_SIZE(omap_dss_drivers));
 }
 
 static void __exit omap_dss_exit(void)
 {
-	platform_device_unregister(omap_drm_device);
-
 	platform_unregister_drivers(omap_dss_drivers,
 				    ARRAY_SIZE(omap_dss_drivers));
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 04300b2..3cfe4a7 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1298,6 +1298,17 @@  static int dss_video_pll_probe(struct platform_device *pdev)
 	{ /* sentinel */ }
 };
 
+static struct platform_device *omap_drm_device = NULL;
+
+static int initialize_omapdrm_device(void)
+{
+	omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0);
+	if (IS_ERR(omap_drm_device))
+		return PTR_ERR(omap_drm_device);
+
+	return 0;
+}
+
 static int dss_bind(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -1359,6 +1370,10 @@  static int dss_bind(struct device *dev)
 	if (r)
 		goto err_component;
 
+	r = initialize_omapdrm_device();
+	if (r)
+		goto err_omapdrm_device;
+
 	dss_debugfs_create_file("dss", dss_dump_regs);
 
 	pm_set_vt_switch(0);
@@ -1368,6 +1383,8 @@  static int dss_bind(struct device *dev)
 
 	return 0;
 
+err_omapdrm_device:
+	component_unbind_all(&pdev->dev, NULL);
 err_component:
 err_runtime_get:
 	pm_runtime_disable(&pdev->dev);
@@ -1390,6 +1407,8 @@  static void dss_unbind(struct device *dev)
 
 	omapdss_set_is_initialized(false);
 
+	platform_device_unregister(omap_drm_device);
+
 	component_unbind_all(&pdev->dev, NULL);
 
 	if (dss.video1_pll)