From: Anshul Garg <aksgarg1989@gmail.com>
To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Cc: aksgarg1989@gmail.com
Subject: [PATCH] Input: Use for_each_set_bit where appropriate
Date: Wed, 8 Jul 2015 11:08:49 -0700 [thread overview]
Message-ID: <1436378929-65748-1-git-send-email-aksgarg1989@gmail.com> (raw)
In-Reply-To: <aksgarg1989@gmail.com>
Use for_each_set_bit to check for set bits in bitmap
as it is more efficient than checking individual bits.
Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
drivers/input/ff-core.c | 5 ++---
drivers/input/joydev.c | 11 +++++------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c
index 8f4a30fc..c642082 100644
--- a/drivers/input/ff-core.c
+++ b/drivers/input/ff-core.c
@@ -343,9 +343,8 @@ int input_ff_create(struct input_dev *dev, unsigned int max_effects)
__set_bit(EV_FF, dev->evbit);
/* Copy "true" bits into ff device bitmap */
- for (i = 0; i <= FF_MAX; i++)
- if (test_bit(i, dev->ffbit))
- __set_bit(i, ff->ffbit);
+ for_each_set_bit(i, dev->ffbit, FF_CNT)
+ __set_bit(i, ff->ffbit);
/* we can emulate RUMBLE with periodic effects */
if (test_bit(FF_PERIODIC, ff->ffbit))
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index f362883..4686260 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -798,12 +798,11 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
joydev->handle.handler = handler;
joydev->handle.private = joydev;
- for (i = 0; i < ABS_CNT; i++)
- if (test_bit(i, dev->absbit)) {
- joydev->absmap[i] = joydev->nabs;
- joydev->abspam[joydev->nabs] = i;
- joydev->nabs++;
- }
+ for_each_set_bit(i, dev->absbit, ABS_CNT) {
+ joydev->absmap[i] = joydev->nabs;
+ joydev->abspam[joydev->nabs] = i;
+ joydev->nabs++;
+ }
for (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
if (test_bit(i + BTN_MISC, dev->keybit)) {
--
1.7.9.5
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
next reply other threads:[~2015-07-08 18:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 18:08 Anshul Garg [this message]
2015-09-17 20:02 ` [PATCH] Input: Use for_each_set_bit where appropriate Stephen Chandler Paul
2015-09-19 18:26 ` Dmitry Torokhov
2015-09-21 14:30 ` Stephen Chandler Paul
2015-09-21 22:58 ` Dmitry Torokhov
-- strict thread matches above, loose matches on Subject: below --
2015-07-09 13:41 Anshul Garg
2015-07-09 17:26 ` Dmitry Torokhov
2015-07-09 17:35 ` Anshul Garg
2015-07-09 18:14 ` Dmitry Torokhov
2015-07-09 18:17 ` Anshul Garg
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=1436378929-65748-1-git-send-email-aksgarg1989@gmail.com \
--to=aksgarg1989@gmail.com \
--cc=dmitry.torokhov@gmail.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;
as well as URLs for NNTP newsgroup(s).