mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: dri-devel@lists.freedesktop.org, stefan@agner.ch
Cc: alison.wang@freescale.com, airlied@linux.ie,
	jianwei.wang.chn@gmail.com, meng.yi@nxp.com,
	alexander.stein@systec-electronic.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] drm/fsl-dcu: handle missing panel gracefully
Date: Sat, 16 Apr 2016 22:25:51 -0700	[thread overview]
Message-ID: <1460870755-22964-3-git-send-email-stefan@agner.ch> (raw)
In-Reply-To: <1460870755-22964-1-git-send-email-stefan@agner.ch>

If the device tree property fsl,panel is missing, drm_panel_attach
is called with a NULL pointer as first argument. Having a panel is
basically mandatory since RGB is the only supported connector.
Check if a panel node has been found, return -ENODEV and cleanup
otherwise.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
index a07886f..819fe12 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -171,14 +171,18 @@ int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
 				      DRM_MODE_DPMS_OFF);
 
 	panel_node = of_parse_phandle(fsl_dev->np, "fsl,panel", 0);
-	if (panel_node) {
-		fsl_dev->connector.panel = of_drm_find_panel(panel_node);
-		if (!fsl_dev->connector.panel) {
-			ret = -EPROBE_DEFER;
-			goto err_sysfs;
-		}
-	of_node_put(panel_node);
+	if (!panel_node) {
+		dev_err(fsl_dev->dev, "fsl,panel property not found\n");
+		ret = -ENODEV;
+		goto err_sysfs;
+	}
+
+	fsl_dev->connector.panel = of_drm_find_panel(panel_node);
+	if (!fsl_dev->connector.panel) {
+		ret = -EPROBE_DEFER;
+		goto err_panel;
 	}
+	of_node_put(panel_node);
 
 	ret = drm_panel_attach(fsl_dev->connector.panel, connector);
 	if (ret) {
@@ -188,6 +192,8 @@ int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
 
 	return 0;
 
+err_panel:
+	of_node_put(panel_node);
 err_sysfs:
 	drm_connector_unregister(connector);
 err_cleanup:
-- 
2.8.0

  parent reply	other threads:[~2016-04-17  5:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-17  5:25 [PATCH 0/6] drm/fsl-dcu: unload fixes Stefan Agner
2016-04-17  5:25 ` [PATCH 1/6] drm/fsl-dcu: detach panel on destroy Stefan Agner
2016-04-17  5:25 ` Stefan Agner [this message]
2016-04-17  5:25 ` [PATCH 3/6] drm/fsl-dcu: use variable name dev for struct drm_device Stefan Agner
2016-04-17  5:25 ` [PATCH 4/6] drm/fsl-dcu: deallocate fbdev CMA on unload Stefan Agner
2016-04-17  5:25 ` [PATCH 5/6] drm/fsl-dcu: disable output polling on driver unload Stefan Agner
2016-04-17  5:25 ` [PATCH 6/6] drm/fsl-dcu: implement lastclose callback Stefan Agner
2016-04-26  3:27 ` [PATCH 0/6] drm/fsl-dcu: unload fixes Stefan Agner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460870755-22964-3-git-send-email-stefan@agner.ch \
    --to=stefan@agner.ch \
    --cc=airlied@linux.ie \
    --cc=alexander.stein@systec-electronic.com \
    --cc=alison.wang@freescale.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jianwei.wang.chn@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meng.yi@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®