aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/IR/ir-keytable.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-05-18 01:06:06 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:57:46 -0400
commit42880cd438d6e74b6005648a7dc06867d4b30b44 (patch)
tree0ab3a733d456a83574b7d554b03841606d342e10 /drivers/media/IR/ir-keytable.c
parentd46844300ccd99444d32e481751b6508c8c7834e (diff)
V4L/DVB: ir-core: fix table resize during keymap init
drivers/media/IR/ir-keytable.c would alloc a suitably sized keymap table only to have it resized as it is populated with the initial keymap. Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR/ir-keytable.c')
-rw-r--r--drivers/media/IR/ir-keytable.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index 1bb4e32f3dc3..ebe24579bf32 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -78,6 +78,7 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab)
78 * @rc_tab: the struct ir_scancode_table to set the keycode in 78 * @rc_tab: the struct ir_scancode_table to set the keycode in
79 * @scancode: the scancode for the ir command 79 * @scancode: the scancode for the ir command
80 * @keycode: the keycode for the ir command 80 * @keycode: the keycode for the ir command
81 * @resize: whether the keytable may be shrunk
81 * @return: -EINVAL if the keycode could not be inserted, otherwise zero. 82 * @return: -EINVAL if the keycode could not be inserted, otherwise zero.
82 * 83 *
83 * This routine is used internally to manipulate the scancode->keycode table. 84 * This routine is used internally to manipulate the scancode->keycode table.
@@ -85,7 +86,8 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab)
85 */ 86 */
86static int ir_do_setkeycode(struct input_dev *dev, 87static int ir_do_setkeycode(struct input_dev *dev,
87 struct ir_scancode_table *rc_tab, 88 struct ir_scancode_table *rc_tab,
88 unsigned scancode, unsigned keycode) 89 unsigned scancode, unsigned keycode,
90 bool resize)
89{ 91{
90 unsigned int i; 92 unsigned int i;
91 int old_keycode = KEY_RESERVED; 93 int old_keycode = KEY_RESERVED;
@@ -129,7 +131,7 @@ static int ir_do_setkeycode(struct input_dev *dev,
129 131
130 if (old_keycode == KEY_RESERVED && keycode != KEY_RESERVED) { 132 if (old_keycode == KEY_RESERVED && keycode != KEY_RESERVED) {
131 /* No previous mapping found, we might need to grow the table */ 133 /* No previous mapping found, we might need to grow the table */
132 if (ir_resize_table(rc_tab)) 134 if (resize && ir_resize_table(rc_tab))
133 return -ENOMEM; 135 return -ENOMEM;
134 136
135 IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n", 137 IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",
@@ -177,7 +179,7 @@ static int ir_setkeycode(struct input_dev *dev,
177 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab; 179 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
178 180
179 spin_lock_irqsave(&rc_tab->lock, flags); 181 spin_lock_irqsave(&rc_tab->lock, flags);
180 rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode); 182 rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode, true);
181 spin_unlock_irqrestore(&rc_tab->lock, flags); 183 spin_unlock_irqrestore(&rc_tab->lock, flags);
182 return rc; 184 return rc;
183} 185}
@@ -204,7 +206,7 @@ static int ir_setkeytable(struct input_dev *dev,
204 spin_lock_irqsave(&rc_tab->lock, flags); 206 spin_lock_irqsave(&rc_tab->lock, flags);
205 for (i = 0; i < from->size; i++) { 207 for (i = 0; i < from->size; i++) {
206 rc = ir_do_setkeycode(dev, to, from->scan[i].scancode, 208 rc = ir_do_setkeycode(dev, to, from->scan[i].scancode,
207 from->scan[i].keycode); 209 from->scan[i].keycode, false);
208 if (rc) 210 if (rc)
209 break; 211 break;
210 } 212 }