Re: [PATCH 4/5] gpio: of: remove of_gpiochip_and_xlate() and struct gg_data

From: Linus Walleij
Date: Thu Jun 23 2016 - 03:41:42 EST


On Tue, Jun 14, 2016 at 12:07 PM, Masahiro Yamada
<yamada.masahiro@xxxxxxxxxxxxx> wrote:

> The usage of gpiochip_find(&gg_data, of_gpiochip_and_xlate) is odd.
>
> Usually gpiochip_find() is used to find a gpio_chip. Here, however,
> the return value from gpiochip_find() is just discarded. Instead,
> gpiochip_find(&gg_data, of_gpiochip_and_xlate) is called for the
> side-effect of the match function.
>
> The match function, of_gpiochip_find_and_xlate(), fills the given
> struct gg_data, but a match function should be simply called to
> judge the matching.
>
> This commit fixes this distortion and makes the code more readable.
> Remove of_gpiochip_find_and_xlate() and struct gg_data. Instead,
> this adds a very simple helper function of_find_gpiochip_by_node().
> Now, of_get_named_gpiod_flags() is implemented more straight-forward.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>

Excellent patch, this always confused me too. Now I understand
the code.

Patch applied.

Yours,
Linus Walleij