Message ID | 1533626118-26583-1-git-send-email-biju.das@bp.renesas.com |
---|---|
State | New |
Headers | show |
Series | gpiolib: Avoid calling chip->request() for unused gpios | expand |
Hi Biju, Thanks for your patch! On Tue, Aug 7, 2018 at 9:21 AM Biju Das <biju.das@bp.renesas.com> wrote: > Add a check for unused gpios to avoid chip->request() call to client > driver for unused gpios. "... so not every driver has to do this in its chip->request() callback." Note that currently no driver seems to check for this. I was mistaken in my earlier report about msm_pinmux_request (this is pinmux_ops.request(), not gpio_chip.request()). > Signed-off-by: Biju Das <biju.das@bp.renesas.com> > Reviewed-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- 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
On Tue, Aug 7, 2018 at 9:21 AM Biju Das <biju.das@bp.renesas.com> wrote: > Add a check for unused gpios to avoid chip->request() call to client > driver for unused gpios. > > Signed-off-by: Biju Das <biju.das@bp.renesas.com> > Reviewed-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com> Patch applied with Geert's ACK. Yours, Linus Walleij
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 20fe531..1ffe17b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2261,6 +2261,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label) struct gpio_chip *chip = desc->gdev->chip; int status; unsigned long flags; + unsigned offset; spin_lock_irqsave(&gpio_lock, flags); @@ -2279,7 +2280,11 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label) if (chip->request) { /* chip->request may sleep */ spin_unlock_irqrestore(&gpio_lock, flags); - status = chip->request(chip, gpio_chip_hwgpio(desc)); + offset = gpio_chip_hwgpio(desc); + if (gpiochip_line_is_valid(chip, offset)) + status = chip->request(chip, offset); + else + status = -EINVAL; spin_lock_irqsave(&gpio_lock, flags); if (status < 0) {