Skip to content

Commit 8323f3a

Browse files
guixinliu1995Bartosz Golaszewski
authored andcommitted
gpio: tegra186: fix resource handling in ACPI probe path
When the Tegra186 GPIO controller is probed through ACPI matching, the driver emits two error messages during probing: "tegra186-gpio NVDA0508:00: invalid resource (null)" "tegra186-gpio NVDA0508:00: invalid resource (null)" Fix this by getting resource first and then do the ioremap. Fixes: 2606e7c ("gpio: tegra186: Add ACPI support") Cc: [email protected] Signed-off-by: Guixin Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 0af2f6b commit 8323f3a

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

drivers/gpio/gpio-tegra186.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
823823
struct gpio_irq_chip *irq;
824824
struct tegra_gpio *gpio;
825825
struct device_node *np;
826+
struct resource *res;
826827
char **names;
827828
int err;
828829

@@ -842,19 +843,19 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
842843
gpio->num_banks++;
843844

844845
/* get register apertures */
845-
gpio->secure = devm_platform_ioremap_resource_byname(pdev, "security");
846-
if (IS_ERR(gpio->secure)) {
847-
gpio->secure = devm_platform_ioremap_resource(pdev, 0);
848-
if (IS_ERR(gpio->secure))
849-
return PTR_ERR(gpio->secure);
850-
}
851-
852-
gpio->base = devm_platform_ioremap_resource_byname(pdev, "gpio");
853-
if (IS_ERR(gpio->base)) {
854-
gpio->base = devm_platform_ioremap_resource(pdev, 1);
855-
if (IS_ERR(gpio->base))
856-
return PTR_ERR(gpio->base);
857-
}
846+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "security");
847+
if (!res)
848+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
849+
gpio->secure = devm_ioremap_resource(&pdev->dev, res);
850+
if (IS_ERR(gpio->secure))
851+
return PTR_ERR(gpio->secure);
852+
853+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gpio");
854+
if (!res)
855+
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
856+
gpio->base = devm_ioremap_resource(&pdev->dev, res);
857+
if (IS_ERR(gpio->base))
858+
return PTR_ERR(gpio->base);
858859

859860
err = platform_irq_count(pdev);
860861
if (err < 0)

0 commit comments

Comments
 (0)