aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/hrtimer.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /sound/core/hrtimer.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'sound/core/hrtimer.c')
-rw-r--r--sound/core/hrtimer.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sound/core/hrtimer.c b/sound/core/hrtimer.c
index 34c7d48f5061..7730575bfadd 100644
--- a/sound/core/hrtimer.c
+++ b/sound/core/hrtimer.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
24#include <linux/hrtimer.h> 25#include <linux/hrtimer.h>
@@ -37,14 +38,22 @@ static unsigned int resolution;
37struct snd_hrtimer { 38struct snd_hrtimer {
38 struct snd_timer *timer; 39 struct snd_timer *timer;
39 struct hrtimer hrt; 40 struct hrtimer hrt;
41 atomic_t running;
40}; 42};
41 43
42static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) 44static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
43{ 45{
44 struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt); 46 struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt);
45 struct snd_timer *t = stime->timer; 47 struct snd_timer *t = stime->timer;
48
49 if (!atomic_read(&stime->running))
50 return HRTIMER_NORESTART;
51
46 hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution)); 52 hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
47 snd_timer_interrupt(stime->timer, t->sticks); 53 snd_timer_interrupt(stime->timer, t->sticks);
54
55 if (!atomic_read(&stime->running))
56 return HRTIMER_NORESTART;
48 return HRTIMER_RESTART; 57 return HRTIMER_RESTART;
49} 58}
50 59
@@ -58,6 +67,7 @@ static int snd_hrtimer_open(struct snd_timer *t)
58 hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 67 hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
59 stime->timer = t; 68 stime->timer = t;
60 stime->hrt.function = snd_hrtimer_callback; 69 stime->hrt.function = snd_hrtimer_callback;
70 atomic_set(&stime->running, 0);
61 t->private_data = stime; 71 t->private_data = stime;
62 return 0; 72 return 0;
63} 73}
@@ -78,16 +88,18 @@ static int snd_hrtimer_start(struct snd_timer *t)
78{ 88{
79 struct snd_hrtimer *stime = t->private_data; 89 struct snd_hrtimer *stime = t->private_data;
80 90
91 atomic_set(&stime->running, 0);
92 hrtimer_cancel(&stime->hrt);
81 hrtimer_start(&stime->hrt, ns_to_ktime(t->sticks * resolution), 93 hrtimer_start(&stime->hrt, ns_to_ktime(t->sticks * resolution),
82 HRTIMER_MODE_REL); 94 HRTIMER_MODE_REL);
95 atomic_set(&stime->running, 1);
83 return 0; 96 return 0;
84} 97}
85 98
86static int snd_hrtimer_stop(struct snd_timer *t) 99static int snd_hrtimer_stop(struct snd_timer *t)
87{ 100{
88 struct snd_hrtimer *stime = t->private_data; 101 struct snd_hrtimer *stime = t->private_data;
89 102 atomic_set(&stime->running, 0);
90 hrtimer_cancel(&stime->hrt);
91 return 0; 103 return 0;
92} 104}
93 105