* [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value
@ 2026-07-23 2:29 kr494167
2026-07-25 1:02 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: kr494167 @ 2026-07-23 2:29 UTC (permalink / raw)
To: hvilleneuve, dmitry.torokhov
Cc: andriy.shevchenko, linux-input, linux-kernel,
Surendra Singh Chouhan
From: Surendra Singh Chouhan <kr494167@gmail.com>
charlieplex_keypad_scan_line() currently ignores the return value of
gpiod_direction_output() when setting the active output line for scanning.
If setting the GPIO direction fails (e.g. on I2C/SPI GPIO expanders or
hardware errors), the function continues to sleep and read input values
from an improperly configured GPIO line.
Fix this by capturing the return value of gpiod_direction_output() and
returning the error code immediately if it fails.
Fixes: 2ca45e57ea02 ("Input: charlieplex_keypad - add GPIO charlieplex keypad")
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
---
drivers/input/keyboard/charlieplex_keypad.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/charlieplex_keypad.c b/drivers/input/keyboard/charlieplex_keypad.c
index d222b622c820..d46a2298e6da 100644
--- a/drivers/input/keyboard/charlieplex_keypad.c
+++ b/drivers/input/keyboard/charlieplex_keypad.c
@@ -77,7 +77,9 @@ static int charlieplex_keypad_scan_line(struct charlieplex_keypad *keypad,
int err;
/* Activate only one line as output at a time. */
- gpiod_direction_output(line_gpios->desc[oline], 1);
+ err = gpiod_direction_output(line_gpios->desc[oline], 1);
+ if (err)
+ return err;
if (keypad->settling_time_us)
fsleep(keypad->settling_time_us);
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value
2026-07-23 2:29 [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value kr494167
@ 2026-07-25 1:02 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-07-25 1:02 UTC (permalink / raw)
To: kr494167; +Cc: hvilleneuve, andriy.shevchenko, linux-input, linux-kernel
On Thu, Jul 23, 2026 at 07:59:43AM +0530, kr494167@gmail.com wrote:
> From: Surendra Singh Chouhan <kr494167@gmail.com>
>
> charlieplex_keypad_scan_line() currently ignores the return value of
> gpiod_direction_output() when setting the active output line for scanning.
>
> If setting the GPIO direction fails (e.g. on I2C/SPI GPIO expanders or
> hardware errors), the function continues to sleep and read input values
> from an improperly configured GPIO line.
>
> Fix this by capturing the return value of gpiod_direction_output() and
> returning the error code immediately if it fails.
>
> Fixes: 2ca45e57ea02 ("Input: charlieplex_keypad - add GPIO charlieplex keypad")
> Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-25 1:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 2:29 [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value kr494167
2026-07-25 1:02 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox