Commit 6df6ea4b authored by Barnabás Pőcze's avatar Barnabás Pőcze Committed by Bartosz Golaszewski
Browse files

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: a5016248 ("gpio: Respect valid_mask when requesting GPIOs")
Signed-off-by: default avatarBarnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/20260310204359.1202451-1-pobrn@protonmail.com


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
parent 189645ba
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2465,8 +2465,10 @@ int gpiod_request_commit(struct gpio_desc *desc, const char *label)
		return -EBUSY;

	offset = gpiod_hwgpio(desc);
	if (!gpiochip_line_is_valid(guard.gc, offset))
		return -EINVAL;
	if (!gpiochip_line_is_valid(guard.gc, offset)) {
		ret = -EINVAL;
		goto out_clear_bit;
	}

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