aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/timer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-10-12 11:12:31 -0400
committerJaroslav Kysela <perex@suse.cz>2005-11-04 07:18:43 -0500
commitde24214d0c8e78134875752619f99b9e5824c196 (patch)
tree147f8cdcf5dfb3be2d95409f7ac44af101d2e0a5 /sound/core/timer.c
parent2fd43d1159d22395aae01836c4b13ee5265a9b6b (diff)
[ALSA] timers: add module refcounting for global timers
Modules: RTC timer driver,Timer Midlevel Add a module pointer to the timer structure and use it for refcounting instead of the card's module pointer to prevent the global timer modules (rtctimer and hpetimer) from being removed while in use. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/core/timer.c')
-rw-r--r--sound/core/timer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sound/core/timer.c b/sound/core/timer.c
index b02681eaea75..c8496c7b8df8 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -113,7 +113,7 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *ti
113 INIT_LIST_HEAD(&timeri->slave_active_head); 113 INIT_LIST_HEAD(&timeri->slave_active_head);
114 114
115 timeri->timer = timer; 115 timeri->timer = timer;
116 if (timer && timer->card && !try_module_get(timer->card->module)) { 116 if (timer && !try_module_get(timer->module)) {
117 kfree(timeri->owner); 117 kfree(timeri->owner);
118 kfree(timeri); 118 kfree(timeri);
119 return NULL; 119 return NULL;
@@ -363,8 +363,8 @@ int snd_timer_close(snd_timer_instance_t * timeri)
363 timeri->private_free(timeri); 363 timeri->private_free(timeri);
364 kfree(timeri->owner); 364 kfree(timeri->owner);
365 kfree(timeri); 365 kfree(timeri);
366 if (timer && timer->card) 366 if (timer)
367 module_put(timer->card->module); 367 module_put(timer->module);
368 return 0; 368 return 0;
369} 369}
370 370
@@ -787,6 +787,7 @@ int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, snd_timer_t *
787 spin_lock_init(&timer->lock); 787 spin_lock_init(&timer->lock);
788 tasklet_init(&timer->task_queue, snd_timer_tasklet, (unsigned long)timer); 788 tasklet_init(&timer->task_queue, snd_timer_tasklet, (unsigned long)timer);
789 if (card != NULL) { 789 if (card != NULL) {
790 timer->module = card->module;
790 if ((err = snd_device_new(card, SNDRV_DEV_TIMER, timer, &ops)) < 0) { 791 if ((err = snd_device_new(card, SNDRV_DEV_TIMER, timer, &ops)) < 0) {
791 snd_timer_free(timer); 792 snd_timer_free(timer);
792 return err; 793 return err;