From: andrew.liu200917@gmail.com
To: michael.hennerich@analog.com, dmitry.torokhov@gmail.com,
device-drivers-devel@blackfin.uclinux.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org,
Andrew Liu <andrew.liu200917@gmail.com>
Subject: [PATCH] input:keyboard: "keycode & KEY_MAX" changes some keycode value.
Date: Sat, 23 Nov 2013 21:45:45 +0800 [thread overview]
Message-ID: <1385214345-10385-1-git-send-email-andrew.liu200917@gmail.com> (raw)
From: Andrew Liu <andrew.liu200917@gmail.com>
For exmaple, keycode: KEY_OK(0x160) is changed by "and" operation with
KEY_MAX(0x2ff) to KEY_KPENTER(96).
Signed-off-by: Andrew Liu <andrew.liu200917@gmail.com>
---
drivers/input/keyboard/adp5588-keys.c | 8 ++++++--
drivers/input/keyboard/adp5589-keys.c | 8 ++++++--
drivers/input/keyboard/bf54x-keys.c | 8 ++++++--
drivers/input/misc/pcf8574_keypad.c | 6 +++++-
drivers/media/pci/ttpci/av7110_ir.c | 1 +
5 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index dbd2047..1ce559e 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -535,8 +535,12 @@ static int adp5588_probe(struct i2c_client *client,
if (pdata->repeat)
__set_bit(EV_REP, input->evbit);
- for (i = 0; i < input->keycodemax; i++)
- __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit);
+ for (i = 0; i < input->keycodemax; i++) {
+ if (kpad->keycode[i] > KEY_MAX)
+ kpad->keycode[i] = 0;
+ else if (kpad->keycode[i] > KEY_RESERVED)
+ __set_bit(kpad->keycode[i], input->keybit);
+ }
__clear_bit(KEY_RESERVED, input->keybit);
if (kpad->gpimapsize)
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index 67d12b3..22ca2a5 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -991,8 +991,12 @@ static int adp5589_probe(struct i2c_client *client,
if (pdata->repeat)
__set_bit(EV_REP, input->evbit);
- for (i = 0; i < input->keycodemax; i++)
- __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit);
+ for (i = 0; i < input->keycodemax; i++) {
+ if (kpad->keycode[i] > KEY_MAX)
+ kpad->keycode[i] = 0;
+ else if (kpad->keycode[i] > KEY_RESERVED)
+ __set_bit(kpad->keycode[i], input->keybit);
+ }
__clear_bit(KEY_RESERVED, input->keybit);
if (kpad->gpimapsize)
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index fc88fb4..96f54e7 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -288,8 +288,12 @@ static int bfin_kpad_probe(struct platform_device *pdev)
if (pdata->repeat)
__set_bit(EV_REP, input->evbit);
- for (i = 0; i < input->keycodemax; i++)
- __set_bit(bf54x_kpad->keycode[i] & KEY_MAX, input->keybit);
+ for (i = 0; i < input->keycodemax; i++) {
+ if (bf54x_kpad->keycode[i] > KEY_MAX)
+ bf54x_kpad->keycode[i] = 0;
+ else if (bf54x_kpad->keycode[i] > KEY_RESERVED)
+ __set_bit(bf54x_kpad->keycode[i], input->keybit);
+ }
__clear_bit(KEY_RESERVED, input->keybit);
error = input_register_device(input);
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c
index e373929..48829f3 100644
--- a/drivers/input/misc/pcf8574_keypad.c
+++ b/drivers/input/misc/pcf8574_keypad.c
@@ -114,8 +114,12 @@ static int pcf8574_kp_probe(struct i2c_client *client, const struct i2c_device_i
for (i = 0; i < ARRAY_SIZE(pcf8574_kp_btncode); i++) {
lp->btncode[i] = pcf8574_kp_btncode[i];
- __set_bit(lp->btncode[i] & KEY_MAX, idev->keybit);
+ if (lp->btncode[i] > KEY_MAX)
+ lp->btncode[i] = 0;
+ else if (lp->btncode[i] > KEY_RESERVED)
+ __set_bit(lp->btncode[i], idev->keybit);
}
+ __clear_bit(KEY_RESERVED, idev->keybit);
sprintf(lp->name, DRV_NAME);
sprintf(lp->phys, "kp_data/input0");
diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
index 0e763a7..7fdac45 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -201,6 +201,7 @@ static void input_register_keys(struct infrared *ir)
else if (ir->key_map[i] > KEY_RESERVED)
set_bit(ir->key_map[i], ir->input_dev->keybit);
}
+ __clear_bit(KEY_RESERVED, ir->input_dev->keybit);
ir->input_dev->keycode = ir->key_map;
ir->input_dev->keycodesize = sizeof(ir->key_map[0]);
--
1.7.1
next reply other threads:[~2013-11-23 13:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-23 13:45 andrew.liu200917 [this message]
2013-11-23 18:06 ` [PATCH] input:keyboard: "keycode & KEY_MAX" changes some keycode value 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=1385214345-10385-1-git-send-email-andrew.liu200917@gmail.com \
--to=andrew.liu200917@gmail.com \
--cc=device-drivers-devel@blackfin.uclinux.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=michael.hennerich@analog.com \
/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).