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 <jsa...@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 --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 @@ static struct platform_driver * const omap_dss_drivers[] = {
 #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 5752328..dda3237 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -1314,6 +1314,17 @@ static const struct soc_device_attribute 
dss_soc_devices[] = {
        { /* sentinel */ }
 };
 
+static struct platform_device *omap_drm_device;
+
+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 dss_device *dss = dev_get_drvdata(dev);
@@ -1323,6 +1334,12 @@ static int dss_bind(struct device *dev)
        if (r)
                return r;
 
+       r = initialize_omapdrm_device();
+       if (r) {
+               component_unbind_all(dev, NULL);
+               return r;
+       }
+
        pm_set_vt_switch(0);
 
        omapdss_gather_components(dev);
@@ -1335,6 +1352,8 @@ static void dss_unbind(struct device *dev)
 {
        omapdss_set_dss(NULL);
 
+       platform_device_unregister(omap_drm_device);
+
        component_unbind_all(dev, NULL);
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

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

Reply via email to