* [PATCH] Input:Avoid extra comparision in report_event api
@ 2015-01-29 18:56 Mukesh Sharma
2015-01-29 19:04 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Mukesh Sharma @ 2015-01-29 18:56 UTC (permalink / raw)
To: dmitry.torokhov, dtor, linux-input; +Cc: aksgarg1989, mukesh.sharma091
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input:Avoid extra comparision in report_event api
2015-01-29 18:56 [PATCH] Input:Avoid extra comparision in report_event api Mukesh Sharma
@ 2015-01-29 19:04 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2015-01-29 19:04 UTC (permalink / raw)
To: Mukesh Sharma; +Cc: linux-input, aksgarg1989
On Thu, Jan 29, 2015 at 10:56:38AM -0800, Mukesh Sharma wrote:
> 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>
Did you try building this change?
CC [M] drivers/input/keyboard/gpio_keys.o
drivers/input/keyboard/gpio_keys.c: In function ‘gpio_keys_setup_key’:
drivers/input/keyboard/gpio_keys.c:509:2: error: assignment of member
‘type’ in read-only object
button->type = button->type ?: EV_KEY;
^
make[1]: *** [drivers/input/keyboard/gpio_keys.o] Error 1
make: *** [drivers/input/keyboard/gpio_keys.o] Error 2
Thanks.
> ---
> 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
>
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-29 19:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-29 18:56 [PATCH] Input:Avoid extra comparision in report_event api Mukesh Sharma
2015-01-29 19:04 ` Dmitry Torokhov
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).