X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=sound%2Fcore%2Frtctimer.c;h=51e64e30dd3b6eea52b9d79908e3e50e333e7979;hb=4777e4e6b8540ee4226876a737833d03bbc55394;hp=c3c18568207e4f1a70bfd7bba7318dd69bb98660;hpb=8006fdd6dc387abaa4b683bda4868c879fd76070;p=linux-2.6-omap-h63xx.git diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c index c3c18568207..51e64e30dd3 100644 --- a/sound/core/rtctimer.c +++ b/sound/core/rtctimer.c @@ -20,15 +20,12 @@ * */ -#include #include -#include -#include #include #include +#include #include #include -#include #if defined(CONFIG_RTC) || defined(CONFIG_RTC_MODULE) @@ -40,17 +37,19 @@ /* * prototypes */ -static int rtctimer_open(snd_timer_t *t); -static int rtctimer_close(snd_timer_t *t); -static int rtctimer_start(snd_timer_t *t); -static int rtctimer_stop(snd_timer_t *t); +static int rtctimer_open(struct snd_timer *t); +static int rtctimer_close(struct snd_timer *t); +static int rtctimer_start(struct snd_timer *t); +static int rtctimer_stop(struct snd_timer *t); /* * The hardware dependent description for this timer. */ -static struct _snd_timer_hardware rtc_hw = { - .flags = SNDRV_TIMER_HW_FIRST|SNDRV_TIMER_HW_AUTO, +static struct snd_timer_hardware rtc_hw = { + .flags = SNDRV_TIMER_HW_AUTO | + SNDRV_TIMER_HW_FIRST | + SNDRV_TIMER_HW_TASKLET, .ticks = 100000000L, /* FIXME: XXX */ .open = rtctimer_open, .close = rtctimer_close, @@ -59,12 +58,13 @@ static struct _snd_timer_hardware rtc_hw = { }; static int rtctimer_freq = RTC_FREQ; /* frequency */ -static snd_timer_t *rtctimer; +static struct snd_timer *rtctimer; +static struct tasklet_struct rtc_tasklet; static rtc_task_t rtc_task; static int -rtctimer_open(snd_timer_t *t) +rtctimer_open(struct snd_timer *t) { int err; @@ -76,41 +76,49 @@ rtctimer_open(snd_timer_t *t) } static int -rtctimer_close(snd_timer_t *t) +rtctimer_close(struct snd_timer *t) { rtc_task_t *rtc = t->private_data; if (rtc) { rtc_unregister(rtc); + tasklet_kill(&rtc_tasklet); t->private_data = NULL; } return 0; } static int -rtctimer_start(snd_timer_t *timer) +rtctimer_start(struct snd_timer *timer) { rtc_task_t *rtc = timer->private_data; - snd_assert(rtc != NULL, return -EINVAL); + if (snd_BUG_ON(!rtc)) + return -EINVAL; rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq); rtc_control(rtc, RTC_PIE_ON, 0); return 0; } static int -rtctimer_stop(snd_timer_t *timer) +rtctimer_stop(struct snd_timer *timer) { rtc_task_t *rtc = timer->private_data; - snd_assert(rtc != NULL, return -EINVAL); + if (snd_BUG_ON(!rtc)) + return -EINVAL; rtc_control(rtc, RTC_PIE_OFF, 0); return 0; } +static void rtctimer_tasklet(unsigned long data) +{ + snd_timer_interrupt((struct snd_timer *)data, 1); +} + /* * interrupt */ static void rtctimer_interrupt(void *private_data) { - snd_timer_interrupt(private_data, 1); + tasklet_hi_schedule(private_data); } @@ -120,10 +128,10 @@ static void rtctimer_interrupt(void *private_data) static int __init rtctimer_init(void) { int err; - snd_timer_t *timer; + struct snd_timer *timer; if (rtctimer_freq < 2 || rtctimer_freq > 8192 || - (rtctimer_freq & (rtctimer_freq - 1)) != 0) { + !is_power_of_2(rtctimer_freq)) { snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); return -EINVAL; @@ -139,9 +147,11 @@ static int __init rtctimer_init(void) timer->hw = rtc_hw; timer->hw.resolution = NANO_SEC / rtctimer_freq; + tasklet_init(&rtc_tasklet, rtctimer_tasklet, (unsigned long)timer); + /* set up RTC callback */ rtc_task.func = rtctimer_interrupt; - rtc_task.private_data = timer; + rtc_task.private_data = &rtc_tasklet; err = snd_timer_global_register(timer); if (err < 0) { @@ -156,7 +166,7 @@ static int __init rtctimer_init(void) static void __exit rtctimer_exit(void) { if (rtctimer) { - snd_timer_global_unregister(rtctimer); + snd_timer_global_free(rtctimer); rtctimer = NULL; } }