From: kr494167@gmail.com
To: hvilleneuve@dimonoff.com, dmitry.torokhov@gmail.com
Cc: andriy.shevchenko@intel.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org,
Surendra Singh Chouhan <kr494167@gmail.com>
Subject: [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value
Date: Thu, 23 Jul 2026 07:59:43 +0530 [thread overview]
Message-ID: <20260723022943.9337-1-kr494167@gmail.com> (raw)
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
next reply other threads:[~2026-07-23 2:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 2:29 kr494167 [this message]
2026-07-23 2:38 ` [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value sashiko-bot
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=20260723022943.9337-1-kr494167@gmail.com \
--to=kr494167@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=dmitry.torokhov@gmail.com \
--cc=hvilleneuve@dimonoff.com \
--cc=linux-input@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