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 | |
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')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-input.c | 6 | ||||
-rw-r--r-- | drivers/media/video/ir-kbd-i2c.c | 17 |
2 files changed, 18 insertions, 5 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c b/drivers/media/video/cx231xx/cx231xx-input.c index 45e14cac4622..8a75a908e709 100644 --- a/drivers/media/video/cx231xx/cx231xx-input.c +++ b/drivers/media/video/cx231xx/cx231xx-input.c | |||
@@ -27,12 +27,16 @@ | |||
27 | static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key, | 27 | static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key, |
28 | u32 *ir_raw) | 28 | u32 *ir_raw) |
29 | { | 29 | { |
30 | int rc; | ||
30 | u8 cmd, scancode; | 31 | u8 cmd, scancode; |
31 | 32 | ||
32 | dev_dbg(&ir->rc->input_dev->dev, "%s\n", __func__); | 33 | dev_dbg(&ir->rc->input_dev->dev, "%s\n", __func__); |
33 | 34 | ||
34 | /* poll IR chip */ | 35 | /* poll IR chip */ |
35 | if (1 != i2c_master_recv(ir->c, &cmd, 1)) | 36 | rc = i2c_master_recv(ir->c, &cmd, 1); |
37 | if (rc < 0) | ||
38 | return rc; | ||
39 | if (rc != 1) | ||
36 | return -EIO; | 40 | return -EIO; |
37 | 41 | ||
38 | /* it seems that 0xFE indicates that a button is still hold | 42 | /* it seems that 0xFE indicates that a button is still hold |
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); |