]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/panel: Make of_drm_find_panel() return an ERR_PTR() instead of NULL
authorBoris Brezillon <boris.brezillon@bootlin.com>
Wed, 9 May 2018 13:00:39 +0000 (15:00 +0200)
committerThierry Reding <treding@nvidia.com>
Tue, 10 Jul 2018 15:59:05 +0000 (17:59 +0200)
Right now, the DRM panel logic returns NULL when a panel pointing to
the passed OF node is not present in the list of registered panels.

Most drivers interpret this NULL value as -EPROBE_DEFER, but we are
about to modify the semantic of of_drm_find_panel() and let the
framework return -ENODEV when the device node we're pointing to has
a status property that is not equal to "okay" or "ok".

Let's first patch the of_drm_find_panel() implementation to return
ERR_PTR(-EPROBE_DEFER) instead of NULL and patch all callers to replace
the '!panel' check by an 'IS_ERR(panel)' one.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180509130042.9435-2-boris.brezillon@bootlin.com
18 files changed:
drivers/gpu/drm/bridge/cdns-dsi.c
drivers/gpu/drm/bridge/lvds-encoder.c
drivers/gpu/drm/drm_of.c
drivers/gpu/drm/drm_panel.c
drivers/gpu/drm/exynos/exynos_dp.c
drivers/gpu/drm/exynos/exynos_drm_dpi.c
drivers/gpu/drm/exynos/exynos_drm_dsi.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
drivers/gpu/drm/msm/disp/mdp4/mdp4_lcdc_encoder.c
drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_connector.c
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/rcar-du/rcar_lvds.c
drivers/gpu/drm/rockchip/dw-mipi-dsi.c
drivers/gpu/drm/sti/sti_dvo.c
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
drivers/gpu/drm/tegra/dsi.c
drivers/gpu/drm/tegra/output.c
include/drm/drm_panel.h

index f2d43f24acfbecfbd92eca83c7430677f057aa9e..ce9496d13986937f9de7a0cbd4d146b9959d3615 100644 (file)
@@ -1152,7 +1152,7 @@ static int cdns_dsi_attach(struct mipi_dsi_host *host,
                np = of_node_get(dev->dev.of_node);
 
        panel = of_drm_find_panel(np);
-       if (panel) {
+       if (!IS_ERR(panel)) {
                bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DSI);
        } else {
                bridge = of_drm_find_bridge(dev->dev.of_node);
index 75b0d3f6e4de919301b63af95b28d2b7af4bf79e..f56c92f7af7c484b90fcbac98b9177e36177b949 100644 (file)
@@ -68,9 +68,9 @@ static int lvds_encoder_probe(struct platform_device *pdev)
 
        panel = of_drm_find_panel(panel_node);
        of_node_put(panel_node);
-       if (!panel) {
+       if (IS_ERR(panel)) {
                dev_dbg(&pdev->dev, "panel not found, deferring probe\n");
-               return -EPROBE_DEFER;
+               return PTR_ERR(panel);
        }
 
        lvds_encoder->panel_bridge =
index 3b8c7a6a5720da6e3d2b8157bdfba56659c4d512..1f4a16772583a04a4580e3f7ac1ff6ada27e88ec 100644 (file)
@@ -241,8 +241,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
 
        if (panel) {
                *panel = of_drm_find_panel(remote);
-               if (*panel)
+               if (!IS_ERR(*panel))
                        ret = 0;
+               else
+                       *panel = NULL;
        }
 
        /* No panel found yet, check for a bridge next. */
index 965530a6f4cd355cc82386a258b46f2363b63430..7e5530a048464b610910ae612ef0ab266f9fa8c1 100644 (file)
@@ -151,7 +151,9 @@ EXPORT_SYMBOL(drm_panel_detach);
  * tree node. If a matching panel is found, return a pointer to it.
  *
  * Return: A pointer to the panel registered for the specified device tree
- * node or NULL if no panel matching the device tree node can be found.
+ * node or an ERR_PTR() if no panel matching the device tree node can be found.
+ * The only error that can be reported is -EPROBE_DEFER, meaning that the panel
+ * device has not been probed yet, and the caller should retry later.
  */
 struct drm_panel *of_drm_find_panel(const struct device_node *np)
 {
@@ -167,7 +169,7 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np)
        }
 
        mutex_unlock(&panel_lock);
-       return NULL;
+       return ERR_PTR(-EPROBE_DEFER);
 }
 EXPORT_SYMBOL(of_drm_find_panel);
 #endif
index 86330f396784ddb8ecc0ba277ebefd0fe3ec50d7..af7ab1ceb50f4d0572b5c56aaa055cfb21b45133 100644 (file)
@@ -232,9 +232,11 @@ static int exynos_dp_probe(struct platform_device *pdev)
        np = of_parse_phandle(dev->of_node, "panel", 0);
        if (np) {
                dp->plat_data.panel = of_drm_find_panel(np);
+
                of_node_put(np);
-               if (!dp->plat_data.panel)
-                       return -EPROBE_DEFER;
+               if (IS_ERR(dp->plat_data.panel))
+                       return PTR_ERR(dp->plat_data.panel);
+
                goto out;
        }
 
index 66945e0dc57fc6c723fe8e891a0fa655d9358354..5887e8522b700c0f9af58796321badd4c321b345 100644 (file)
@@ -240,8 +240,8 @@ struct drm_encoder *exynos_dpi_probe(struct device *dev)
 
        if (ctx->panel_node) {
                ctx->panel = of_drm_find_panel(ctx->panel_node);
-               if (!ctx->panel)
-                       return ERR_PTR(-EPROBE_DEFER);
+               if (IS_ERR(ctx->panel))
+                       return ERR_CAST(ctx->panel);
        }
 
        return &ctx->encoder;
index 6d29777884f931eab3cde84986823b5341f0df76..809e1e0447dfeae05db6386893f306b0ca1291e2 100644 (file)
@@ -1519,6 +1519,9 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host,
        dsi->format = device->format;
        dsi->mode_flags = device->mode_flags;
        dsi->panel = of_drm_find_panel(device->dev.of_node);
+       if (IS_ERR(dsi->panel))
+               dsi->panel = NULL;
+
        if (dsi->panel) {
                drm_panel_attach(dsi->panel, &dsi->connector);
                dsi->connector.status = connector_status_connected;
index c54806d08dd78d0080ef42a314fe5ac2db40d7b6..681e2a07d03be788bd9508b201cdee795dcc4d8d 100644 (file)
@@ -148,8 +148,9 @@ int fsl_dcu_create_outputs(struct fsl_dcu_drm_device *fsl_dev)
        if (panel_node) {
                fsl_dev->connector.panel = of_drm_find_panel(panel_node);
                of_node_put(panel_node);
-               if (!fsl_dev->connector.panel)
-                       return -EPROBE_DEFER;
+               if (IS_ERR(fsl_dev->connector.panel))
+                       return PTR_ERR(fsl_dev->connector.panel);
+
                return fsl_dcu_attach_panel(fsl_dev, fsl_dev->connector.panel);
        }
 
index 4a645926edb7d1654978861b17cedc9c269ad0b3..2bfb39082f54dd7f9e9c51e038a46e2955ed03c8 100644 (file)
@@ -341,7 +341,7 @@ static void mdp4_lcdc_encoder_disable(struct drm_encoder *encoder)
        mdp4_write(mdp4_kms, REG_MDP4_LCDC_ENABLE, 0);
 
        panel = of_drm_find_panel(mdp4_lcdc_encoder->panel_node);
-       if (panel) {
+       if (!IS_ERR(panel)) {
                drm_panel_disable(panel);
                drm_panel_unprepare(panel);
        }
@@ -410,7 +410,7 @@ static void mdp4_lcdc_encoder_enable(struct drm_encoder *encoder)
                dev_err(dev->dev, "failed to enable lcdc_clk: %d\n", ret);
 
        panel = of_drm_find_panel(mdp4_lcdc_encoder->panel_node);
-       if (panel) {
+       if (!IS_ERR(panel)) {
                drm_panel_prepare(panel);
                drm_panel_enable(panel);
        }
index e3b1c86b7aaeaeecf39d0fff91cad1f6c1f325b8..32fba5664b0eefb162a689a54c77a4e9ae7c41b6 100644 (file)
@@ -34,9 +34,12 @@ static enum drm_connector_status mdp4_lvds_connector_detect(
        struct mdp4_lvds_connector *mdp4_lvds_connector =
                        to_mdp4_lvds_connector(connector);
 
-       if (!mdp4_lvds_connector->panel)
+       if (!mdp4_lvds_connector->panel) {
                mdp4_lvds_connector->panel =
                        of_drm_find_panel(mdp4_lvds_connector->panel_node);
+               if (IS_ERR(mdp4_lvds_connector->panel))
+                       mdp4_lvds_connector->panel = NULL;
+       }
 
        return mdp4_lvds_connector->panel ?
                        connector_status_connected :
index 2f1a2780658a416bd4e5235f34cf110965bce569..29841f440111e0aa4ba82ce8b899a202d86a8ad9 100644 (file)
@@ -1898,7 +1898,7 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer)
                 * output
                 */
                if (check_defer && msm_host->device_node) {
-                       if (!of_drm_find_panel(msm_host->device_node))
+                       if (IS_ERR(of_drm_find_panel(msm_host->device_node)))
                                if (!of_drm_find_bridge(msm_host->device_node))
                                        return -EPROBE_DEFER;
                }
index 155ad840f3c59d6cfae28caaba6a863ceb3880a9..5d8e391e75f4201b9b9df11482ce9b075ca4b46f 100644 (file)
@@ -434,8 +434,8 @@ static int rcar_lvds_parse_dt(struct rcar_lvds *lvds)
                        ret = -EPROBE_DEFER;
        } else {
                lvds->panel = of_drm_find_panel(remote);
-               if (!lvds->panel)
-                       ret = -EPROBE_DEFER;
+               if (IS_ERR(lvds->panel))
+                       ret = PTR_ERR(lvds->panel);
        }
 
 done:
index d53d5a09547f13a8af2e40f222b6e648058830e9..01642aaf6127333076ad1b0994c50b069f41c146 100644 (file)
@@ -595,7 +595,7 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
        dsi->format = device->format;
        dsi->mode_flags = device->mode_flags;
        dsi->panel = of_drm_find_panel(device->dev.of_node);
-       if (dsi->panel)
+       if (!IS_ERR(dsi->panel))
                return drm_panel_attach(dsi->panel, &dsi->connector);
 
        return -EINVAL;
index a5979cd25cc7d8264b9bc9edd462bbb1a31a8e53..030da55a8d3011e3150be1da4da3b67712f275ba 100644 (file)
@@ -387,7 +387,9 @@ sti_dvo_connector_detect(struct drm_connector *connector, bool force)
 
        if (!dvo->panel) {
                dvo->panel = of_drm_find_panel(dvo->panel_node);
-               if (dvo->panel)
+               if (IS_ERR(dvo->panel))
+                       dvo->panel = NULL;
+               else
                        drm_panel_attach(dvo->panel, connector);
        }
 
index da9814f94d008001c3d74a26733eb9594886dc14..2b40d1f6aee8946bd028e90106a4a7de8aba4b71 100644 (file)
@@ -833,8 +833,8 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host,
 
        dsi->device = device;
        dsi->panel = of_drm_find_panel(device->dev.of_node);
-       if (!dsi->panel)
-               return -EINVAL;
+       if (IS_ERR(dsi->panel))
+               return PTR_ERR(dsi->panel);
 
        dev_info(host->dev, "Attached device %s\n", device->name);
 
index 87c5d89bc9baf3cd09012f5a2385510b645ebe1b..ad88ec23032976e2eae1cbda9aeb86365a4c8def 100644 (file)
@@ -1411,6 +1411,9 @@ static int tegra_dsi_host_attach(struct mipi_dsi_host *host,
                struct tegra_output *output = &dsi->output;
 
                output->panel = of_drm_find_panel(device->dev.of_node);
+               if (IS_ERR(output->panel))
+                       output->panel = NULL;
+
                if (output->panel && output->connector.dev) {
                        drm_panel_attach(output->panel, &output->connector);
                        drm_helper_hpd_irq_event(output->connector.dev);
index ffe34bd0bb9d1f1a694299c1162767604a02c8bd..0c0936511bb48ea702946281b544ed63d5fa5386 100644 (file)
@@ -110,8 +110,8 @@ int tegra_output_probe(struct tegra_output *output)
        panel = of_parse_phandle(output->of_node, "nvidia,panel", 0);
        if (panel) {
                output->panel = of_drm_find_panel(panel);
-               if (!output->panel)
-                       return -EPROBE_DEFER;
+               if (IS_ERR(output->panel))
+                       return PTR_ERR(output->panel);
 
                of_node_put(panel);
        }
index 26a1b5fd8796cb7b4e495ca09b60e49bc06733bc..582a0ec0aa70448e07b39f5de7f49868e5787953 100644 (file)
@@ -200,7 +200,7 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np);
 #else
 static inline struct drm_panel *of_drm_find_panel(const struct device_node *np)
 {
-       return NULL;
+       return ERR_PTR(-ENODEV);
 }
 #endif