diff mbox

[v2,2/3] pinctrl: tegra: Only set the gpio range if needed

Message ID 1436862596-27730-3-git-send-email-tomeu.vizoso@collabora.com
State New
Headers show

Commit Message

Tomeu Vizoso July 14, 2015, 8:29 a.m. UTC
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>
---

Changes in v2: None

 drivers/pinctrl/pinctrl-tegra.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Tomeu Vizoso Aug. 6, 2015, 1:40 p.m. UTC | #1
On 14 July 2015 at 10:29, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> 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>

Hi Linus,

do you mind if this goes through the Tegra tree? It would be best if
it went together with 3/3 ("ARM: tegra: Add gpio-ranges property"), to
avoid duplicated GPIO ranges.

Thanks,

Tomeu

> ---
>
> Changes in v2: None
>
>  drivers/pinctrl/pinctrl-tegra.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
> index 0f982b829be1..0fd7fd2b0f72 100644
> --- a/drivers/pinctrl/pinctrl-tegra.c
> +++ b/drivers/pinctrl/pinctrl-tegra.c
> @@ -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)
>  {
> @@ -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);
>
> --
> 2.4.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Aug. 13, 2015, 12:55 p.m. UTC | #2
On Thu, Aug 6, 2015 at 3:40 PM, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> On 14 July 2015 at 10:29, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
>> 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>
>
> Hi Linus,
>
> do you mind if this goes through the Tegra tree? It would be best if
> it went together with 3/3 ("ARM: tegra: Add gpio-ranges property"), to
> avoid duplicated GPIO ranges.

It's cool, go ahead:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
index 0f982b829be1..0fd7fd2b0f72 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -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)
 {
@@ -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);