Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Thierry Reding <thierry.reding@gmail.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org, Mark Brown <broonie@kernel.org>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH] drm/tegra: Fix regulator_get_optional() misuse
Date: Tue,  5 Nov 2019 12:59:42 +0000	[thread overview]
Message-ID: <20191105125943.34729-1-broonie@kernel.org> (raw)

The tegra driver requests a supply using regulator_get_optional()
but both the name of the supply and the usage pattern suggest that it is
being used for the main power for the device and is not at all optional
for the device for function, there is no meaningful handling for absent
supplies.  Such regulators should use the vanilla regulator_get()
interface, it will ensure that even if a supply is not described in the
system integration one will be provided in software.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/gpu/drm/tegra/dpaux.c | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index 622cdf1ad246..38686f56ea2f 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -505,18 +505,14 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	dpaux->vdd = devm_regulator_get_optional(&pdev->dev, "vdd");
+	dpaux->vdd = devm_regulator_get(&pdev->dev, "vdd");
 	if (IS_ERR(dpaux->vdd)) {
-		if (PTR_ERR(dpaux->vdd) != -ENODEV) {
-			if (PTR_ERR(dpaux->vdd) != -EPROBE_DEFER)
-				dev_err(&pdev->dev,
-					"failed to get VDD supply: %ld\n",
-					PTR_ERR(dpaux->vdd));
-
-			return PTR_ERR(dpaux->vdd);
-		}
+		if (PTR_ERR(dpaux->vdd) != -EPROBE_DEFER)
+			dev_err(&pdev->dev,
+				"failed to get VDD supply: %ld\n",
+				PTR_ERR(dpaux->vdd));
 
-		dpaux->vdd = NULL;
+		return PTR_ERR(dpaux->vdd);
 	}
 
 	platform_set_drvdata(pdev, dpaux);
@@ -731,11 +727,9 @@ int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output)
 	if (output->panel) {
 		enum drm_connector_status status;
 
-		if (dpaux->vdd) {
-			err = regulator_enable(dpaux->vdd);
-			if (err < 0)
-				return err;
-		}
+		err = regulator_enable(dpaux->vdd);
+		if (err < 0)
+			return err;
 
 		timeout = jiffies + msecs_to_jiffies(250);
 
@@ -767,11 +761,9 @@ int drm_dp_aux_detach(struct drm_dp_aux *aux)
 	if (dpaux->output->panel) {
 		enum drm_connector_status status;
 
-		if (dpaux->vdd) {
-			err = regulator_disable(dpaux->vdd);
-			if (err < 0)
-				return err;
-		}
+		err = regulator_disable(dpaux->vdd);
+		if (err < 0)
+			return err;
 
 		timeout = jiffies + msecs_to_jiffies(250);
 
-- 
2.20.1

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

             reply	other threads:[~2019-11-05 12:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 12:59 Mark Brown [this message]
2019-11-05 13:15 ` [PATCH] drm/tegra: Fix regulator_get_optional() misuse Thierry Reding
2019-11-05 13:24   ` Mark Brown

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=20191105125943.34729-1-broonie@kernel.org \
    --to=broonie@kernel.org \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.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