Thread (14 messages) 14 messages, 4 authors, 2015-07-10

Re: [PATCH v1 1/3] gpio: defer probe if pinctrl cannot be found

From: Rob Herring <hidden>
Date: 2015-07-10 18:41:28
Also in: linux-gpio, linux-tegra, lkml

On Fri, Jul 10, 2015 at 4:29 AM, Tomeu Vizoso
[off-list ref] wrote:
On 1 July 2015 at 19:36, Rob Herring [off-list ref] wrote:
quoted
On Wed, Jul 1, 2015 at 7:45 AM, Tomeu Vizoso [off-list ref] wrote:
quoted
When an OF node has a pin range for its GPIOs, return -EPROBE_DEFER if
the pin controller isn't available.

Otherwise, the GPIO range wouldn't be set at all unless the pin
controller probed always before the GPIO chip.

With this change, the probe of the GPIO chip will be deferred and will
be retried at a later point, hopefully once the pin controller has been
registered and probed already.
This will break cases where the pinctrl driver does not exist, but the
DT contains pinctrl bindings. We can have similar problems already
with clocks though. However, IMO this problem is a bit different in
that pinctrl is more likely entirely optional while clocks are often
required. You may do all pin setup in bootloader/firmware on some
boards and not others. Of course then why put pinctrl in the DT in
that case? They could be present just due to how chip vs. board dts
files are structured.
I see. My instinct tells me that it would be better if the gpio-ranges
property was set in the board dts, but I don't really know what each
mach does with its DTSs.
quoted
We could address this by simply marking the pin controller node
disabled. However, ...
quoted
@@ -361,7 +361,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip)

                pctldev = of_pinctrl_get(pinspec.np);
                if (!pctldev)
-                       break;
+                       return -EPROBE_DEFER;
But you cannot distinguish that case here. I think of_pinctrl_get
needs to set the error code appropriately.
Why not? I was thinking of just doing this before we call of_pinctrl_get():

        if (!of_device_is_available(pinspec.np))
            continue;
That is exactly what you need, but that should be of_pinctrl_get's
responsibility to check, not the caller's. IIRC, this is the only user
of of_pinctrl_get, so it should be just as easy to change.

Rob
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help