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>
This commit is contained in:
Mauro Carvalho Chehab 2009-11-29 08:19:59 -03:00
Родитель 0278155c84
Коммит 055cd55601
11 изменённых файлов: 76 добавлений и 14 удалений

Просмотреть файл

@ -54,11 +54,13 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
/* -------------------------------------------------------------------------- */
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
int ir_type, struct ir_scancode_table *ir_codes)
{
ir->ir_type = ir_type;
/* FIXME: Add the proper code to dynamically allocate IR table */
ir_set_keycode_table(dev, ir_codes);
clear_bit(0, dev->keybit);
@ -66,9 +68,17 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
set_bit(EV_KEY, dev->evbit);
if (repeat)
set_bit(EV_REP, dev->evbit);
return 0;
}
EXPORT_SYMBOL_GPL(ir_input_init);
void ir_input_free(struct input_dev *input_dev)
{
/* FIXME: Add the proper code to free allocated resources */
}
EXPORT_SYMBOL_GPL(ir_input_free);
void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
{
if (ir->keypressed) {

Просмотреть файл

@ -589,7 +589,12 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
"pci-%s/ir0", pci_name(dm1105->pdev));
ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes);
err = ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes);
if (err < 0) {
input_free_device(input_dev);
return err;
}
input_dev->name = "DVB on-card IR receiver";
input_dev->phys = dm1105->ir.input_phys;
input_dev->id.bustype = BUS_PCI;
@ -608,6 +613,7 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
err = input_register_device(input_dev);
if (err) {
ir_input_free(input_dev);
input_free_device(input_dev);
return err;
}
@ -617,8 +623,8 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105)
{
ir_input_free(dm1105->ir.input_dev);
input_unregister_device(dm1105->ir.input_dev);
}
static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb)

Просмотреть файл

@ -224,8 +224,10 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
case 0x1011:
case 0x1012:
/* The hauppauge keymap is a superset of these remotes */
ir_input_init(input_dev, &budget_ci->ir.state,
error = ir_input_init(input_dev, &budget_ci->ir.state,
IR_TYPE_RC5, &ir_codes_hauppauge_new_table);
if (error < 0)
goto out2;
if (rc5_device < 0)
budget_ci->ir.rc5_device = 0x1f;
@ -236,8 +238,10 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
case 0x1017:
case 0x101a:
/* for the Technotrend 1500 bundled remote */
ir_input_init(input_dev, &budget_ci->ir.state,
error = ir_input_init(input_dev, &budget_ci->ir.state,
IR_TYPE_RC5, &ir_codes_tt_1500_table);
if (error < 0)
goto out2;
if (rc5_device < 0)
budget_ci->ir.rc5_device = IR_DEVICE_ANY;
@ -246,8 +250,10 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
break;
default:
/* unknown remote */
ir_input_init(input_dev, &budget_ci->ir.state,
error = ir_input_init(input_dev, &budget_ci->ir.state,
IR_TYPE_RC5, &ir_codes_budget_ci_old_table);
if (error < 0)
goto out2;
if (rc5_device < 0)
budget_ci->ir.rc5_device = IR_DEVICE_ANY;
@ -280,6 +286,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
return 0;
out2:
ir_input_free(input_dev);
input_free_device(input_dev);
out1:
return error;
@ -297,6 +304,7 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
del_timer_sync(&dev->timer);
ir_input_nokey(dev, &budget_ci->ir.state);
ir_input_free(dev);
input_unregister_device(dev);
}

Просмотреть файл

@ -368,7 +368,10 @@ int bttv_input_init(struct bttv *btv)
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
pci_name(btv->c.pci));
ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
if (err < 0)
goto err_out_free;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_PCI;
@ -400,6 +403,7 @@ int bttv_input_init(struct bttv *btv)
bttv_ir_stop(btv);
btv->remote = NULL;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return err;
@ -411,6 +415,7 @@ void bttv_input_fini(struct bttv *btv)
return;
bttv_ir_stop(btv);
ir_input_free(btv->remote->dev);
input_unregister_device(btv->remote->dev);
kfree(btv->remote);
btv->remote = NULL;

Просмотреть файл

@ -197,7 +197,11 @@ int cx231xx_ir_init(struct cx231xx *dev)
usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
strlcat(ir->phys, "/input0", sizeof(ir->phys));
ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes);
err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER,
dev->board.ir_codes);
if (err < 0)
goto err_out_free;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_USB;
@ -222,6 +226,7 @@ err_out_stop:
cx231xx_ir_stop(ir);
dev->ir = NULL;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return err;
@ -236,6 +241,7 @@ int cx231xx_ir_fini(struct cx231xx *dev)
return 0;
cx231xx_ir_stop(ir);
ir_input_free(ir->input);
input_unregister_device(ir->input);
kfree(ir);

Просмотреть файл

@ -377,7 +377,10 @@ int cx23885_input_init(struct cx23885_dev *dev)
cx23885_boards[dev->board].name);
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(dev->pci));
ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
ret = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
if (ret < 0)
goto err_out_free;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_PCI;
@ -404,6 +407,7 @@ err_out_stop:
cx23885_input_ir_stop(dev);
dev->ir_input = NULL;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return ret;
@ -416,6 +420,7 @@ void cx23885_input_fini(struct cx23885_dev *dev)
if (dev->ir_input == NULL)
return;
ir_input_free(dev->ir_input->dev);
input_unregister_device(dev->ir_input->dev);
kfree(dev->ir_input);
dev->ir_input = NULL;

Просмотреть файл

@ -360,7 +360,10 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
if (err < 0)
goto err_out_free;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_PCI;
@ -390,6 +393,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
cx88_ir_stop(core, ir);
core->ir = NULL;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return err;
@ -404,6 +408,7 @@ int cx88_ir_fini(struct cx88_core *core)
return 0;
cx88_ir_stop(core, ir);
ir_input_free(ir->input);
input_unregister_device(ir->input);
kfree(ir);

Просмотреть файл

@ -367,7 +367,11 @@ int em28xx_ir_init(struct em28xx *dev)
usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
strlcat(ir->phys, "/input0", sizeof(ir->phys));
ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes);
err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER,
dev->board.ir_codes);
if (err < 0)
goto err_out_free;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_USB;
@ -392,6 +396,7 @@ int em28xx_ir_init(struct em28xx *dev)
em28xx_ir_stop(ir);
dev->ir = NULL;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return err;
@ -406,6 +411,7 @@ int em28xx_ir_fini(struct em28xx *dev)
return 0;
em28xx_ir_stop(ir);
ir_input_free(ir->input);
input_unregister_device(ir->input);
kfree(ir);

Просмотреть файл

@ -437,7 +437,10 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
dev_name(&client->dev));
/* init + register input device */
ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
err = ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
if (err < 0)
goto err_out_free;
input_dev->id.bustype = BUS_I2C;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
@ -456,6 +459,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
return 0;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return err;
@ -469,6 +473,7 @@ static int ir_remove(struct i2c_client *client)
cancel_delayed_work_sync(&ir->work);
/* unregister device */
ir_input_free(ir->input);
input_unregister_device(ir->input);
/* free memory */

Просмотреть файл

@ -652,7 +652,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
pci_name(dev->pci));
ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
if (err < 0)
goto err_out_free;
input_dev->name = ir->name;
input_dev->phys = ir->phys;
input_dev->id.bustype = BUS_PCI;
@ -683,6 +686,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
saa7134_ir_stop(dev);
dev->remote = NULL;
err_out_free:
ir_input_free(input_dev);
input_free_device(input_dev);
kfree(ir);
return err;
@ -694,6 +698,7 @@ void saa7134_input_fini(struct saa7134_dev *dev)
return;
saa7134_ir_stop(dev);
ir_input_free(dev->remote->dev);
input_unregister_device(dev->remote->dev);
kfree(dev->remote);
dev->remote = NULL;

Просмотреть файл

@ -100,7 +100,7 @@ struct card_ir {
/* Routines from ir-functions.c */
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
int ir_type, struct ir_scancode_table *ir_codes);
void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
@ -121,6 +121,7 @@ u32 ir_g_keycode_from_table(struct input_dev *input_dev,
int ir_set_keycode_table(struct input_dev *input_dev,
struct ir_scancode_table *rc_tab);
void ir_input_free(struct input_dev *input_dev);
/* scancode->keycode map tables from ir-keymaps.c */