[PATCH v2 2/2] Input: st-keyscan: Improve probe error handling

From: phucduc . bui

Date: Mon Jul 20 2026 - 05:16:26 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Use dev_err_probe() for devm_clk_get() so deferred probe errors are
handled correctly.
Drop the redundant error message after devm_request_irq(), since the
helper already reports request failures internally.
Return the original error from platform_get_irq() instead of replacing
it with -EINVAL.

Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---

Changes in v2 :
-Return the original error from platform_get_irq() instead of replacing
it with -EINVAL.

drivers/input/keyboard/st-keyscan.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c
index e53ef4c670e4..8e9bac339dc4 100644
--- a/drivers/input/keyboard/st-keyscan.c
+++ b/drivers/input/keyboard/st-keyscan.c
@@ -173,10 +173,9 @@ static int keyscan_probe(struct platform_device *pdev)
return PTR_ERR(keypad_data->base);

keypad_data->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(keypad_data->clk)) {
- dev_err(&pdev->dev, "cannot get clock\n");
- return PTR_ERR(keypad_data->clk);
- }
+ if (IS_ERR(keypad_data->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(keypad_data->clk),
+ "cannot get clock\n");

error = clk_enable(keypad_data->clk);
if (error) {
@@ -188,14 +187,12 @@ static int keyscan_probe(struct platform_device *pdev)

keypad_data->irq = platform_get_irq(pdev, 0);
if (keypad_data->irq < 0)
- return -EINVAL;
+ return keypad_data->irq;

error = devm_request_irq(&pdev->dev, keypad_data->irq, keyscan_isr, 0,
pdev->name, keypad_data);
- if (error) {
- dev_err(&pdev->dev, "failed to request IRQ\n");
+ if (error)
return error;
- }

error = input_register_device(input_dev);
if (error) {
--
2.43.0