aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ir-kbd-i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ir-kbd-i2c.c')
-rw-r--r--drivers/media/video/ir-kbd-i2c.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 3ab875d036e1..a7c41d32f414 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -244,7 +244,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir,
244 244
245/* ----------------------------------------------------------------------- */ 245/* ----------------------------------------------------------------------- */
246 246
247static void ir_key_poll(struct IR_i2c *ir) 247static int ir_key_poll(struct IR_i2c *ir)
248{ 248{
249 static u32 ir_key, ir_raw; 249 static u32 ir_key, ir_raw;
250 int rc; 250 int rc;
@@ -253,20 +253,28 @@ static void ir_key_poll(struct IR_i2c *ir)
253 rc = ir->get_key(ir, &ir_key, &ir_raw); 253 rc = ir->get_key(ir, &ir_key, &ir_raw);
254 if (rc < 0) { 254 if (rc < 0) {
255 dprintk(2,"error\n"); 255 dprintk(2,"error\n");
256 return; 256 return rc;
257 } 257 }
258 258
259 if (rc) { 259 if (rc) {
260 dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key); 260 dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key);
261 rc_keydown(ir->rc, ir_key, 0); 261 rc_keydown(ir->rc, ir_key, 0);
262 } 262 }
263 return 0;
263} 264}
264 265
265static void ir_work(struct work_struct *work) 266static void ir_work(struct work_struct *work)
266{ 267{
268 int rc;
267 struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work); 269 struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work);
268 270
269 ir_key_poll(ir); 271 rc = ir_key_poll(ir);
272 if (rc == -ENODEV) {
273 rc_unregister_device(ir->rc);
274 ir->rc = NULL;
275 return;
276 }
277
270 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval)); 278 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval));
271} 279}
272 280
@@ -446,7 +454,8 @@ static int ir_remove(struct i2c_client *client)
446 cancel_delayed_work_sync(&ir->work); 454 cancel_delayed_work_sync(&ir->work);
447 455
448 /* unregister device */ 456 /* unregister device */
449 rc_unregister_device(ir->rc); 457 if (ir->rc)
458 rc_unregister_device(ir->rc);
450 459
451 /* free memory */ 460 /* free memory */
452 kfree(ir); 461 kfree(ir);
@@ -489,11 +498,3 @@ static void __exit ir_fini(void)
489 498
490module_init(ir_init); 499module_init(ir_init);
491module_exit(ir_fini); 500module_exit(ir_fini);
492
493/*
494 * Overrides for Emacs so that we follow Linus's tabbing style.
495 * ---------------------------------------------------------------------------
496 * Local variables:
497 * c-basic-offset: 8
498 * End:
499 */