From: Daniel Walker <dwalker@mvista.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>, Philippe Troin <phil@fifi.org>,
"Adolfo R. Brandes" <arbrandes@gmail.com>,
linux-input@vger.kernel.org
Subject: [PATCH] input: push down scancode negative checking
Date: Mon, 30 Jun 2008 12:33:46 -0700 [thread overview]
Message-ID: <1214854426-20442-1-git-send-email-dwalker@mvista.com> (raw)
The getkeycode/setkeycode calls should be able to accept "negative" values.
The HID layer has some scan codes of the form 0xffbc0000 for logitech
devices, and they get ignored by these calls. I pushed the checking
into the input_default_* functions since they do need non-negative
values.
I also corrected a typo in the comment for input_set_keycode
Signed-off-by: Daniel Walker <dwalker@mvista.com>
---
drivers/input/input.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 27006fc..e1af21f 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -526,7 +526,7 @@ static int input_default_getkeycode(struct input_dev *dev,
if (!dev->keycodesize)
return -EINVAL;
- if (scancode >= dev->keycodemax)
+ if (scancode < 0 || scancode >= dev->keycodemax)
return -EINVAL;
*keycode = input_fetch_keycode(dev, scancode);
@@ -540,7 +540,7 @@ static int input_default_setkeycode(struct input_dev *dev,
int old_keycode;
int i;
- if (scancode >= dev->keycodemax)
+ if (scancode < 0 || scancode >= dev->keycodemax)
return -EINVAL;
if (!dev->keycodesize)
@@ -595,15 +595,12 @@ static int input_default_setkeycode(struct input_dev *dev,
*/
int input_get_keycode(struct input_dev *dev, int scancode, int *keycode)
{
- if (scancode < 0)
- return -EINVAL;
-
return dev->getkeycode(dev, scancode, keycode);
}
EXPORT_SYMBOL(input_get_keycode);
/**
- * input_get_keycode - assign new keycode to a given scancode
+ * input_set_keycode - assign new keycode to a given scancode
* @dev: input device which keymap is being updated
* @scancode: scancode (or its equivalent for device in question)
* @keycode: new keycode to be assigned to the scancode
@@ -617,9 +614,6 @@ int input_set_keycode(struct input_dev *dev, int scancode, int keycode)
int old_keycode;
int retval;
- if (scancode < 0)
- return -EINVAL;
-
if (keycode < 0 || keycode > KEY_MAX)
return -EINVAL;
--
1.5.4.1.166.g6706d
next reply other threads:[~2008-06-30 19:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-30 19:33 Daniel Walker [this message]
2008-06-30 19:47 ` [PATCH] input: push down scancode negative checking Dmitry Torokhov
2008-06-30 19:56 ` Daniel Walker
2008-07-01 7:51 ` Jiri Kosina
2008-07-01 17:23 ` Daniel Walker
2008-07-07 19:00 ` 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=1214854426-20442-1-git-send-email-dwalker@mvista.com \
--to=dwalker@mvista.com \
--cc=arbrandes@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=phil@fifi.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).