Commit 3789f5ac authored by Biju Das's avatar Biju Das Committed by Linus Walleij

gpiolib: Avoid calling chip->request() for unused gpios

Add a check for unused gpios to avoid chip->request() call to client
driver for unused gpios.
Signed-off-by: default avatarBiju Das <biju.das@bp.renesas.com>
Reviewed-by: default avatarFabrizio Castro <fabrizio.castro@bp.renesas.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 21041dab
...@@ -2267,6 +2267,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label) ...@@ -2267,6 +2267,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
struct gpio_chip *chip = desc->gdev->chip; struct gpio_chip *chip = desc->gdev->chip;
int status; int status;
unsigned long flags; unsigned long flags;
unsigned offset;
spin_lock_irqsave(&gpio_lock, flags); spin_lock_irqsave(&gpio_lock, flags);
...@@ -2285,7 +2286,11 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label) ...@@ -2285,7 +2286,11 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
if (chip->request) { if (chip->request) {
/* chip->request may sleep */ /* chip->request may sleep */
spin_unlock_irqrestore(&gpio_lock, flags); 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); spin_lock_irqsave(&gpio_lock, flags);
if (status < 0) { if (status < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment