linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mukesh Sharma <mukesh.sharma091@gmail.com>
To: dmitry.torokhov@gmail.com, dtor@mail.ru, linux-input@vger.kernel.org
Cc: aksgarg1989@gmail.com, mukesh.sharma091@gmail.com
Subject: [PATCH] Input:Avoid extra comparision in report_event api
Date: Thu, 29 Jan 2015 10:56:38 -0800	[thread overview]
Message-ID: <1422557798-106138-1-git-send-email-mukesh.sharma091@gmail.com> (raw)
In-Reply-To: <mukesh.sharma091@gmail.com>

From: Mukesh Sharma <mukesh.sharma091@gmail.com>

Set button->type to EV_KEY if no type is defined by platform or device
tree structure hence we can remove the extra comparision operation from
gpio_keys_gpio_report_event.

Signed-off-by: Mukesh Sharma <mukesh.sharma091@gmail.com>
---
 drivers/input/keyboard/gpio_keys.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 883d6ae..9256ff9 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -335,14 +335,13 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
 {
 	const struct gpio_keys_button *button = bdata->button;
 	struct input_dev *input = bdata->input;
-	unsigned int type = button->type ?: EV_KEY;
 	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
 
-	if (type == EV_ABS) {
+	if (button->type == EV_ABS) {
 		if (state)
-			input_event(input, type, button->code, button->value);
+			input_event(input, button->type, button->code, button->value);
 	} else {
-		input_event(input, type, button->code, !!state);
+		input_event(input, button->type, button->code, !!state);
 	}
 	input_sync(input);
 }
@@ -507,8 +506,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 		isr = gpio_keys_irq_isr;
 		irqflags = 0;
 	}
-
-	input_set_capability(input, button->type ?: EV_KEY, button->code);
+	button->type = button->type ?: EV_KEY;
+	input_set_capability(input, button->type, button->code);
 
 	/*
 	 * Install custom action to cancel release timer and
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


             reply	other threads:[~2015-01-29 18:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 18:56 Mukesh Sharma [this message]
2015-01-29 19:04 ` [PATCH] Input:Avoid extra comparision in report_event api 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=1422557798-106138-1-git-send-email-mukesh.sharma091@gmail.com \
    --to=mukesh.sharma091@gmail.com \
    --cc=aksgarg1989@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dtor@mail.ru \
    --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).