From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Anshul Garg <aksgarg1989@gmail.com>
Cc: linux-input@vger.kernel.org, anshul.g@samsung.com
Subject: Re: [PATCH v2] Input :Optimize input_dev_release_keys function
Date: Mon, 29 Jun 2015 12:46:31 -0700 [thread overview]
Message-ID: <20150629194631.GF22166@dtor-ws> (raw)
In-Reply-To: <1435254817-41989-1-git-send-email-aksgarg1989@gmail.com>
On Thu, Jun 25, 2015 at 10:53:37AM -0700, Anshul Garg wrote:
> From: Anshul Garg <aksgarg1989@gmail.com>
>
> input_dev_release_keys : Use for_each_set_bit instead
> of testing every bit upto KEY_MAX as it is more clean
> and more optimized.
>
> input_estimate_events_per_packet : Use bitmap_weight
> to get set bits count for EV_REL type instead of using
> loop and also use for_each_set_bit for EV_ABS event for
> more optimized code.
>
> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
> ---
> drivers/input/input.c | 28 ++++++++++------------------
> 1 file changed, 10 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index e0b7b8e..9459f8b 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -682,12 +682,9 @@ static void input_dev_release_keys(struct input_dev *dev)
> int code;
>
> if (is_event_supported(EV_KEY, dev->evbit, EV_MAX)) {
> - for (code = 0; code <= KEY_MAX; code++) {
> - if (is_event_supported(code, dev->keybit, KEY_MAX) &&
> - __test_and_clear_bit(code, dev->key)) {
> - input_pass_event(dev, EV_KEY, code, 0);
> - }
> - }
> + for_each_set_bit(code, dev->keybit, KEY_MAX)
That should have been KEY_CNT (as KEY_MAX is a valid keycode and you do
not want to skip it), I fixed it up locally and applied.
Thanks.
> + input_pass_event(dev, EV_KEY, code, 0);
> + memset(dev->key, 0, sizeof(dev->key));
> input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
> }
> }
> @@ -1986,21 +1983,16 @@ static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
> events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
>
> if (test_bit(EV_ABS, dev->evbit)) {
> - for (i = 0; i < ABS_CNT; i++) {
> - if (test_bit(i, dev->absbit)) {
> - if (input_is_mt_axis(i))
> - events += mt_slots;
> - else
> - events++;
> - }
> + for_each_set_bit(i, dev->absbit, ABS_CNT) {
> + if (input_is_mt_axis(i))
> + events += mt_slots;
> + else
> + events++;
> }
> }
>
> - if (test_bit(EV_REL, dev->evbit)) {
> - for (i = 0; i < REL_CNT; i++)
> - if (test_bit(i, dev->relbit))
> - events++;
> - }
> + if (test_bit(EV_REL, dev->evbit))
> + events += bitmap_weight(dev->relbit, REL_CNT);
>
> /* Make room for KEY and MSC events */
> events += 7;
> --
> 1.7.9.5
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
--
Dmitry
prev parent reply other threads:[~2015-06-29 19:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 17:53 [PATCH v2] Input :Optimize input_dev_release_keys function Anshul Garg
2015-06-29 19:46 ` Dmitry Torokhov [this message]
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=20150629194631.GF22166@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=aksgarg1989@gmail.com \
--cc=anshul.g@samsung.com \
--cc=linux-input@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