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

* Re: [PATCH] input: push down scancode negative checking
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2008-06-30 19:47 UTC (permalink / raw)
  To: Daniel Walker; +Cc: Jiri Kosina, Philippe Troin, Adolfo R. Brandes, linux-input

On Mon, Jun 30, 2008 at 12:33:46PM -0700, Daniel Walker wrote:
> 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

Hmm, I wonder if we just need to type these as unsigned.

-- 
Dmitry

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

* Re: [PATCH] input: push down scancode negative checking
  2008-06-30 19:47 ` Dmitry Torokhov
@ 2008-06-30 19:56   ` Daniel Walker
  2008-07-01  7:51     ` Jiri Kosina
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Walker @ 2008-06-30 19:56 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Jiri Kosina, Philippe Troin, Adolfo R. Brandes, linux-input


On Mon, 2008-06-30 at 15:47 -0400, Dmitry Torokhov wrote:
> On Mon, Jun 30, 2008 at 12:33:46PM -0700, Daniel Walker wrote:
> > 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
> 
> Hmm, I wonder if we just need to type these as unsigned.
> 

I think it would make sense, because AFAIK scancodes don't really have a
concept of signed-ness anyway .. I almost did it that way, but I wasn't
sure enough about the reasoning for the signed int ..

Daniel


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

* Re: [PATCH] input: push down scancode negative checking
  2008-06-30 19:56   ` Daniel Walker
@ 2008-07-01  7:51     ` Jiri Kosina
  2008-07-01 17:23       ` Daniel Walker
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Kosina @ 2008-07-01  7:51 UTC (permalink / raw)
  To: Daniel Walker
  Cc: Dmitry Torokhov, Philippe Troin, Adolfo R. Brandes, linux-input

On Mon, 30 Jun 2008, Daniel Walker wrote:

>> Hmm, I wonder if we just need to type these as unsigned.
> I think it would make sense, because AFAIK scancodes don't really have a
> concept of signed-ness anyway .. I almost did it that way, but I wasn't
> sure enough about the reasoning for the signed int ..

That would be the option I'd prefer too.

Thanks,

-- 
Jiri Kosina
SUSE Labs

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

* Re: [PATCH] input: push down scancode negative checking
  2008-07-01  7:51     ` Jiri Kosina
@ 2008-07-01 17:23       ` Daniel Walker
  2008-07-07 19:00         ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Walker @ 2008-07-01 17:23 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Dmitry Torokhov, Philippe Troin, Adolfo R. Brandes, linux-input


On Tue, 2008-07-01 at 09:51 +0200, Jiri Kosina wrote:
> On Mon, 30 Jun 2008, Daniel Walker wrote:
> 
> >> Hmm, I wonder if we just need to type these as unsigned.
> > I think it would make sense, because AFAIK scancodes don't really have a
> > concept of signed-ness anyway .. I almost did it that way, but I wasn't
> > sure enough about the reasoning for the signed int ..
> 
> That would be the option I'd prefer too.

Do you guys want me to send another patch for this?

Daniel


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

* Re: [PATCH] input: push down scancode negative checking
  2008-07-01 17:23       ` Daniel Walker
@ 2008-07-07 19:00         ` Dmitry Torokhov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2008-07-07 19:00 UTC (permalink / raw)
  To: Daniel Walker; +Cc: Jiri Kosina, Philippe Troin, Adolfo R. Brandes, linux-input

On Tue, Jul 01, 2008 at 10:23:25AM -0700, Daniel Walker wrote:
> 
> On Tue, 2008-07-01 at 09:51 +0200, Jiri Kosina wrote:
> > On Mon, 30 Jun 2008, Daniel Walker wrote:
> > 
> > >> Hmm, I wonder if we just need to type these as unsigned.
> > > I think it would make sense, because AFAIK scancodes don't really have a
> > > concept of signed-ness anyway .. I almost did it that way, but I wasn't
> > > sure enough about the reasoning for the signed int ..
> > 
> > That would be the option I'd prefer too.
> 
> Do you guys want me to send another patch for this?
> 

Yes please.

-- 
Dmitry

^ permalink raw reply	[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).