Skip to content

Commit 6df6ea4

Browse files
pobrnBartosz Golaszewski
authored andcommitted
gpiolib: clear requested flag if line is invalid
If `gpiochip_line_is_valid()` fails, then `-EINVAL` is returned, but `desc->flags` will have `GPIOD_FLAG_REQUESTED` set, which will result in subsequent calls misleadingly returning `-EBUSY`. Fix that by clearing the flag in case of failure. Fixes: a501624 ("gpio: Respect valid_mask when requesting GPIOs") Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/20260310204359.1202451-1-pobrn@protonmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 189645b commit 6df6ea4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,8 +2465,10 @@ int gpiod_request_commit(struct gpio_desc *desc, const char *label)
24652465
return -EBUSY;
24662466

24672467
offset = gpiod_hwgpio(desc);
2468-
if (!gpiochip_line_is_valid(guard.gc, offset))
2469-
return -EINVAL;
2468+
if (!gpiochip_line_is_valid(guard.gc, offset)) {
2469+
ret = -EINVAL;
2470+
goto out_clear_bit;
2471+
}
24702472

24712473
/* NOTE: gpio_request() can be called in early boot,
24722474
* before IRQs are enabled, for non-sleeping (SOC) GPIOs.

0 commit comments

Comments
 (0)