gpio: tegra186: Check PMC driver status before any request
Subsystems (2)
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
@@ -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
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
Signed-off-by Manish Bhardwaj <[email protected]>Signed-off-by Prathamesh Shete <[email protected]>--- drivers/gpio/gpio-tegra186.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/gpio-tegra186.c +0
-0
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
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
@@ -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
Quoted 6 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.
Signed-off-by Manish Bhardwaj <[email protected]>Signed-off-by Prathamesh Shete <[email protected]>
Yours,
Linus Walleij
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.
Signed-off-by Manish Bhardwaj <[email protected]>Signed-off-by Prathamesh Shete <[email protected]>--- drivers/gpio/gpio-tegra186.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)