Skip to contentSkip to conversation

drivers/media/IR - improve keytable code

PATCH New David Härdeman 1 participant 1 message Mar 28, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/media/IR - improve keytable code

The attached patch rewrites much of the keytable code in drivers/media/IR/ir-keytable.c.

(applies to http://git.linuxtv.org/mchehab/ir.git)

The scancodes are now inserted into the array in sorted order which allows for a binary search on lookup.

The code has also been shrunk by about 150 lines.

In addition it fixes the following bugs:

Any use of ir_seek_table() was racy.

ir_dev->driver_name is leaked between ir_input_register() and ir_input_unregister().

ir_setkeycode() unconditionally does clear_bit() on dev->keybit when removing a mapping, but there might be another mapping with a different scancode and the same keycode.

---
 drivers/media/IR/ir-keymaps.c  |    2 +
 drivers/media/IR/ir-keytable.c |  516 ++++++++++++++-------------------------
 include/media/ir-core.h        |    4 +-
 3 files changed, 190 insertions(+), 332 deletions(-)
drivers/media/IR/ir-keymaps.c +2 -0
index 55e7acd..bae8522 100644
@@ -39,6 +39,8 @@
 struct ir_scancode_table tabname ## _table = {			\
 	.scan = tabname,					\
 	.size = ARRAY_SIZE(tabname),				\
+	.len = ARRAY_SIZE(tabname),				\
+	.alloc = 0,						\
 	.ir_type = type,					\
 	.name = #irname,					\
 };								\
drivers/media/IR/ir-keytable.c +185 -331

618 lines not on this page · raw message

include/media/ir-core.h +3 -1
index 87dd738..c250e36 100644
@@ -46,7 +46,9 @@ struct ir_scancode {
 
 struct ir_scancode_table {
 	struct ir_scancode	*scan;
-	int			size;
+	unsigned int		size;	/* Max number of entries */
+	unsigned int		len;	/* Used number of entries */
+	unsigned int		alloc;	/* Size of *scan in bytes */
 	u64			ir_type;
 	char			*name;
 	spinlock_t		lock;
Signature · 7 lines
1.7.0.3


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html