linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] gpio: refactor of_parse_own_gpio() and of_get_named_gpiod_flags()
@ 2016-06-14 10:07 Masahiro Yamada
  2016-06-14 10:07 ` [PATCH 1/5] gpio: of: optimize "gpios" property parsing of of_parse_own_gpio() Masahiro Yamada
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Masahiro Yamada @ 2016-06-14 10:07 UTC (permalink / raw)
  To: linux-gpio
  Cc: Masahiro Yamada, Linus Walleij, Alexandre Courbot, linux-kernel


I found one bug in of_parse_own_gpio(); of_gpiochip_find_and_xlate()
fills gg_data->out_gpio with an error pointer if the .of_xlate()
callback fails, but of_parse_own_gpio() only checks whether the
out_gpio is NULL.  This is a problem because the error pointer might
be passed to the desc_to_gpio() in the failure path.

At first, I was trying to fix it with the following patch:

    @@ -165,6 +165,9 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
                return ERR_PTR(ret);

        gpiochip_find(&gg_data, of_gpiochip_find_and_xlate);
    +   if (IS_ERR(gg_data.out_gpio)){
    +           return gg_data.out_gpio;
    +   }
        if (!gg_data.out_gpio) {
                if (np->parent == np)
                        return ERR_PTR(-ENXIO);

But, after reading this code around, I thought it was more complex
than needed.  So, I decided to clean-up it instead of fix the bug.

Talking about of_parse_own_gpio(), does it need to call gpiochip_find()
in the first place?

The caller of this function, of_gpiochip_scan_gpios() already knows the
gpio_chip.  I want to make the implementation more straight-forward.



Masahiro Yamada (5):
  gpio: of: optimize "gpios" property parsing of of_parse_own_gpio()
  gpio: of: drop needless gpio_chip look-up in of_parse_own_gpio()
  gpio: of: move chip->of_gpio_n_cells checking to of_gpiochip_add()
  gpio: of: remove of_gpiochip_and_xlate() and struct gg_data
  gpio: of: factor out common code to a new helper function

 drivers/gpio/gpiolib-of.c | 126 +++++++++++++++++++++-------------------------
 1 file changed, 58 insertions(+), 68 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-06-23  7:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14 10:07 [PATCH 0/5] gpio: refactor of_parse_own_gpio() and of_get_named_gpiod_flags() Masahiro Yamada
2016-06-14 10:07 ` [PATCH 1/5] gpio: of: optimize "gpios" property parsing of of_parse_own_gpio() Masahiro Yamada
2016-06-23  7:23   ` Linus Walleij
2016-06-14 10:07 ` [PATCH 2/5] gpio: of: drop needless gpio_chip look-up in of_parse_own_gpio() Masahiro Yamada
2016-06-23  7:34   ` Linus Walleij
2016-06-14 10:07 ` [PATCH 3/5] gpio: of: move chip->of_gpio_n_cells checking to of_gpiochip_add() Masahiro Yamada
2016-06-23  7:36   ` Linus Walleij
2016-06-14 10:07 ` [PATCH 4/5] gpio: of: remove of_gpiochip_and_xlate() and struct gg_data Masahiro Yamada
2016-06-23  7:41   ` Linus Walleij
2016-06-14 10:07 ` [PATCH 5/5] gpio: of: factor out common code to a new helper function Masahiro Yamada
2016-06-23  7:42   ` Linus Walleij
2016-06-23  7:44 ` [PATCH 0/5] gpio: refactor of_parse_own_gpio() and of_get_named_gpiod_flags() Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).