linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Prathamesh Shete <pshete@nvidia.com>
Cc: linus.walleij@linaro.org, bgolaszewski@baylibre.com,
	linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, jonathanh@nvidia.com,
	smangipudi@nvidia.com, Manish Bhardwaj <mbhardwaj@nvidia.com>
Subject: Re: [PATCH] gpio: tegra186: Check PMC driver status before any request
Date: Mon, 24 Oct 2022 16:02:07 +0200	[thread overview]
Message-ID: <Y1aa3/oJA2ElSGp0@orome> (raw)
In-Reply-To: <20220912133309.18506-1-pshete@nvidia.com>

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

On Mon, Sep 12, 2022 at 07:03:09PM +0530, Prathamesh Shete wrote:
> This patch fixes the issue where even if pmc driver
> status is disabled still we are invoking pmc driver
> to process some request

s/pmc/PMC/ twice above. Also, this is slightly misleading. We're not
"invoking" the PMC driver, but rather we're trying to look up the IRQ
domain that the PMC driver would've registered if it had been enabled.
So perhaps reword this to more accurately reflect that.

> 
> Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
> Signed-off-by: Prathamesh Shete <pshete@nvidia.com>
> ---
>  drivers/gpio/gpio-tegra186.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 54d9fa7da9c1..efd508ba07a6 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -895,7 +895,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
>  		tegra186_gpio_init_route_mapping(gpio);
>  
>  	np = of_find_matching_node(NULL, tegra186_pmc_of_match);
> -	if (np) {
> +	if (of_device_is_available(np)) {
>  		irq->parent_domain = irq_find_host(np);
>  		of_node_put(np);

This now leaks a reference to np if np is found but not available. So
this should be something like:

	if (np) {
		if (of_device_is_available(np)) {
			irq->parent_domain = irq_find_host(np);
			of_node_put(np);

			if (!irq->parent_domain)
				return -EPROBE_DEFER;
		} else {
			of_node_put(np);
		}
	}

or:

	if (np) {
		if (of_device_is_available(np))
			irq->parent_domain = irq_find_host(np);

		of_node_put(np);

		if (of_device_is_available(np) && !irq->parent_domain)
			return -EPROBE_DEFER;
	}

The former is a little nicer because it doesn't check availability
twice.

Thierry

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

  reply	other threads:[~2022-10-24 17:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 13:33 [PATCH] gpio: tegra186: Check PMC driver status before any request Prathamesh Shete
2022-10-24 14:02 ` Thierry Reding [this message]
2022-10-26  7:06   ` [PATCH v2] " Prathamesh Shete
2022-11-08 10:34     ` Linus Walleij
2022-11-08 13:29     ` Thierry Reding
  -- strict thread matches above, loose matches on Subject: below --
2023-06-06  7:17 [PATCH] " Prathamesh Shete
2023-06-06  8:53 ` Jon Hunter
2023-06-07 10:55   ` Jon Hunter
2023-06-06  9:48 ` andy.shevchenko
2023-06-09  7:18 ` Linus Walleij

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=Y1aa3/oJA2ElSGp0@orome \
    --to=thierry.reding@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=jonathanh@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mbhardwaj@nvidia.com \
    --cc=pshete@nvidia.com \
    --cc=smangipudi@nvidia.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;
as well as URLs for NNTP newsgroup(s).