drm/omap: remove global dss_device variable
authorSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 15 Dec 2020 10:46:11 +0000 (12:46 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 15 Dec 2020 14:08:25 +0000 (16:08 +0200)
We can simply provide the device to the omapdrm driver
via pdata. omapdss_is_initialized() is no longer required
(even before this patch), since omapdrm device is only
registered after the pointer is initialized.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-39-tomi.valkeinen@ti.com
drivers/gpu/drm/omapdrm/dss/base.c
drivers/gpu/drm/omapdrm/dss/dss.c
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/omap_drv.c

index 3d2aa9d4ab6b90081c88cf68dcc2c61758a5fb28..68c5d058b2e9fe2c7acd64b7ea8208038af04285 100644 (file)
 #include "dss.h"
 #include "omapdss.h"
 
-static struct dss_device *dss_device;
-
-struct dss_device *omapdss_get_dss(void)
-{
-       return dss_device;
-}
-EXPORT_SYMBOL(omapdss_get_dss);
-
-void omapdss_set_dss(struct dss_device *dss)
-{
-       dss_device = dss;
-}
-EXPORT_SYMBOL(omapdss_set_dss);
-
 struct dispc_device *dispc_get_dispc(struct dss_device *dss)
 {
        return dss->dispc;
index d7b2f5bcac1698393f92ab18208e063732b9fc3c..0556711f57cdbdb3e995090f2a8e435d22bafebc 100644 (file)
@@ -1308,6 +1308,7 @@ static int dss_bind(struct device *dev)
 {
        struct dss_device *dss = dev_get_drvdata(dev);
        struct platform_device *drm_pdev;
+       struct dss_pdata pdata;
        int r;
 
        r = component_bind_all(dev, NULL);
@@ -1316,9 +1317,9 @@ static int dss_bind(struct device *dev)
 
        pm_set_vt_switch(0);
 
-       omapdss_set_dss(dss);
-
-       drm_pdev = platform_device_register_simple("omapdrm", 0, NULL, 0);
+       pdata.dss = dss;
+       drm_pdev = platform_device_register_data(NULL, "omapdrm", 0,
+                                                &pdata, sizeof(pdata));
        if (IS_ERR(drm_pdev)) {
                component_unbind_all(dev, NULL);
                return PTR_ERR(drm_pdev);
@@ -1335,8 +1336,6 @@ static void dss_unbind(struct device *dev)
 
        platform_device_unregister(dss->drm_pdev);
 
-       omapdss_set_dss(NULL);
-
        component_unbind_all(dev, NULL);
 }
 
index f2f96e9fcd58d55d644982b0fd455c82d969fb1b..7e50a34f90a8f932c564feb4a88bc6780b5f4308 100644 (file)
@@ -359,12 +359,9 @@ struct omap_dss_device {
        unsigned int of_port;
 };
 
-struct dss_device *omapdss_get_dss(void);
-void omapdss_set_dss(struct dss_device *dss);
-static inline bool omapdss_is_initialized(void)
-{
-       return !!omapdss_get_dss();
-}
+struct dss_pdata {
+       struct dss_device *dss;
+};
 
 void omapdss_display_init(struct omap_dss_device *dssdev);
 int omapdss_display_get_modes(struct drm_connector *connector,
index 42c2ed7520950dd61ed3dac24eefebd600fbf68d..825478c0196815ed31adc9cf4463e1a3a1d96778 100644 (file)
@@ -568,6 +568,7 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
 static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 {
        const struct soc_device_attribute *soc;
+       struct dss_pdata *pdata = dev->platform_data;
        struct drm_device *ddev;
        int ret;
 
@@ -582,7 +583,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
        ddev->dev_private = priv;
 
        priv->dev = dev;
-       priv->dss = omapdss_get_dss();
+       priv->dss = pdata->dss;
        priv->dispc = dispc_get_dispc(priv->dss);
        priv->dispc_ops = dispc_get_ops(priv->dss);
 
@@ -677,9 +678,6 @@ 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_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
        if (ret) {
                dev_err(&pdev->dev, "Failed to set the DMA mask\n");