Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5fa8e4a2 authored by Boris Brezillon's avatar Boris Brezillon Committed by Thierry Reding
Browse files

drm/panel: Make of_drm_find_panel() return an ERR_PTR() instead of NULL



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: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180509130042.9435-2-boris.brezillon@bootlin.com
parent 0ca0c827
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1152,7 +1152,7 @@ static int cdns_dsi_attach(struct mipi_dsi_host *host,
		np = of_node_get(dev->dev.of_node);
		np = of_node_get(dev->dev.of_node);


	panel = of_drm_find_panel(np);
	panel = of_drm_find_panel(np);
	if (panel) {
	if (!IS_ERR(panel)) {
		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DSI);
		bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DSI);
	} else {
	} else {
		bridge = of_drm_find_bridge(dev->dev.of_node);
		bridge = of_drm_find_bridge(dev->dev.of_node);
+2 −2
Original line number Original line Diff line number Diff line
@@ -68,9 +68,9 @@ static int lvds_encoder_probe(struct platform_device *pdev)


	panel = of_drm_find_panel(panel_node);
	panel = of_drm_find_panel(panel_node);
	of_node_put(panel_node);
	of_node_put(panel_node);
	if (!panel) {
	if (IS_ERR(panel)) {
		dev_dbg(&pdev->dev, "panel not found, deferring probe\n");
		dev_dbg(&pdev->dev, "panel not found, deferring probe\n");
		return -EPROBE_DEFER;
		return PTR_ERR(panel);
	}
	}


	lvds_encoder->panel_bridge =
	lvds_encoder->panel_bridge =
+3 −1
Original line number Original line Diff line number Diff line
@@ -241,8 +241,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,


	if (panel) {
	if (panel) {
		*panel = of_drm_find_panel(remote);
		*panel = of_drm_find_panel(remote);
		if (*panel)
		if (!IS_ERR(*panel))
			ret = 0;
			ret = 0;
		else
			*panel = NULL;
	}
	}


	/* No panel found yet, check for a bridge next. */
	/* No panel found yet, check for a bridge next. */
+4 −2
Original line number Original line Diff line number Diff line
@@ -151,7 +151,9 @@ EXPORT_SYMBOL(drm_panel_detach);
 * tree node. If a matching panel is found, return a pointer to it.
 * 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
 * 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)
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);
	mutex_unlock(&panel_lock);
	return NULL;
	return ERR_PTR(-EPROBE_DEFER);
}
}
EXPORT_SYMBOL(of_drm_find_panel);
EXPORT_SYMBOL(of_drm_find_panel);
#endif
#endif
+4 −2
Original line number Original line Diff line number Diff line
@@ -232,9 +232,11 @@ static int exynos_dp_probe(struct platform_device *pdev)
	np = of_parse_phandle(dev->of_node, "panel", 0);
	np = of_parse_phandle(dev->of_node, "panel", 0);
	if (np) {
	if (np) {
		dp->plat_data.panel = of_drm_find_panel(np);
		dp->plat_data.panel = of_drm_find_panel(np);

		of_node_put(np);
		of_node_put(np);
		if (!dp->plat_data.panel)
		if (IS_ERR(dp->plat_data.panel))
			return -EPROBE_DEFER;
			return PTR_ERR(dp->plat_data.panel);

		goto out;
		goto out;
	}
	}


Loading