Skip to contentSkip to conversation

gpio: tegra186: Check PMC driver status before any request

PATCH Superseded Prathamesh Shete 3 participants 5 messages Sep 12, 2022 – Nov 8, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: tegra186: Check PMC driver status before any request

This patch fixes the issue where even if pmc driver status is disabled still we are invoking pmc driver to process some request

---
 drivers/gpio/gpio-tegra186.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tegra186.c +1 -1
index 54d9fa7da9c1..efd508ba07a6 100644
@@ -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);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Prathamesh Shete

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.

Quoted 12 lines
---
 drivers/gpio/gpio-tegra186.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tegra186.c +0 -0
index 54d9fa7da9c1..efd508ba07a6 100644

drivers/gpio/gpio-tegra186.c static int tegra186_gpio_probe(struct platform_device *pdev) · line 900

Quoted 7 lines
drivers/gpio/gpio-tegra186.c +1 -1
@@ -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

#2 lore raw

PATCH v2 1/1 gpio: tegra186: Check PMC driver status before any request

This patch fixes the issue where even if PMC driver status is disabled still we are trying to look up for the IRQ domain that PMC driver would've registered if it had been enabled.

---
 drivers/gpio/gpio-tegra186.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpio/gpio-tegra186.c +9 -5
index 54d9fa7da9c1..b99756037ed4 100644
@@ -896,11 +896,15 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
 
 	np = of_find_matching_node(NULL, tegra186_pmc_of_match);
 	if (np) {
-		irq->parent_domain = irq_find_host(np);
-		of_node_put(np);
-
-		if (!irq->parent_domain)
-			return -EPROBE_DEFER;
+		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);
+		}
 	}
 
 	irq->map = devm_kcalloc(&pdev->dev, gpio->gpio.ngpio,
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#4 lore raw
In reply to Prathamesh Shete
Quoted 9 lines · Prathamesh Shete

This patch fixes the issue where even if PMC driver status is disabled still we are trying to look up for the IRQ domain that PMC driver would've registered if it had been enabled.

---
 drivers/gpio/gpio-tegra186.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)