diff options
author | Sean Young <sean@mess.org> | 2012-08-13 07:59:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-13 15:19:13 -0400 |
commit | 4da212e2ffaa34edb887a3a86424124fe8341e34 (patch) | |
tree | d7688629db376758548694346324653ca618d67c /drivers/media/video | |
parent | b83bfd1b0127b0963fcac39280280e365e7e04d8 (diff) |
[media] saa7134: simplify timer activation
This simplies the code and resolves a possible race condition between
ir_raw_decode_timer_end() and saa7134_raw_decode_irq().
If the interrupt handler is called after ir_raw_decode_timer_end()
calls ir_raw_event_handle() but before clearing ir->active, then the
timer won't be rearmed.
Compile tested only.
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-input.c | 10 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 1 |
2 files changed, 3 insertions, 8 deletions
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 05c6e217d8a7..0f78f5e537e2 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -446,11 +446,8 @@ static void saa7134_input_timer(unsigned long data) | |||
446 | static void ir_raw_decode_timer_end(unsigned long data) | 446 | static void ir_raw_decode_timer_end(unsigned long data) |
447 | { | 447 | { |
448 | struct saa7134_dev *dev = (struct saa7134_dev *)data; | 448 | struct saa7134_dev *dev = (struct saa7134_dev *)data; |
449 | struct saa7134_card_ir *ir = dev->remote; | ||
450 | 449 | ||
451 | ir_raw_event_handle(dev->remote->dev); | 450 | ir_raw_event_handle(dev->remote->dev); |
452 | |||
453 | ir->active = false; | ||
454 | } | 451 | } |
455 | 452 | ||
456 | static int __saa7134_ir_start(void *priv) | 453 | static int __saa7134_ir_start(void *priv) |
@@ -501,7 +498,6 @@ static int __saa7134_ir_start(void *priv) | |||
501 | } | 498 | } |
502 | 499 | ||
503 | ir->running = true; | 500 | ir->running = true; |
504 | ir->active = false; | ||
505 | 501 | ||
506 | if (ir->polling) { | 502 | if (ir->polling) { |
507 | setup_timer(&ir->timer, saa7134_input_timer, | 503 | setup_timer(&ir->timer, saa7134_input_timer, |
@@ -532,7 +528,6 @@ static void __saa7134_ir_stop(void *priv) | |||
532 | if (ir->polling || ir->raw_decode) | 528 | if (ir->polling || ir->raw_decode) |
533 | del_timer_sync(&ir->timer); | 529 | del_timer_sync(&ir->timer); |
534 | 530 | ||
535 | ir->active = false; | ||
536 | ir->running = false; | 531 | ir->running = false; |
537 | 532 | ||
538 | return; | 533 | return; |
@@ -1035,10 +1030,11 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev) | |||
1035 | * the event. This time is enough for NEC protocol. May need adjustments | 1030 | * the event. This time is enough for NEC protocol. May need adjustments |
1036 | * to work with other protocols. | 1031 | * to work with other protocols. |
1037 | */ | 1032 | */ |
1038 | if (!ir->active) { | 1033 | smp_mb(); |
1034 | |||
1035 | if (!timer_pending(&ir->timer)) { | ||
1039 | timeout = jiffies + msecs_to_jiffies(15); | 1036 | timeout = jiffies + msecs_to_jiffies(15); |
1040 | mod_timer(&ir->timer, timeout); | 1037 | mod_timer(&ir->timer, timeout); |
1041 | ir->active = true; | ||
1042 | } | 1038 | } |
1043 | 1039 | ||
1044 | return 1; | 1040 | return 1; |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 89c8333736a2..c24b6512bd8f 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -130,7 +130,6 @@ struct saa7134_card_ir { | |||
130 | u32 mask_keycode, mask_keydown, mask_keyup; | 130 | u32 mask_keycode, mask_keydown, mask_keyup; |
131 | 131 | ||
132 | bool running; | 132 | bool running; |
133 | bool active; | ||
134 | 133 | ||
135 | struct timer_list timer; | 134 | struct timer_list timer; |
136 | 135 | ||