diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-09 19:28:13 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-10 19:35:28 -0500 |
commit | 90bf3aab42937f760e5b645ab63df46d26b5e620 (patch) | |
tree | ed1dec61c0283b4ef0beae71dbbebbf11bf57b4c /drivers/media/video/ir-kbd-i2c.c | |
parent | c53a8e951b9cb5689a510ef31c85fb9b1ff78f11 (diff) |
[media] cx231xx-input: stop polling if the device got removed.
If the device got removed, stops polling it. Also, un-registers
it at input/evdev, as it won't work anymore. We can't free the
IR structure yet, as the ir_remove method will be called later.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/ir-kbd-i2c.c')
-rw-r--r-- | drivers/media/video/ir-kbd-i2c.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 3ab875d036e1..37d0c2012519 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 | ||
247 | static void ir_key_poll(struct IR_i2c *ir) | 247 | static 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 | ||
265 | static void ir_work(struct work_struct *work) | 266 | static 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); |