blob: a0aa5c1b6b41a72d83914d982f92a6154c8ec6a4 [file] [log] [blame]
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -03001/* ir-register.c - handle IR scancode->keycode tables
2 *
3 * Copyright (C) 2009 by Mauro Carvalho Chehab <mchehab@redhat.com>
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -03004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030013 */
14
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030015
Mauro Carvalho Chehab882ead32009-12-29 10:37:38 -030016#include <linux/input.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030018#include <media/ir-common.h>
19
David Härdemanb3074c02010-04-02 15:58:28 -030020/* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */
21#define IR_TAB_MIN_SIZE 256
22#define IR_TAB_MAX_SIZE 8192
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030023
24/**
David Härdemanb3074c02010-04-02 15:58:28 -030025 * ir_resize_table() - resizes a scancode table if necessary
26 * @rc_tab: the ir_scancode_table to resize
27 * @return: zero on success or a negative error code
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -030028 *
David Härdemanb3074c02010-04-02 15:58:28 -030029 * This routine will shrink the ir_scancode_table if it has lots of
30 * unused entries and grow it if it is full.
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -030031 */
David Härdemanb3074c02010-04-02 15:58:28 -030032static int ir_resize_table(struct ir_scancode_table *rc_tab)
33{
34 unsigned int oldalloc = rc_tab->alloc;
35 unsigned int newalloc = oldalloc;
36 struct ir_scancode *oldscan = rc_tab->scan;
37 struct ir_scancode *newscan;
38
39 if (rc_tab->size == rc_tab->len) {
40 /* All entries in use -> grow keytable */
41 if (rc_tab->alloc >= IR_TAB_MAX_SIZE)
42 return -ENOMEM;
43
44 newalloc *= 2;
45 IR_dprintk(1, "Growing table to %u bytes\n", newalloc);
46 }
47
48 if ((rc_tab->len * 3 < rc_tab->size) && (oldalloc > IR_TAB_MIN_SIZE)) {
49 /* Less than 1/3 of entries in use -> shrink keytable */
50 newalloc /= 2;
51 IR_dprintk(1, "Shrinking table to %u bytes\n", newalloc);
52 }
53
54 if (newalloc == oldalloc)
55 return 0;
56
57 newscan = kmalloc(newalloc, GFP_ATOMIC);
58 if (!newscan) {
59 IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc);
60 return -ENOMEM;
61 }
62
63 memcpy(newscan, rc_tab->scan, rc_tab->len * sizeof(struct ir_scancode));
64 rc_tab->scan = newscan;
65 rc_tab->alloc = newalloc;
66 rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode);
67 kfree(oldscan);
68 return 0;
69}
70
71/**
72 * ir_do_setkeycode() - internal function to set a keycode in the
73 * scancode->keycode table
74 * @dev: the struct input_dev device descriptor
75 * @rc_tab: the struct ir_scancode_table to set the keycode in
76 * @scancode: the scancode for the ir command
77 * @keycode: the keycode for the ir command
78 * @return: -EINVAL if the keycode could not be inserted, otherwise zero.
79 *
80 * This routine is used internally to manipulate the scancode->keycode table.
81 * The caller has to hold @rc_tab->lock.
82 */
83static int ir_do_setkeycode(struct input_dev *dev,
84 struct ir_scancode_table *rc_tab,
85 unsigned scancode, unsigned keycode)
86{
87 unsigned int i;
88 int old_keycode = KEY_RESERVED;
89
90 /* First check if we already have a mapping for this ir command */
91 for (i = 0; i < rc_tab->len; i++) {
92 /* Keytable is sorted from lowest to highest scancode */
93 if (rc_tab->scan[i].scancode > scancode)
94 break;
95 else if (rc_tab->scan[i].scancode < scancode)
96 continue;
97
98 old_keycode = rc_tab->scan[i].keycode;
99 rc_tab->scan[i].keycode = keycode;
100
101 /* Did the user wish to remove the mapping? */
102 if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN) {
Mauro Carvalho Chehab35438942010-04-03 16:53:16 -0300103 IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",
104 i, scancode);
David Härdemanb3074c02010-04-02 15:58:28 -0300105 rc_tab->len--;
106 memmove(&rc_tab->scan[i], &rc_tab->scan[i + 1],
107 (rc_tab->len - i) * sizeof(struct ir_scancode));
108 }
109
110 /* Possibly shrink the keytable, failure is not a problem */
111 ir_resize_table(rc_tab);
112 break;
113 }
114
115 if (old_keycode == KEY_RESERVED) {
116 /* No previous mapping found, we might need to grow the table */
117 if (ir_resize_table(rc_tab))
118 return -ENOMEM;
119
Mauro Carvalho Chehab35438942010-04-03 16:53:16 -0300120 IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",
121 i, scancode, keycode);
122
David Härdemanb3074c02010-04-02 15:58:28 -0300123 /* i is the proper index to insert our new keycode */
124 memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i],
125 (rc_tab->len - i) * sizeof(struct ir_scancode));
126 rc_tab->scan[i].scancode = scancode;
127 rc_tab->scan[i].keycode = keycode;
128 rc_tab->len++;
129 set_bit(keycode, dev->keybit);
130 } else {
Mauro Carvalho Chehab35438942010-04-03 16:53:16 -0300131 IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",
132 i, scancode, keycode);
David Härdemanb3074c02010-04-02 15:58:28 -0300133 /* A previous mapping was updated... */
134 clear_bit(old_keycode, dev->keybit);
135 /* ...but another scancode might use the same keycode */
136 for (i = 0; i < rc_tab->len; i++) {
137 if (rc_tab->scan[i].keycode == old_keycode) {
138 set_bit(old_keycode, dev->keybit);
139 break;
140 }
141 }
142 }
143
144 return 0;
145}
146
147/**
148 * ir_setkeycode() - set a keycode in the scancode->keycode table
149 * @dev: the struct input_dev device descriptor
150 * @scancode: the desired scancode
151 * @keycode: result
152 * @return: -EINVAL if the keycode could not be inserted, otherwise zero.
153 *
154 * This routine is used to handle evdev EVIOCSKEY ioctl.
155 */
156static int ir_setkeycode(struct input_dev *dev,
157 unsigned int scancode, unsigned int keycode)
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300158{
159 int rc;
160 unsigned long flags;
David Härdemanb3074c02010-04-02 15:58:28 -0300161 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
162 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300163
164 spin_lock_irqsave(&rc_tab->lock, flags);
David Härdemanb3074c02010-04-02 15:58:28 -0300165 rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode);
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300166 spin_unlock_irqrestore(&rc_tab->lock, flags);
167 return rc;
168}
169
170/**
David Härdemanb3074c02010-04-02 15:58:28 -0300171 * ir_setkeytable() - sets several entries in the scancode->keycode table
172 * @dev: the struct input_dev device descriptor
173 * @to: the struct ir_scancode_table to copy entries to
174 * @from: the struct ir_scancode_table to copy entries from
175 * @return: -EINVAL if all keycodes could not be inserted, otherwise zero.
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300176 *
David Härdemanb3074c02010-04-02 15:58:28 -0300177 * This routine is used to handle table initialization.
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300178 */
David Härdemanb3074c02010-04-02 15:58:28 -0300179static int ir_setkeytable(struct input_dev *dev,
180 struct ir_scancode_table *to,
181 const struct ir_scancode_table *from)
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300182{
David Härdemanb3074c02010-04-02 15:58:28 -0300183 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
184 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
185 unsigned long flags;
186 unsigned int i;
187 int rc = 0;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300188
David Härdemanb3074c02010-04-02 15:58:28 -0300189 spin_lock_irqsave(&rc_tab->lock, flags);
190 for (i = 0; i < from->size; i++) {
191 rc = ir_do_setkeycode(dev, to, from->scan[i].scancode,
192 from->scan[i].keycode);
193 if (rc)
194 break;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300195 }
David Härdemanb3074c02010-04-02 15:58:28 -0300196 spin_unlock_irqrestore(&rc_tab->lock, flags);
197 return rc;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300198}
199
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300200/**
David Härdemanb3074c02010-04-02 15:58:28 -0300201 * ir_getkeycode() - get a keycode from the scancode->keycode table
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300202 * @dev: the struct input_dev device descriptor
203 * @scancode: the desired scancode
David Härdemanb3074c02010-04-02 15:58:28 -0300204 * @keycode: used to return the keycode, if found, or KEY_RESERVED
205 * @return: always returns zero.
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300206 *
207 * This routine is used to handle evdev EVIOCGKEY ioctl.
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300208 */
209static int ir_getkeycode(struct input_dev *dev,
Dmitry Torokhov58b93992010-03-08 22:37:10 -0800210 unsigned int scancode, unsigned int *keycode)
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300211{
David Härdemanb3074c02010-04-02 15:58:28 -0300212 int start, end, mid;
213 unsigned long flags;
214 int key = KEY_RESERVED;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300215 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
216 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300217
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300218 spin_lock_irqsave(&rc_tab->lock, flags);
David Härdemanb3074c02010-04-02 15:58:28 -0300219 start = 0;
220 end = rc_tab->len - 1;
221 while (start <= end) {
222 mid = (start + end) / 2;
223 if (rc_tab->scan[mid].scancode < scancode)
224 start = mid + 1;
225 else if (rc_tab->scan[mid].scancode > scancode)
226 end = mid - 1;
227 else {
228 key = rc_tab->scan[mid].keycode;
229 break;
230 }
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300231 }
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300232 spin_unlock_irqrestore(&rc_tab->lock, flags);
233
Mauro Carvalho Chehab35438942010-04-03 16:53:16 -0300234 if (key == KEY_RESERVED)
235 IR_dprintk(1, "unknown key for scancode 0x%04x\n",
236 scancode);
237
David Härdemanb3074c02010-04-02 15:58:28 -0300238 *keycode = key;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300239 return 0;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300240}
241
242/**
243 * ir_g_keycode_from_table() - gets the keycode that corresponds to a scancode
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300244 * @input_dev: the struct input_dev descriptor of the device
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300245 * @scancode: the scancode that we're seeking
246 *
247 * This routine is used by the input routines when a key is pressed at the
248 * IR. The scancode is received and needs to be converted into a keycode.
Mauro Carvalho Chehab6660de52010-03-21 12:15:16 -0300249 * If the key is not found, it returns KEY_RESERVED. Otherwise, returns the
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300250 * corresponding keycode from the table.
251 */
252u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
253{
David Härdemanb3074c02010-04-02 15:58:28 -0300254 int keycode;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300255
David Härdemanb3074c02010-04-02 15:58:28 -0300256 ir_getkeycode(dev, scancode, &keycode);
Mauro Carvalho Chehab35438942010-04-03 16:53:16 -0300257 if (keycode != KEY_RESERVED)
258 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
259 dev->name, scancode, keycode);
David Härdemanb3074c02010-04-02 15:58:28 -0300260 return keycode;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300261}
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300262EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300263
264/**
Mauro Carvalho Chehab6660de52010-03-21 12:15:16 -0300265 * ir_keyup() - generates input event to cleanup a key press
266 * @input_dev: the struct input_dev descriptor of the device
267 *
268 * This routine is used by the input routines when a key is pressed at the
269 * IR. It reports a keyup input event via input_report_key().
270 */
271void ir_keyup(struct input_dev *dev)
272{
273 struct ir_input_dev *ir = input_get_drvdata(dev);
274
275 if (!ir->keypressed)
276 return;
277
Mauro Carvalho Chehab9f154782010-03-21 13:00:55 -0300278 IR_dprintk(1, "keyup key 0x%04x\n", ir->keycode);
Mauro Carvalho Chehab6660de52010-03-21 12:15:16 -0300279 input_report_key(dev, ir->keycode, 0);
280 input_sync(dev);
281 ir->keypressed = 0;
282}
283EXPORT_SYMBOL_GPL(ir_keyup);
284
285/**
286 * ir_keydown() - generates input event for a key press
287 * @input_dev: the struct input_dev descriptor of the device
288 * @scancode: the scancode that we're seeking
289 *
290 * This routine is used by the input routines when a key is pressed at the
291 * IR. It gets the keycode for a scancode and reports an input event via
292 * input_report_key().
293 */
294void ir_keydown(struct input_dev *dev, int scancode)
295{
296 struct ir_input_dev *ir = input_get_drvdata(dev);
297
298 u32 keycode = ir_g_keycode_from_table(dev, scancode);
299
300 /* If already sent a keydown, do a keyup */
301 if (ir->keypressed)
302 ir_keyup(dev);
303
304 if (KEY_RESERVED == keycode)
305 return;
306
307 ir->keycode = keycode;
308 ir->keypressed = 1;
309
310 IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n",
311 dev->name, keycode, scancode);
312
313 input_report_key(dev, ir->keycode, 1);
314 input_sync(dev);
315
316}
317EXPORT_SYMBOL_GPL(ir_keydown);
318
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300319static int ir_open(struct input_dev *input_dev)
320{
321 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
322
323 return ir_dev->props->open(ir_dev->props->priv);
324}
325
326static void ir_close(struct input_dev *input_dev)
327{
328 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
329
330 ir_dev->props->close(ir_dev->props->priv);
331}
Mauro Carvalho Chehab6660de52010-03-21 12:15:16 -0300332
333/**
Mauro Carvalho Chehabb2245ba2010-04-02 13:18:42 -0300334 * __ir_input_register() - sets the IR keycode table and add the handlers
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300335 * for keymap table get/set
336 * @input_dev: the struct input_dev descriptor of the device
337 * @rc_tab: the struct ir_scancode_table table of scancode/keymap
338 *
Mauro Carvalho Chehabd4b778d2009-12-14 02:55:03 -0300339 * This routine is used to initialize the input infrastructure
340 * to work with an IR.
341 * It will register the input/evdev interface for the device and
342 * register the syfs code for IR class
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300343 */
Mauro Carvalho Chehabb2245ba2010-04-02 13:18:42 -0300344int __ir_input_register(struct input_dev *input_dev,
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300345 const struct ir_scancode_table *rc_tab,
Mauro Carvalho Chehab727e6252010-03-12 21:18:14 -0300346 const struct ir_dev_props *props,
347 const char *driver_name)
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300348{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300349 struct ir_input_dev *ir_dev;
David Härdemanb3074c02010-04-02 15:58:28 -0300350 int rc;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300351
352 if (rc_tab->scan == NULL || !rc_tab->size)
353 return -EINVAL;
354
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300355 ir_dev = kzalloc(sizeof(*ir_dev), GFP_KERNEL);
356 if (!ir_dev)
357 return -ENOMEM;
358
David Härdemanb3074c02010-04-02 15:58:28 -0300359 ir_dev->driver_name = kasprintf(GFP_KERNEL, "%s", driver_name);
360 if (!ir_dev->driver_name) {
361 rc = -ENOMEM;
362 goto out_dev;
Alexander Beregalov82311522010-01-09 13:51:14 -0300363 }
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300364
David Härdemanb3074c02010-04-02 15:58:28 -0300365 input_dev->getkeycode = ir_getkeycode;
366 input_dev->setkeycode = ir_setkeycode;
367 input_set_drvdata(input_dev, ir_dev);
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300368
David Härdemanb3074c02010-04-02 15:58:28 -0300369 spin_lock_init(&ir_dev->rc_tab.lock);
370 ir_dev->rc_tab.name = rc_tab->name;
371 ir_dev->rc_tab.ir_type = rc_tab->ir_type;
372 ir_dev->rc_tab.alloc = roundup_pow_of_two(rc_tab->size *
373 sizeof(struct ir_scancode));
374 ir_dev->rc_tab.scan = kmalloc(ir_dev->rc_tab.alloc, GFP_KERNEL);
375 ir_dev->rc_tab.size = ir_dev->rc_tab.alloc / sizeof(struct ir_scancode);
376
377 if (!ir_dev->rc_tab.scan) {
378 rc = -ENOMEM;
379 goto out_name;
380 }
381
382 IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
383 ir_dev->rc_tab.size, ir_dev->rc_tab.alloc);
384
385 set_bit(EV_KEY, input_dev->evbit);
386 if (ir_setkeytable(input_dev, &ir_dev->rc_tab, rc_tab)) {
387 rc = -ENOMEM;
388 goto out_table;
389 }
390
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300391 ir_dev->props = props;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300392 if (props && props->open)
393 input_dev->open = ir_open;
394 if (props && props->close)
395 input_dev->close = ir_close;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300396
Mauro Carvalho Chehab945cdfa2010-03-11 12:41:56 -0300397 rc = ir_register_class(input_dev);
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300398 if (rc < 0)
David Härdemanb3074c02010-04-02 15:58:28 -0300399 goto out_table;
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300400
Mauro Carvalho Chehab35438942010-04-03 16:53:16 -0300401 IR_dprintk(1, "Registered input device on %s for %s remote.\n",
402 driver_name, rc_tab->name);
403
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300404 return 0;
405
David Härdemanb3074c02010-04-02 15:58:28 -0300406out_table:
407 kfree(ir_dev->rc_tab.scan);
408out_name:
409 kfree(ir_dev->driver_name);
410out_dev:
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300411 kfree(ir_dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300412 return rc;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300413}
Mauro Carvalho Chehabb2245ba2010-04-02 13:18:42 -0300414EXPORT_SYMBOL_GPL(__ir_input_register);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300415
Mauro Carvalho Chehabd4b778d2009-12-14 02:55:03 -0300416/**
417 * ir_input_unregister() - unregisters IR and frees resources
418 * @input_dev: the struct input_dev descriptor of the device
419
420 * This routine is used to free memory and de-register interfaces.
421 */
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -0300422void ir_input_unregister(struct input_dev *dev)
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300423{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300424 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300425 struct ir_scancode_table *rc_tab;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300426
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300427 if (!ir_dev)
Mauro Carvalho Chehab05395a32009-12-06 08:32:49 -0300428 return;
429
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300430 IR_dprintk(1, "Freed keycode table\n");
431
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300432 rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300433 rc_tab->size = 0;
434 kfree(rc_tab->scan);
435 rc_tab->scan = NULL;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300436
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300437 ir_unregister_class(dev);
438
David Härdemanb3074c02010-04-02 15:58:28 -0300439 kfree(ir_dev->driver_name);
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300440 kfree(ir_dev);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300441}
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -0300442EXPORT_SYMBOL_GPL(ir_input_unregister);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300443
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300444int ir_core_debug; /* ir_debug level (0,1,2) */
445EXPORT_SYMBOL_GPL(ir_core_debug);
446module_param_named(debug, ir_core_debug, int, 0644);
447
448MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
449MODULE_LICENSE("GPL");