Skip to content

Commit

Permalink
pinctrl: tegra: Only set the gpio range if needed
Browse files Browse the repository at this point in the history
If the gpio DT node has the gpio-ranges property, the range will be
added by the gpio core and doesn't need to be added by the pinctrl
driver.

By having the gpio-ranges property, we have an explicit dependency from
the gpio node to the pinctrl node and we can stop using the deprecated
pinctrl_add_gpio_range() function.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
  • Loading branch information
Tomeu Vizoso authored and Thierry Reding committed Aug 13, 2015
1 parent d770e55 commit 9462510
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion drivers/pinctrl/pinctrl-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,22 @@ static struct pinctrl_desc tegra_pinctrl_desc = {
.owner = THIS_MODULE,
};

static bool gpio_node_has_range(void)
{
struct device_node *np;
bool has_prop = false;

np = of_find_compatible_node(NULL, NULL, "nvidia,tegra30-gpio");
if (!np)
return has_prop;

has_prop = of_find_property(np, "gpio-ranges", NULL);

of_node_put(np);

return has_prop;
}

int tegra_pinctrl_probe(struct platform_device *pdev,
const struct tegra_pinctrl_soc_data *soc_data)
{
Expand Down Expand Up @@ -708,7 +724,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
return PTR_ERR(pmx->pctl);
}

pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range);
if (!gpio_node_has_range())
pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range);

platform_set_drvdata(pdev, pmx);

Expand Down

0 comments on commit 9462510

Please sign in to comment.