linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/tegra: switch to using devm_gpiod_get_optional
@ 2019-09-15  7:13 Dmitry Torokhov
  2019-09-16 13:59 ` Thierry Reding
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2019-09-15  7:13 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter
  Cc: Thierry Reding, Jonathan Hunter, Dmitry Osipenko,
	Thomas Gleixner, dri-devel, linux-tegra, linux-kernel

We do not really need to use API that fetches GPIO data from an
arbitrary device tree node, as we are dealing with device tree node
assigned to the device structure. We can easily switch to
devm_gpiod_get_optional() plus gpiod_set_consumer_name() and clean up
the code.

Note this is part of efforts to get rid of [devm_]gpiod_get_from_of_node
in drivers so that gpiolib can be cleaned up.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpu/drm/tegra/output.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index bdcaa4c7168c..b4248125b844 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -121,19 +121,15 @@ int tegra_output_probe(struct tegra_output *output)
 		of_node_put(ddc);
 	}
 
-	output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev,
-						       output->of_node,
-						       "nvidia,hpd-gpio", 0,
-						       GPIOD_IN,
-						       "HDMI hotplug detect");
-	if (IS_ERR(output->hpd_gpio)) {
-		if (PTR_ERR(output->hpd_gpio) != -ENOENT)
-			return PTR_ERR(output->hpd_gpio);
-
-		output->hpd_gpio = NULL;
-	}
+	output->hpd_gpio = devm_gpiod_get_optional(output->dev,
+						   "nvidia,hpd", GPIOD_IN);
+	if (IS_ERR(output->hpd_gpio))
+		return PTR_ERR(output->hpd_gpio);
 
 	if (output->hpd_gpio) {
+		gpiod_set_consumer_name(output->hpd_gpio,
+					"HDMI hotplug detect");
+
 		err = gpiod_to_irq(output->hpd_gpio);
 		if (err < 0) {
 			dev_err(output->dev, "gpiod_to_irq(): %d\n", err);
-- 
2.23.0.237.gc6a4ce50a0-goog


-- 
Dmitry

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/tegra: switch to using devm_gpiod_get_optional
  2019-09-15  7:13 [PATCH] drm/tegra: switch to using devm_gpiod_get_optional Dmitry Torokhov
@ 2019-09-16 13:59 ` Thierry Reding
  2019-09-16 16:54   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Thierry Reding @ 2019-09-16 13:59 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: David Airlie, Daniel Vetter, Jonathan Hunter, Dmitry Osipenko,
	Thomas Gleixner, dri-devel, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]

On Sun, Sep 15, 2019 at 12:13:23AM -0700, Dmitry Torokhov wrote:
> We do not really need to use API that fetches GPIO data from an
> arbitrary device tree node, as we are dealing with device tree node
> assigned to the device structure. We can easily switch to
> devm_gpiod_get_optional() plus gpiod_set_consumer_name() and clean up
> the code.
> 
> Note this is part of efforts to get rid of [devm_]gpiod_get_from_of_node
> in drivers so that gpiolib can be cleaned up.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/gpu/drm/tegra/output.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)

We can't do that. There's a special case in rgb.c that sets
output->of_node to something different than output->dev, so we actually
need to pass the struct device_node * separately.

Thierry

> 
> diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
> index bdcaa4c7168c..b4248125b844 100644
> --- a/drivers/gpu/drm/tegra/output.c
> +++ b/drivers/gpu/drm/tegra/output.c
> @@ -121,19 +121,15 @@ int tegra_output_probe(struct tegra_output *output)
>  		of_node_put(ddc);
>  	}
>  
> -	output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev,
> -						       output->of_node,
> -						       "nvidia,hpd-gpio", 0,
> -						       GPIOD_IN,
> -						       "HDMI hotplug detect");
> -	if (IS_ERR(output->hpd_gpio)) {
> -		if (PTR_ERR(output->hpd_gpio) != -ENOENT)
> -			return PTR_ERR(output->hpd_gpio);
> -
> -		output->hpd_gpio = NULL;
> -	}
> +	output->hpd_gpio = devm_gpiod_get_optional(output->dev,
> +						   "nvidia,hpd", GPIOD_IN);
> +	if (IS_ERR(output->hpd_gpio))
> +		return PTR_ERR(output->hpd_gpio);
>  
>  	if (output->hpd_gpio) {
> +		gpiod_set_consumer_name(output->hpd_gpio,
> +					"HDMI hotplug detect");
> +
>  		err = gpiod_to_irq(output->hpd_gpio);
>  		if (err < 0) {
>  			dev_err(output->dev, "gpiod_to_irq(): %d\n", err);
> -- 
> 2.23.0.237.gc6a4ce50a0-goog
> 
> 
> -- 
> Dmitry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/tegra: switch to using devm_gpiod_get_optional
  2019-09-16 13:59 ` Thierry Reding
@ 2019-09-16 16:54   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2019-09-16 16:54 UTC (permalink / raw)
  To: Thierry Reding
  Cc: David Airlie, Daniel Vetter, Jonathan Hunter, Dmitry Osipenko,
	Thomas Gleixner, dri-devel, linux-tegra, linux-kernel

On Mon, Sep 16, 2019 at 03:59:04PM +0200, Thierry Reding wrote:
> On Sun, Sep 15, 2019 at 12:13:23AM -0700, Dmitry Torokhov wrote:
> > We do not really need to use API that fetches GPIO data from an
> > arbitrary device tree node, as we are dealing with device tree node
> > assigned to the device structure. We can easily switch to
> > devm_gpiod_get_optional() plus gpiod_set_consumer_name() and clean up
> > the code.
> > 
> > Note this is part of efforts to get rid of [devm_]gpiod_get_from_of_node
> > in drivers so that gpiolib can be cleaned up.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/gpu/drm/tegra/output.c | 18 +++++++-----------
> >  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> We can't do that. There's a special case in rgb.c that sets
> output->of_node to something different than output->dev, so we actually
> need to pass the struct device_node * separately.

Ugh, brainfart on my part. I totally read it is output->dev.of_node,
similar to another driver I was looking at...

Please discard, there will be another patch changing
devm_gpiod_get_from_of_node() to devm_fwnode_gpiod_get() once Linus
merges this new GPIO method.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-16 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-15  7:13 [PATCH] drm/tegra: switch to using devm_gpiod_get_optional Dmitry Torokhov
2019-09-16 13:59 ` Thierry Reding
2019-09-16 16:54   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).