Message ID | 1397544101-18135-3-git-send-email-wens@csie.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Apr 15, 2014 at 8:41 AM, Chen-Yu Tsai <wens@csie.org> wrote: > This patch enables gpio-names based gpiod lookup in device tree usage, > which ignores the index passed to gpiod_get_index. If this fails, fall > back to the original function-index ("con_id"-gpios) based lookup scheme, > for backward compatibility and any drivers needing more than one GPIO > for any function. > > Signed-off-by: Chen-Yu Tsai <wens@csie.org> This looks a bit scary and I cannot claim to realize the entire semantic effect of this patch, but if it's the way to go then OK. Acked-by: Linus Walleij <linus.walleij@linaro.org> Shall I just apply this to the GPIO tree or are you carrying it along with the other stuff? Yours, Linus Walleij
Hi Linus, On Tue, Apr 22, 2014 at 05:00:17PM +0200, Linus Walleij wrote: > On Tue, Apr 15, 2014 at 8:41 AM, Chen-Yu Tsai <wens@csie.org> wrote: > > > This patch enables gpio-names based gpiod lookup in device tree usage, > > which ignores the index passed to gpiod_get_index. If this fails, fall > > back to the original function-index ("con_id"-gpios) based lookup scheme, > > for backward compatibility and any drivers needing more than one GPIO > > for any function. > > > > Signed-off-by: Chen-Yu Tsai <wens@csie.org> > > This looks a bit scary and I cannot claim to realize the entire semantic > effect of this patch, but if it's the way to go then OK. > Acked-by: Linus Walleij <linus.walleij@linaro.org> > > Shall I just apply this to the GPIO tree or are you carrying it along with > the other stuff? This patch has a dependency on the first patch of this serie, since it uses a binding that was documented there. Maybe you'll want to wait for the ACK from the DT maintainers to merge this one. Maxime
On Tue, Apr 22, 2014 at 5:18 PM, Maxime Ripard <maxime.ripard@free-electrons.com> wrote: > This patch has a dependency on the first patch of this serie, since it > uses a binding that was documented there. > > Maybe you'll want to wait for the ACK from the DT maintainers to merge > this one. Yeah I realized this a bit later, sorry for being a bit confused :-/ Yours, Linus Walleij
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 761013f..956f01e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2585,8 +2585,13 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, else snprintf(prop_name, 32, "gpios"); - desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, - &of_flags); + /* try gpio-names based lookup first */ + desc = of_get_gpiod_flags_by_name(dev->of_node, con_id, &of_flags); + + /* fallback to function based lookup */ + if (IS_ERR(desc)) + desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, + &of_flags); if (IS_ERR(desc)) return desc;
This patch enables gpio-names based gpiod lookup in device tree usage, which ignores the index passed to gpiod_get_index. If this fails, fall back to the original function-index ("con_id"-gpios) based lookup scheme, for backward compatibility and any drivers needing more than one GPIO for any function. Signed-off-by: Chen-Yu Tsai <wens@csie.org> --- drivers/gpio/gpiolib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)