aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/rtctimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/rtctimer.c')
-rw-r--r--sound/core/rtctimer.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c
index bd5d584d284d..c3c18568207e 100644
--- a/sound/core/rtctimer.c
+++ b/sound/core/rtctimer.c
@@ -60,7 +60,6 @@ static struct _snd_timer_hardware rtc_hw = {
60 60
61static int rtctimer_freq = RTC_FREQ; /* frequency */ 61static int rtctimer_freq = RTC_FREQ; /* frequency */
62static snd_timer_t *rtctimer; 62static snd_timer_t *rtctimer;
63static atomic_t rtc_inc = ATOMIC_INIT(0);
64static rtc_task_t rtc_task; 63static rtc_task_t rtc_task;
65 64
66 65
@@ -94,7 +93,6 @@ rtctimer_start(snd_timer_t *timer)
94 snd_assert(rtc != NULL, return -EINVAL); 93 snd_assert(rtc != NULL, return -EINVAL);
95 rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq); 94 rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq);
96 rtc_control(rtc, RTC_PIE_ON, 0); 95 rtc_control(rtc, RTC_PIE_ON, 0);
97 atomic_set(&rtc_inc, 0);
98 return 0; 96 return 0;
99} 97}
100 98
@@ -112,12 +110,7 @@ rtctimer_stop(snd_timer_t *timer)
112 */ 110 */
113static void rtctimer_interrupt(void *private_data) 111static void rtctimer_interrupt(void *private_data)
114{ 112{
115 int ticks; 113 snd_timer_interrupt(private_data, 1);
116
117 atomic_inc(&rtc_inc);
118 ticks = atomic_read(&rtc_inc);
119 snd_timer_interrupt((snd_timer_t*)private_data, ticks);
120 atomic_sub(ticks, &rtc_inc);
121} 114}
122 115
123 116
@@ -126,17 +119,13 @@ static void rtctimer_interrupt(void *private_data)
126 */ 119 */
127static int __init rtctimer_init(void) 120static int __init rtctimer_init(void)
128{ 121{
129 int order, err; 122 int err;
130 snd_timer_t *timer; 123 snd_timer_t *timer;
131 124
132 if (rtctimer_freq < 2 || rtctimer_freq > 8192) { 125 if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
133 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); 126 (rtctimer_freq & (rtctimer_freq - 1)) != 0) {
134 return -EINVAL; 127 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n",
135 } 128 rtctimer_freq);
136 for (order = 1; rtctimer_freq > order; order <<= 1)
137 ;
138 if (rtctimer_freq != order) {
139 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq);
140 return -EINVAL; 129 return -EINVAL;
141 } 130 }
142 131
@@ -145,6 +134,7 @@ static int __init rtctimer_init(void)
145 if (err < 0) 134 if (err < 0)
146 return err; 135 return err;
147 136
137 timer->module = THIS_MODULE;
148 strcpy(timer->name, "RTC timer"); 138 strcpy(timer->name, "RTC timer");
149 timer->hw = rtc_hw; 139 timer->hw = rtc_hw;
150 timer->hw.resolution = NANO_SEC / rtctimer_freq; 140 timer->hw.resolution = NANO_SEC / rtctimer_freq;