linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: push down scancode negative checking
@ 2008-06-30 19:33 Daniel Walker
  2008-06-30 19:47 ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Walker @ 2008-06-30 19:33 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jiri Kosina, Philippe Troin, Adolfo R. Brandes, linux-input

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-07-07 19:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-30 19:33 [PATCH] input: push down scancode negative checking Daniel Walker
2008-06-30 19:47 ` 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

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).