aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-11-29 06:19:59 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:42:21 -0500
commit055cd55601f948675006ca90362fc2bfaae90a86 (patch)
treea878c55c30b0ae30334f3523d8dd67940d32a7f3 /drivers
parent0278155c84af42d78785731263b69fb49f945ea7 (diff)
V4L/DVB (13537): ir: Prepare the code for dynamic keycode table allocation
Currently, the IR table is initialized by calling ir_input_init(). However, this function doesn't return any error code, nor has a function to be called when de-initializing the IR's. Change the return argment to integer and make sure that each driver will handle the error code. Also adds a function to free any resources that may be allocating there: ir_input_free(). Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/ir-functions.c12
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c10
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c14
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c7
-rw-r--r--drivers/media/video/cx231xx/cx231xx-input.c8
-rw-r--r--drivers/media/video/cx23885/cx23885-input.c7
-rw-r--r--drivers/media/video/cx88/cx88-input.c7
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c8
-rw-r--r--drivers/media/video/ir-kbd-i2c.c7
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c7
10 files changed, 74 insertions, 13 deletions
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c
index 29885c2893d2..b31bd27da374 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -54,11 +54,13 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
54 54
55/* -------------------------------------------------------------------------- */ 55/* -------------------------------------------------------------------------- */
56 56
57void ir_input_init(struct input_dev *dev, struct ir_input_state *ir, 57int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
58 int ir_type, struct ir_scancode_table *ir_codes) 58 int ir_type, struct ir_scancode_table *ir_codes)
59{ 59{
60 ir->ir_type = ir_type; 60 ir->ir_type = ir_type;
61 61
62 /* FIXME: Add the proper code to dynamically allocate IR table */
63
62 ir_set_keycode_table(dev, ir_codes); 64 ir_set_keycode_table(dev, ir_codes);
63 65
64 clear_bit(0, dev->keybit); 66 clear_bit(0, dev->keybit);
@@ -66,9 +68,17 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
66 set_bit(EV_KEY, dev->evbit); 68 set_bit(EV_KEY, dev->evbit);
67 if (repeat) 69 if (repeat)
68 set_bit(EV_REP, dev->evbit); 70 set_bit(EV_REP, dev->evbit);
71
72 return 0;
69} 73}
70EXPORT_SYMBOL_GPL(ir_input_init); 74EXPORT_SYMBOL_GPL(ir_input_init);
71 75
76void ir_input_free(struct input_dev *input_dev)
77{
78 /* FIXME: Add the proper code to free allocated resources */
79}
80EXPORT_SYMBOL_GPL(ir_input_free);
81
72void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir) 82void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
73{ 83{
74 if (ir->keypressed) { 84 if (ir->keypressed) {
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index 4c28632f94c4..53e3f2a7d31a 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -589,7 +589,12 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
589 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys), 589 snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
590 "pci-%s/ir0", pci_name(dm1105->pdev)); 590 "pci-%s/ir0", pci_name(dm1105->pdev));
591 591
592 ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes); 592 err = ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes);
593 if (err < 0) {
594 input_free_device(input_dev);
595 return err;
596 }
597
593 input_dev->name = "DVB on-card IR receiver"; 598 input_dev->name = "DVB on-card IR receiver";
594 input_dev->phys = dm1105->ir.input_phys; 599 input_dev->phys = dm1105->ir.input_phys;
595 input_dev->id.bustype = BUS_PCI; 600 input_dev->id.bustype = BUS_PCI;
@@ -608,6 +613,7 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
608 613
609 err = input_register_device(input_dev); 614 err = input_register_device(input_dev);
610 if (err) { 615 if (err) {
616 ir_input_free(input_dev);
611 input_free_device(input_dev); 617 input_free_device(input_dev);
612 return err; 618 return err;
613 } 619 }
@@ -617,8 +623,8 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
617 623
618void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105) 624void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105)
619{ 625{
626 ir_input_free(dm1105->ir.input_dev);
620 input_unregister_device(dm1105->ir.input_dev); 627 input_unregister_device(dm1105->ir.input_dev);
621
622} 628}
623 629
624static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb) 630static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb)
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index adc4b954e5ad..7d193ebc0aea 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -224,8 +224,10 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
224 case 0x1011: 224 case 0x1011:
225 case 0x1012: 225 case 0x1012:
226 /* The hauppauge keymap is a superset of these remotes */ 226 /* The hauppauge keymap is a superset of these remotes */
227 ir_input_init(input_dev, &budget_ci->ir.state, 227 error = ir_input_init(input_dev, &budget_ci->ir.state,
228 IR_TYPE_RC5, &ir_codes_hauppauge_new_table); 228 IR_TYPE_RC5, &ir_codes_hauppauge_new_table);
229 if (error < 0)
230 goto out2;
229 231
230 if (rc5_device < 0) 232 if (rc5_device < 0)
231 budget_ci->ir.rc5_device = 0x1f; 233 budget_ci->ir.rc5_device = 0x1f;
@@ -236,8 +238,10 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
236 case 0x1017: 238 case 0x1017:
237 case 0x101a: 239 case 0x101a:
238 /* for the Technotrend 1500 bundled remote */ 240 /* for the Technotrend 1500 bundled remote */
239 ir_input_init(input_dev, &budget_ci->ir.state, 241 error = ir_input_init(input_dev, &budget_ci->ir.state,
240 IR_TYPE_RC5, &ir_codes_tt_1500_table); 242 IR_TYPE_RC5, &ir_codes_tt_1500_table);
243 if (error < 0)
244 goto out2;
241 245
242 if (rc5_device < 0) 246 if (rc5_device < 0)
243 budget_ci->ir.rc5_device = IR_DEVICE_ANY; 247 budget_ci->ir.rc5_device = IR_DEVICE_ANY;
@@ -246,8 +250,10 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
246 break; 250 break;
247 default: 251 default:
248 /* unknown remote */ 252 /* unknown remote */
249 ir_input_init(input_dev, &budget_ci->ir.state, 253 error = ir_input_init(input_dev, &budget_ci->ir.state,
250 IR_TYPE_RC5, &ir_codes_budget_ci_old_table); 254 IR_TYPE_RC5, &ir_codes_budget_ci_old_table);
255 if (error < 0)
256 goto out2;
251 257
252 if (rc5_device < 0) 258 if (rc5_device < 0)
253 budget_ci->ir.rc5_device = IR_DEVICE_ANY; 259 budget_ci->ir.rc5_device = IR_DEVICE_ANY;
@@ -280,6 +286,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
280 return 0; 286 return 0;
281 287
282out2: 288out2:
289 ir_input_free(input_dev);
283 input_free_device(input_dev); 290 input_free_device(input_dev);
284out1: 291out1:
285 return error; 292 return error;
@@ -297,6 +304,7 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
297 del_timer_sync(&dev->timer); 304 del_timer_sync(&dev->timer);
298 ir_input_nokey(dev, &budget_ci->ir.state); 305 ir_input_nokey(dev, &budget_ci->ir.state);
299 306
307 ir_input_free(dev);
300 input_unregister_device(dev); 308 input_unregister_device(dev);
301} 309}
302 310
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 62408ccf34c8..84a957e52c4b 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -368,7 +368,10 @@ int bttv_input_init(struct bttv *btv)
368 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 368 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
369 pci_name(btv->c.pci)); 369 pci_name(btv->c.pci));
370 370
371 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 371 err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
372 if (err < 0)
373 goto err_out_free;
374
372 input_dev->name = ir->name; 375 input_dev->name = ir->name;
373 input_dev->phys = ir->phys; 376 input_dev->phys = ir->phys;
374 input_dev->id.bustype = BUS_PCI; 377 input_dev->id.bustype = BUS_PCI;
@@ -400,6 +403,7 @@ int bttv_input_init(struct bttv *btv)
400 bttv_ir_stop(btv); 403 bttv_ir_stop(btv);
401 btv->remote = NULL; 404 btv->remote = NULL;
402 err_out_free: 405 err_out_free:
406 ir_input_free(input_dev);
403 input_free_device(input_dev); 407 input_free_device(input_dev);
404 kfree(ir); 408 kfree(ir);
405 return err; 409 return err;
@@ -411,6 +415,7 @@ void bttv_input_fini(struct bttv *btv)
411 return; 415 return;
412 416
413 bttv_ir_stop(btv); 417 bttv_ir_stop(btv);
418 ir_input_free(btv->remote->dev);
414 input_unregister_device(btv->remote->dev); 419 input_unregister_device(btv->remote->dev);
415 kfree(btv->remote); 420 kfree(btv->remote);
416 btv->remote = NULL; 421 btv->remote = NULL;
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c b/drivers/media/video/cx231xx/cx231xx-input.c
index 58dd39bc6787..cd135f01b9c1 100644
--- a/drivers/media/video/cx231xx/cx231xx-input.c
+++ b/drivers/media/video/cx231xx/cx231xx-input.c
@@ -197,7 +197,11 @@ int cx231xx_ir_init(struct cx231xx *dev)
197 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 197 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
198 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 198 strlcat(ir->phys, "/input0", sizeof(ir->phys));
199 199
200 ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes); 200 err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER,
201 dev->board.ir_codes);
202 if (err < 0)
203 goto err_out_free;
204
201 input_dev->name = ir->name; 205 input_dev->name = ir->name;
202 input_dev->phys = ir->phys; 206 input_dev->phys = ir->phys;
203 input_dev->id.bustype = BUS_USB; 207 input_dev->id.bustype = BUS_USB;
@@ -222,6 +226,7 @@ err_out_stop:
222 cx231xx_ir_stop(ir); 226 cx231xx_ir_stop(ir);
223 dev->ir = NULL; 227 dev->ir = NULL;
224err_out_free: 228err_out_free:
229 ir_input_free(input_dev);
225 input_free_device(input_dev); 230 input_free_device(input_dev);
226 kfree(ir); 231 kfree(ir);
227 return err; 232 return err;
@@ -236,6 +241,7 @@ int cx231xx_ir_fini(struct cx231xx *dev)
236 return 0; 241 return 0;
237 242
238 cx231xx_ir_stop(ir); 243 cx231xx_ir_stop(ir);
244 ir_input_free(ir->input);
239 input_unregister_device(ir->input); 245 input_unregister_device(ir->input);
240 kfree(ir); 246 kfree(ir);
241 247
diff --git a/drivers/media/video/cx23885/cx23885-input.c b/drivers/media/video/cx23885/cx23885-input.c
index fea882d1fbcb..469e083dd5f8 100644
--- a/drivers/media/video/cx23885/cx23885-input.c
+++ b/drivers/media/video/cx23885/cx23885-input.c
@@ -377,7 +377,10 @@ int cx23885_input_init(struct cx23885_dev *dev)
377 cx23885_boards[dev->board].name); 377 cx23885_boards[dev->board].name);
378 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(dev->pci)); 378 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(dev->pci));
379 379
380 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 380 ret = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
381 if (ret < 0)
382 goto err_out_free;
383
381 input_dev->name = ir->name; 384 input_dev->name = ir->name;
382 input_dev->phys = ir->phys; 385 input_dev->phys = ir->phys;
383 input_dev->id.bustype = BUS_PCI; 386 input_dev->id.bustype = BUS_PCI;
@@ -404,6 +407,7 @@ err_out_stop:
404 cx23885_input_ir_stop(dev); 407 cx23885_input_ir_stop(dev);
405 dev->ir_input = NULL; 408 dev->ir_input = NULL;
406err_out_free: 409err_out_free:
410 ir_input_free(input_dev);
407 input_free_device(input_dev); 411 input_free_device(input_dev);
408 kfree(ir); 412 kfree(ir);
409 return ret; 413 return ret;
@@ -416,6 +420,7 @@ void cx23885_input_fini(struct cx23885_dev *dev)
416 420
417 if (dev->ir_input == NULL) 421 if (dev->ir_input == NULL)
418 return; 422 return;
423 ir_input_free(dev->ir_input->dev);
419 input_unregister_device(dev->ir_input->dev); 424 input_unregister_device(dev->ir_input->dev);
420 kfree(dev->ir_input); 425 kfree(dev->ir_input);
421 dev->ir_input = NULL; 426 dev->ir_input = NULL;
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 7b2066415d7e..92b8cdf9fb81 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -360,7 +360,10 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
360 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name); 360 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
361 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); 361 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
362 362
363 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 363 err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
364 if (err < 0)
365 goto err_out_free;
366
364 input_dev->name = ir->name; 367 input_dev->name = ir->name;
365 input_dev->phys = ir->phys; 368 input_dev->phys = ir->phys;
366 input_dev->id.bustype = BUS_PCI; 369 input_dev->id.bustype = BUS_PCI;
@@ -390,6 +393,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
390 cx88_ir_stop(core, ir); 393 cx88_ir_stop(core, ir);
391 core->ir = NULL; 394 core->ir = NULL;
392 err_out_free: 395 err_out_free:
396 ir_input_free(input_dev);
393 input_free_device(input_dev); 397 input_free_device(input_dev);
394 kfree(ir); 398 kfree(ir);
395 return err; 399 return err;
@@ -404,6 +408,7 @@ int cx88_ir_fini(struct cx88_core *core)
404 return 0; 408 return 0;
405 409
406 cx88_ir_stop(core, ir); 410 cx88_ir_stop(core, ir);
411 ir_input_free(ir->input);
407 input_unregister_device(ir->input); 412 input_unregister_device(ir->input);
408 kfree(ir); 413 kfree(ir);
409 414
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 5550de9c669f..d96ec7c09dca 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -367,7 +367,11 @@ int em28xx_ir_init(struct em28xx *dev)
367 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 367 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
368 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 368 strlcat(ir->phys, "/input0", sizeof(ir->phys));
369 369
370 ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes); 370 err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER,
371 dev->board.ir_codes);
372 if (err < 0)
373 goto err_out_free;
374
371 input_dev->name = ir->name; 375 input_dev->name = ir->name;
372 input_dev->phys = ir->phys; 376 input_dev->phys = ir->phys;
373 input_dev->id.bustype = BUS_USB; 377 input_dev->id.bustype = BUS_USB;
@@ -392,6 +396,7 @@ int em28xx_ir_init(struct em28xx *dev)
392 em28xx_ir_stop(ir); 396 em28xx_ir_stop(ir);
393 dev->ir = NULL; 397 dev->ir = NULL;
394 err_out_free: 398 err_out_free:
399 ir_input_free(input_dev);
395 input_free_device(input_dev); 400 input_free_device(input_dev);
396 kfree(ir); 401 kfree(ir);
397 return err; 402 return err;
@@ -406,6 +411,7 @@ int em28xx_ir_fini(struct em28xx *dev)
406 return 0; 411 return 0;
407 412
408 em28xx_ir_stop(ir); 413 em28xx_ir_stop(ir);
414 ir_input_free(ir->input);
409 input_unregister_device(ir->input); 415 input_unregister_device(ir->input);
410 kfree(ir); 416 kfree(ir);
411 417
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 9c6d0ae58b1f..64360d26b32d 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -437,7 +437,10 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
437 dev_name(&client->dev)); 437 dev_name(&client->dev));
438 438
439 /* init + register input device */ 439 /* init + register input device */
440 ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes); 440 err = ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
441 if (err < 0)
442 goto err_out_free;
443
441 input_dev->id.bustype = BUS_I2C; 444 input_dev->id.bustype = BUS_I2C;
442 input_dev->name = ir->name; 445 input_dev->name = ir->name;
443 input_dev->phys = ir->phys; 446 input_dev->phys = ir->phys;
@@ -456,6 +459,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
456 return 0; 459 return 0;
457 460
458 err_out_free: 461 err_out_free:
462 ir_input_free(input_dev);
459 input_free_device(input_dev); 463 input_free_device(input_dev);
460 kfree(ir); 464 kfree(ir);
461 return err; 465 return err;
@@ -469,6 +473,7 @@ static int ir_remove(struct i2c_client *client)
469 cancel_delayed_work_sync(&ir->work); 473 cancel_delayed_work_sync(&ir->work);
470 474
471 /* unregister device */ 475 /* unregister device */
476 ir_input_free(ir->input);
472 input_unregister_device(ir->input); 477 input_unregister_device(ir->input);
473 478
474 /* free memory */ 479 /* free memory */
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 439f3d54d009..744918b1cd47 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -652,7 +652,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
652 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 652 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
653 pci_name(dev->pci)); 653 pci_name(dev->pci));
654 654
655 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 655 err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
656 if (err < 0)
657 goto err_out_free;
658
656 input_dev->name = ir->name; 659 input_dev->name = ir->name;
657 input_dev->phys = ir->phys; 660 input_dev->phys = ir->phys;
658 input_dev->id.bustype = BUS_PCI; 661 input_dev->id.bustype = BUS_PCI;
@@ -683,6 +686,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
683 saa7134_ir_stop(dev); 686 saa7134_ir_stop(dev);
684 dev->remote = NULL; 687 dev->remote = NULL;
685 err_out_free: 688 err_out_free:
689 ir_input_free(input_dev);
686 input_free_device(input_dev); 690 input_free_device(input_dev);
687 kfree(ir); 691 kfree(ir);
688 return err; 692 return err;
@@ -694,6 +698,7 @@ void saa7134_input_fini(struct saa7134_dev *dev)
694 return; 698 return;
695 699
696 saa7134_ir_stop(dev); 700 saa7134_ir_stop(dev);
701 ir_input_free(dev->remote->dev);
697 input_unregister_device(dev->remote->dev); 702 input_unregister_device(dev->remote->dev);
698 kfree(dev->remote); 703 kfree(dev->remote);
699 dev->remote = NULL; 704 dev->remote = NULL;