diff mbox series

[libgpiod,2/7] tests: gpiosim: don't allow clearing hogs on active devices

Message ID 20251006-gpiosim-valid-lines-v1-2-b399373e90a9@linaro.org
State New
Headers show
Series None | expand

Commit Message

Bartosz Golaszewski Oct. 6, 2025, 11:27 a.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Check if the GPIO device is pending in gpiosim_bank_clear_hog() before
actually trying to remove the hog directory.

Fixes: a2f6e8cd3540 ("libgpiosim: new library for controlling the gpio-sim module")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 tests/gpiosim/gpiosim.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/tests/gpiosim/gpiosim.c b/tests/gpiosim/gpiosim.c
index 81bfd574817a1259f6b30dab52051a907414fd83..d48257534b887c8e9694afce80894a895379e1f1 100644
--- a/tests/gpiosim/gpiosim.c
+++ b/tests/gpiosim/gpiosim.c
@@ -1116,6 +1116,9 @@  GPIOSIM_API int gpiosim_bank_clear_hog(struct gpiosim_bank *bank,
 				       unsigned int offset)
 {
 	char buf[64];
+	
+	if (!dev_check_pending(bank->dev))
+		return -1;
 
 	snprintf(buf, sizeof(buf), "line%u/hog", offset);