aboutsummaryrefslogtreecommitdiffstats
path: root/sound
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
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')
-rw-r--r--sound/core/rtctimer.c4
-rw-r--r--sound/core/timer.c7
2 files changed, 7 insertions, 4 deletions
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c
index 8762ff8938c2..c3c18568207e 100644
--- a/sound/core/rtctimer.c
+++ b/sound/core/rtctimer.c
@@ -124,7 +124,8 @@ static int __init rtctimer_init(void)
124 124
125 if (rtctimer_freq < 2 || rtctimer_freq > 8192 || 125 if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
126 (rtctimer_freq & (rtctimer_freq - 1)) != 0) { 126 (rtctimer_freq & (rtctimer_freq - 1)) != 0) {
127 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", rtctimer_freq); 127 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n",
128 rtctimer_freq);
128 return -EINVAL; 129 return -EINVAL;
129 } 130 }
130 131
@@ -133,6 +134,7 @@ static int __init rtctimer_init(void)
133 if (err < 0) 134 if (err < 0)
134 return err; 135 return err;
135 136
137 timer->module = THIS_MODULE;
136 strcpy(timer->name, "RTC timer"); 138 strcpy(timer->name, "RTC timer");
137 timer->hw = rtc_hw; 139 timer->hw = rtc_hw;
138 timer->hw.resolution = NANO_SEC / rtctimer_freq; 140 timer->hw.resolution = NANO_SEC / rtctimer_freq;
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;