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] Input : Optimize joydev_connect function
Date: Tue, 10 Mar 2015 18:44:04 -0700 [thread overview]
Message-ID: <20150311014404.GB22959@dtor-ws> (raw)
In-Reply-To: <1426012577-921-1-git-send-email-aksgarg1989@gmail.com>
Hi Anshul,
On Tue, Mar 10, 2015 at 11:36:17AM -0700, Anshul Garg wrote:
> From: Anshul Garg <aksgarg1989@gmail.com>
>
> In joydev_connect function added check for event type before
> setting properties for that event. This will avoid dummy
> loop iterations which checks for event code even if event type
> is not set.
I do not think you'll find a device that would fit joydev's matching
rules that would benefit from this.
>
> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
> ---
> drivers/input/joydev.c | 44 ++++++++++++++++++++++++--------------------
> 1 file changed, 24 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
> index f362883..a37a26c 100644
> --- a/drivers/input/joydev.c
> +++ b/drivers/input/joydev.c
> @@ -797,27 +797,31 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
> joydev->handle.name = dev_name(&joydev->dev);
> joydev->handle.handler = handler;
> joydev->handle.private = joydev;
> +
> + if (test_bit(EV_ABS, dev->evbit)) {
> + 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 (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 (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
> - if (test_bit(i + BTN_MISC, dev->keybit)) {
> - joydev->keymap[i] = joydev->nkey;
> - joydev->keypam[joydev->nkey] = i + BTN_MISC;
> - joydev->nkey++;
> - }
> -
> - for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
> - if (test_bit(i + BTN_MISC, dev->keybit)) {
> - joydev->keymap[i] = joydev->nkey;
> - joydev->keypam[joydev->nkey] = i + BTN_MISC;
> - joydev->nkey++;
> - }
> + if (test_bit(EV_KEY, dev->evbit)) {
> + for (i = BTN_JOYSTICK - BTN_MISC; i < KEY_MAX - BTN_MISC + 1; i++)
> + if (test_bit(i + BTN_MISC, dev->keybit)) {
> + joydev->keymap[i] = joydev->nkey;
> + joydev->keypam[joydev->nkey] = i + BTN_MISC;
> + joydev->nkey++;
> + }
> +
> + for (i = 0; i < BTN_JOYSTICK - BTN_MISC; i++)
> + if (test_bit(i + BTN_MISC, dev->keybit)) {
> + joydev->keymap[i] = joydev->nkey;
> + joydev->keypam[joydev->nkey] = i + BTN_MISC;
> + joydev->nkey++;
> + }
> + }
>
> for (i = 0; i < joydev->nabs; i++) {
> j = joydev->abspam[i];
> --
> 1.7.9.5
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> http://www.avast.com
>
--
Dmitry
prev parent reply other threads:[~2015-03-11 1:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-10 18:36 [PATCH] Input : Optimize joydev_connect function Anshul Garg
2015-03-11 1:44 ` 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=20150311014404.GB22959@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