[PATCH] Input: gpio-keys - Detect long press events in sleep mode

Hua Li posted 1 patch 7 months, 2 weeks ago
drivers/input/keyboard/gpio_keys.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] Input: gpio-keys - Detect long press events in sleep mode
Posted by Hua Li 7 months, 2 weeks ago
Previously, long pressing the gpio key could only detect short press
events and could not report long press events in sleep mode, we need
to recognize long press events in sleep mode and fix this issue.

Signed-off-by: Hua Li <lihua@huaqin.corp-partner.google.com>
---
 drivers/input/keyboard/gpio_keys.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 5c39a217b94c..b546f38ecf8f 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -426,6 +426,8 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
 			 * handler to run.
 			 */
 			input_report_key(bdata->input, button->code, 1);
+			input_sync(bdata->input);
+			return IRQ_HANDLED;
 		}
 	}
 
-- 
2.17.1
Re: [PATCH] Input: gpio-keys - Detect long press events in sleep mode
Posted by lihua - 7 months, 1 week ago
Hello, All linux team members:
      Could you please review this modification as soon as possible?


On Tue, May 6, 2025 at 1:58 PM Hua Li
<lihua@huaqin.corp-partner.google.com> wrote:
>
> Previously, long pressing the gpio key could only detect short press
> events and could not report long press events in sleep mode, we need
> to recognize long press events in sleep mode and fix this issue.
>
> Signed-off-by: Hua Li <lihua@huaqin.corp-partner.google.com>
> ---
>  drivers/input/keyboard/gpio_keys.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 5c39a217b94c..b546f38ecf8f 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -426,6 +426,8 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
>                          * handler to run.
>                          */
>                         input_report_key(bdata->input, button->code, 1);
> +                       input_sync(bdata->input);
> +                       return IRQ_HANDLED;
>                 }
>         }
>
> --
> 2.17.1
>
Re: [PATCH] Input: gpio-keys - Detect long press events in sleep mode
Posted by Andy Shevchenko 7 months, 1 week ago
On Mon, May 12, 2025 at 03:57:17PM +0800, lihua - wrote:

First of all, do not top-post!

> Hello, All linux team members:
>       Could you please review this modification as soon as possible?

You even haven't waited for a full week...

If it's an (important) fix, made it look so (Fixes: tag, Cc: stable@, etc).

> On Tue, May 6, 2025 at 1:58 PM Hua Li
> <lihua@huaqin.corp-partner.google.com> wrote:
> >
> > Previously, long pressing the gpio key could only detect short press
> > events and could not report long press events in sleep mode, we need
> > to recognize long press events in sleep mode and fix this issue.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] Input: gpio-keys - Detect long press events in sleep mode
Posted by Dmitry Torokhov 7 months ago
On Mon, May 12, 2025 at 11:50:15AM +0300, Andy Shevchenko wrote:
> On Mon, May 12, 2025 at 03:57:17PM +0800, lihua - wrote:
> 
> First of all, do not top-post!
> 
> > Hello, All linux team members:
> >       Could you please review this modification as soon as possible?
> 
> You even haven't waited for a full week...
> 
> If it's an (important) fix, made it look so (Fixes: tag, Cc: stable@, etc).

I can see that missing input_sync() might hurt, but the patch
description makes no sense. The driver does not really differentiate
between long and sort press.

Please provide a better explanation how missing sync interferes with
your use case.

Thanks.

-- 
Dmitry
Re: [PATCH] Input: gpio-keys - Detect long press events in sleep mode
Posted by Dmitry Torokhov 7 months ago
On Thu, May 15, 2025 at 11:57:58AM -0700, Dmitry Torokhov wrote:
> On Mon, May 12, 2025 at 11:50:15AM +0300, Andy Shevchenko wrote:
> > On Mon, May 12, 2025 at 03:57:17PM +0800, lihua - wrote:
> > 
> > First of all, do not top-post!
> > 
> > > Hello, All linux team members:
> > >       Could you please review this modification as soon as possible?
> > 
> > You even haven't waited for a full week...
> > 
> > If it's an (important) fix, made it look so (Fixes: tag, Cc: stable@, etc).
> 
> I can see that missing input_sync() might hurt, but the patch
> description makes no sense. The driver does not really differentiate
> between long and sort press.
> 
> Please provide a better explanation how missing sync interferes with
> your use case.

Also simply returning from the interrupt handler is wrong: what happens
if you simulate the key press, but the button is indeed released by the
time the handler runs? What will generate the release? The button will
appear "stuck".

Thanks.

-- 
Dmitry