aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ir-kbd-gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ir-kbd-gpio.c')
-rw-r--r--drivers/media/video/ir-kbd-gpio.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c
index cf292da8fdd5..234151e48edc 100644
--- a/drivers/media/video/ir-kbd-gpio.c
+++ b/drivers/media/video/ir-kbd-gpio.c
@@ -158,7 +158,7 @@ static IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE] = {
158 158
159struct IR { 159struct IR {
160 struct bttv_sub_device *sub; 160 struct bttv_sub_device *sub;
161 struct input_dev input; 161 struct input_dev *input;
162 struct ir_input_state ir; 162 struct ir_input_state ir;
163 char name[32]; 163 char name[32];
164 char phys[32]; 164 char phys[32];
@@ -217,23 +217,23 @@ static void ir_handle_key(struct IR *ir)
217 if (ir->mask_keydown) { 217 if (ir->mask_keydown) {
218 /* bit set on keydown */ 218 /* bit set on keydown */
219 if (gpio & ir->mask_keydown) { 219 if (gpio & ir->mask_keydown) {
220 ir_input_keydown(&ir->input,&ir->ir,data,data); 220 ir_input_keydown(ir->input, &ir->ir, data, data);
221 } else { 221 } else {
222 ir_input_nokey(&ir->input,&ir->ir); 222 ir_input_nokey(ir->input, &ir->ir);
223 } 223 }
224 224
225 } else if (ir->mask_keyup) { 225 } else if (ir->mask_keyup) {
226 /* bit cleared on keydown */ 226 /* bit cleared on keydown */
227 if (0 == (gpio & ir->mask_keyup)) { 227 if (0 == (gpio & ir->mask_keyup)) {
228 ir_input_keydown(&ir->input,&ir->ir,data,data); 228 ir_input_keydown(ir->input, &ir->ir, data, data);
229 } else { 229 } else {
230 ir_input_nokey(&ir->input,&ir->ir); 230 ir_input_nokey(ir->input, &ir->ir);
231 } 231 }
232 232
233 } else { 233 } else {
234 /* can't disturgissh keydown/up :-/ */ 234 /* can't disturgissh keydown/up :-/ */
235 ir_input_keydown(&ir->input,&ir->ir,data,data); 235 ir_input_keydown(ir->input, &ir->ir, data, data);
236 ir_input_nokey(&ir->input,&ir->ir); 236 ir_input_nokey(ir->input, &ir->ir);
237 } 237 }
238} 238}
239 239
@@ -268,13 +268,17 @@ static int ir_probe(struct device *dev)
268{ 268{
269 struct bttv_sub_device *sub = to_bttv_sub_dev(dev); 269 struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
270 struct IR *ir; 270 struct IR *ir;
271 struct input_dev *input_dev;
271 IR_KEYTAB_TYPE *ir_codes = NULL; 272 IR_KEYTAB_TYPE *ir_codes = NULL;
272 int ir_type = IR_TYPE_OTHER; 273 int ir_type = IR_TYPE_OTHER;
273 274
274 ir = kmalloc(sizeof(*ir),GFP_KERNEL); 275 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
275 if (NULL == ir) 276 input_dev = input_allocate_device();
277 if (!ir || !input_dev) {
278 kfree(ir);
279 input_free_device(input_dev);
276 return -ENOMEM; 280 return -ENOMEM;
277 memset(ir,0,sizeof(*ir)); 281 }
278 282
279 /* detect & configure */ 283 /* detect & configure */
280 switch (sub->core->type) { 284 switch (sub->core->type) {
@@ -328,6 +332,7 @@ static int ir_probe(struct device *dev)
328 } 332 }
329 if (NULL == ir_codes) { 333 if (NULL == ir_codes) {
330 kfree(ir); 334 kfree(ir);
335 input_free_device(input_dev);
331 return -ENODEV; 336 return -ENODEV;
332 } 337 }
333 338
@@ -341,19 +346,19 @@ static int ir_probe(struct device *dev)
341 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 346 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
342 pci_name(sub->core->pci)); 347 pci_name(sub->core->pci));
343 348
344 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); 349 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
345 ir->input.name = ir->name; 350 input_dev->name = ir->name;
346 ir->input.phys = ir->phys; 351 input_dev->phys = ir->phys;
347 ir->input.id.bustype = BUS_PCI; 352 input_dev->id.bustype = BUS_PCI;
348 ir->input.id.version = 1; 353 input_dev->id.version = 1;
349 if (sub->core->pci->subsystem_vendor) { 354 if (sub->core->pci->subsystem_vendor) {
350 ir->input.id.vendor = sub->core->pci->subsystem_vendor; 355 input_dev->id.vendor = sub->core->pci->subsystem_vendor;
351 ir->input.id.product = sub->core->pci->subsystem_device; 356 input_dev->id.product = sub->core->pci->subsystem_device;
352 } else { 357 } else {
353 ir->input.id.vendor = sub->core->pci->vendor; 358 input_dev->id.vendor = sub->core->pci->vendor;
354 ir->input.id.product = sub->core->pci->device; 359 input_dev->id.product = sub->core->pci->device;
355 } 360 }
356 ir->input.dev = &sub->core->pci->dev; 361 input_dev->cdev.dev = &sub->core->pci->dev;
357 362
358 if (ir->polling) { 363 if (ir->polling) {
359 INIT_WORK(&ir->work, ir_work, ir); 364 INIT_WORK(&ir->work, ir_work, ir);
@@ -364,9 +369,8 @@ static int ir_probe(struct device *dev)
364 } 369 }
365 370
366 /* all done */ 371 /* all done */
367 dev_set_drvdata(dev,ir); 372 dev_set_drvdata(dev, ir);
368 input_register_device(&ir->input); 373 input_register_device(ir->input);
369 printk(DEVNAME ": %s detected at %s\n",ir->input.name,ir->input.phys);
370 374
371 return 0; 375 return 0;
372} 376}
@@ -380,7 +384,7 @@ static int ir_remove(struct device *dev)
380 flush_scheduled_work(); 384 flush_scheduled_work();
381 } 385 }
382 386
383 input_unregister_device(&ir->input); 387 input_unregister_device(ir->input);
384 kfree(ir); 388 kfree(ir);
385 return 0; 389 return 0;
386} 390}