All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org,
	Arthur Demchenkov <spinal.by@gmail.com>,
	Carl Philipp Klemm <philipp@uvos.xyz>,
	Merlijn Wajer <merlijn@wizzup.org>, Pavel Machek <pavel@ucw.cz>,
	ruleh <ruleh@gmx.de>, Sebastian Reichel <sre@kernel.org>
Subject: Re: [PATCH 3/5] Input: omap4-keypad - move rest of key scanning to a separate function
Date: Mon, 11 Jan 2021 07:57:39 +0200	[thread overview]
Message-ID: <X/vo03Hd0sJFou3h@atomide.com> (raw)
In-Reply-To: <X/vZJMAOJc/CzmHH@google.com>

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [210111 04:50]:
> On Sun, Jan 10, 2021 at 09:05:27PM +0200, Tony Lindgren wrote:
> > Let's move rest of the key scanning code to omap4_keypad_scan_keys().
> > We will use omap4_keypad_scan_keys() also for implementing errata
> > handling to clear the stuck last key in the following patch.
> 
> And this one will become then...

Yes great, this works for me.

Thanks,

Tony


> 
> Input: omap4-keypad - move rest of key scanning to a separate function
> 
> From: Tony Lindgren <tony@atomide.com>
> 
> Let's move rest of the key scanning code to omap4_keypad_scan_keys().
> We will use omap4_keypad_scan_keys() also for implementing errata
> handling to clear the stuck last key in the following patch.
> 
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/keyboard/omap4-keypad.c |   39 ++++++++++++++++++++++-----------
>  1 file changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
> index 6dcf27af856d..c48705dd049b 100644
> --- a/drivers/input/keyboard/omap4-keypad.c
> +++ b/drivers/input/keyboard/omap4-keypad.c
> @@ -71,6 +71,7 @@ struct omap4_keypad {
>  
>  	void __iomem *base;
>  	unsigned int irq;
> +	struct mutex lock;		/* for key scan */
>  
>  	unsigned int rows;
>  	unsigned int cols;
> @@ -135,6 +136,28 @@ static int omap4_keypad_report_keys(struct omap4_keypad *keypad_data,
>  	return events;
>  }
>  
> +static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys)
> +{
> +	u64 changed;
> +
> +	mutex_lock(&keypad_data->lock);
> +
> +	changed = keys ^ keypad_data->keys;
> +
> +	/*
> +	 * Report key up events separately and first. This matters in case we
> +	 * lost key-up interrupt and just now catching up.
> +	 */
> +	omap4_keypad_report_keys(keypad_data, changed & ~keys, false);
> +
> +	/* Report key down events */
> +	omap4_keypad_report_keys(keypad_data, changed & keys, true);
> +
> +	keypad_data->keys = keys;
> +
> +	mutex_unlock(&keypad_data->lock);
> +}
> +
>  /* Interrupt handlers */
>  static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id)
>  {
> @@ -150,24 +173,13 @@ static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
>  {
>  	struct omap4_keypad *keypad_data = dev_id;
>  	u32 low, high;
> -	u64 keys, changed;
> +	u64 keys;
>  
>  	low = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
>  	high = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
>  	keys = low | (u64)high << 32;
>  
> -	changed = keys ^ keypad_data->keys;
> -
> -	/*
> -	 * Report key up events separately and first. This matters in case we
> -	 * lost key-up interrupt and just now catching up.
> -	 */
> -	omap4_keypad_report_keys(keypad_data, changed & ~keys, false);
> -
> -	/* Report key down events */
> -	omap4_keypad_report_keys(keypad_data, changed & keys, true);
> -
> -	keypad_data->keys = keys;
> +	omap4_keypad_scan_keys(keypad_data, keys);
>  
>  	/* clear pending interrupts */
>  	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
> @@ -300,6 +312,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
>  	}
>  
>  	keypad_data->irq = irq;
> +	mutex_init(&keypad_data->lock);
>  
>  	error = omap4_keypad_parse_dt(dev, keypad_data);
>  	if (error)

  reply	other threads:[~2021-01-11  5:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-10 19:05 [PATCHv5 0/5] Lost key-up interrupt handling for omap4-keypad Tony Lindgren
2021-01-10 19:05 ` [PATCH 1/5] Input: omap4-keypad - disable unused long interrupts Tony Lindgren
2021-01-11  6:25   ` Dmitry Torokhov
2021-01-10 19:05 ` [PATCH 2/5] Input: omap4-keypad - scan keys in two phases and simplify with bitmask Tony Lindgren
2021-01-11  4:48   ` Dmitry Torokhov
2021-01-11  5:56     ` Tony Lindgren
2021-01-11  6:26       ` Dmitry Torokhov
2021-01-10 19:05 ` [PATCH 3/5] Input: omap4-keypad - move rest of key scanning to a separate function Tony Lindgren
2021-01-11  4:50   ` Dmitry Torokhov
2021-01-11  5:57     ` Tony Lindgren [this message]
2021-01-11  6:27       ` Dmitry Torokhov
2021-01-10 19:05 ` [PATCH 4/5] Input: omap4-keypad - use PM runtime autosuspend Tony Lindgren
2021-01-11  5:01   ` Dmitry Torokhov
2021-01-11  5:12     ` Tony Lindgren
2021-01-11  6:02       ` Tony Lindgren
2021-01-11  6:27         ` Dmitry Torokhov
2021-01-10 19:05 ` [PATCH 5/5] Input: omap4-keypad - implement errata check for lost key-up events Tony Lindgren
2021-01-11  6:10   ` Tony Lindgren
2021-01-11  6:28     ` Dmitry Torokhov
2021-01-11  8:33   ` Pavel Machek
2021-01-11  9:02     ` Tony Lindgren

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=X/vo03Hd0sJFou3h@atomide.com \
    --to=tony@atomide.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=pavel@ucw.cz \
    --cc=philipp@uvos.xyz \
    --cc=ruleh@gmx.de \
    --cc=spinal.by@gmail.com \
    --cc=sre@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.