From: "Baek Kyu, Kim" <pocj8ur4in@gmail.com>
To: linusw@kernel.org, brgl@kernel.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
pocj8ur4in@gmail.com
Subject: [PATCH] gpiolib: Propagate emulated drive errors when setting arrays
Date: Wed, 21 Oct 2026 02:26:01 +0900 [thread overview]
Message-ID: <20261020172601.221861-1-pocj8ur4in@gmail.com> (raw)
gpiod_set_array_value_complex() ignores errors from the open-drain and
open-source emulation helpers. If a direction change fails,
GPIO_V2_LINE_SET_VALUES_IOCTL still reports success, including when
updating a single line.
Return the first emulation error after freeing the temporary bitmaps.
Keep updates already made to earlier lines and stop processing the
remaining lines, as for errors from gpiochip_set_multiple().
Fixes: 8ce258f62f90 ("gpiolib: make value setters have return values")
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com>
---
Tested under ARM64 QEMU through GPIO v2 ioctls and libgpiod with a test
GPIO provider. After a successful line request, an emulated direction
change failure is reported as success before the fix and as an error with
the fix. Tests cover single-line writes, both emulated drive modes,
active-low, mixed arrays, retries and partial updates. No physical GPIO
controller was tested.
drivers/gpio/gpiolib.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1438f97d0634..9decee5a95c7 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3945,9 +3945,13 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
* open drain and open source outputs are set individually
*/
if (test_bit(GPIOD_FLAG_OPEN_DRAIN, &desc->flags) && !raw) {
- gpio_set_open_drain_value_commit(desc, value);
+ ret = gpio_set_open_drain_value_commit(desc, value);
+ if (ret)
+ goto cleanup_bitmap;
} else if (test_bit(GPIOD_FLAG_OPEN_SOURCE, &desc->flags) && !raw) {
- gpio_set_open_source_value_commit(desc, value);
+ ret = gpio_set_open_source_value_commit(desc, value);
+ if (ret)
+ goto cleanup_bitmap;
} else {
__set_bit(hwgpio, mask);
__assign_bit(hwgpio, bits, value);
base-commit: a0fe269293509acdd93b9cfb3f46636f7b91b33a
--
2.55.0
reply other threads:[~2026-10-20 17:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020172601.221861-1-pocj8ur4in@gmail.com \
--to=pocj8ur4in@gmail.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®