From: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Akinobu Mita <akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 4/5] Input: mpr121 - handle multiple bits change of status register
Date: Sun, 15 Jan 2017 15:05:30 -0800 [thread overview]
Message-ID: <20170115230530.GA23285@dtor-ws> (raw)
In-Reply-To: <1484486144-27947-5-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Sun, Jan 15, 2017 at 10:15:43PM +0900, Akinobu Mita wrote:
> This driver reports input events on their interrupts which are triggered
> by the sensor's status register changes. But only single bit change is
> reported in the interrupt handler. So if there are multiple bits are
> changed at almost the same time, other press or release events are ignored.
>
> This fixes it by detecting all changed bits in the status register.
>
> Cc: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Akinobu Mita <akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> * Use for_each_set_bit() to search changed bit
>
> drivers/input/keyboard/mpr121_touchkey.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c
> index 2558c60..a0210ae 100644
> --- a/drivers/input/keyboard/mpr121_touchkey.c
> +++ b/drivers/input/keyboard/mpr121_touchkey.c
> @@ -86,7 +86,8 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id)
> struct mpr121_touchkey *mpr121 = dev_id;
> struct i2c_client *client = mpr121->client;
> struct input_dev *input = mpr121->input_dev;
> - unsigned int key_num, key_val, pressed;
> + unsigned long bit_changed;
> + unsigned int key_num;
> int reg;
>
> reg = i2c_smbus_read_byte_data(client, ELE_TOUCH_STATUS_1_ADDR);
> @@ -104,18 +105,22 @@ static irqreturn_t mpr_touchkey_interrupt(int irq, void *dev_id)
>
> reg &= TOUCH_STATUS_MASK;
> /* use old press bit to figure out which bit changed */
> - key_num = ffs(reg ^ mpr121->statusbits) - 1;
> - pressed = reg & (1 << key_num);
> + bit_changed = reg ^ mpr121->statusbits;
> mpr121->statusbits = reg;
> + for_each_set_bit(key_num, &bit_changed, mpr121->keycount) {
> + unsigned int key_val, pressed;
>
> - key_val = mpr121->keycodes[key_num];
> + pressed = reg & (1 << key_num);
Changed to
pressed = reg & BIT(key_num);
and applied, thank you.
> + key_val = mpr121->keycodes[key_num];
>
> - input_event(input, EV_MSC, MSC_SCAN, key_num);
> - input_report_key(input, key_val, pressed);
> - input_sync(input);
> + input_event(input, EV_MSC, MSC_SCAN, key_num);
> + input_report_key(input, key_val, pressed);
> +
> + dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val,
> + pressed ? "pressed" : "released");
>
> - dev_dbg(&client->dev, "key %d %d %s\n", key_num, key_val,
> - pressed ? "pressed" : "released");
> + }
> + input_sync(input);
>
> out:
> return IRQ_HANDLED;
> --
> 2.7.4
>
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-01-15 23:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 13:15 [PATCH v2 0/5] nput: mpr121 - switch to use device tree probe Akinobu Mita
[not found] ` <1484486144-27947-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-15 13:15 ` [PATCH v2 1/5] Input: mpr121 - annotate PM methods as __maybe_unused Akinobu Mita
2017-01-15 13:15 ` [PATCH v2 2/5] Input: mpr121 - remove unused field in struct mpr121_touchkey Akinobu Mita
2017-01-15 13:15 ` [PATCH v2 3/5] Input: mpr121 - set missing event capability Akinobu Mita
2017-01-15 13:15 ` [PATCH v2 4/5] Input: mpr121 - handle multiple bits change of status register Akinobu Mita
[not found] ` <1484486144-27947-5-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-15 23:05 ` Dmitry Torokhov [this message]
2017-01-15 13:15 ` [PATCH v2 5/5] Input: mpr121 - switch to device tree probe Akinobu Mita
[not found] ` <1484486144-27947-6-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-15 23:06 ` Dmitry Torokhov
2017-01-15 23:07 ` [PATCH v2 0/5] nput: mpr121 - switch to use " Dmitry Torokhov
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=20170115230530.GA23285@dtor-ws \
--to=dmitry.torokhov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).