summaryrefslogtreecommitdiff
path: root/sound/core/timer.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-03 19:57:16 +0300
committerTakashi Iwai <tiwai@suse.de>2015-02-03 19:57:16 +0300
commit3fe9cf390f6dc84f76b112b0a660967a84f9a81b (patch)
tree18b8573687ae8131db155aa791f4d2357d91e6c5 /sound/core/timer.c
parent6ccd93bdb989507717edb375d40534f1177822c5 (diff)
parent830953c0724b42be30a74febcde6c89c706ed286 (diff)
downloadlinux-3fe9cf390f6dc84f76b112b0a660967a84f9a81b.tar.xz
Merge branch 'topic/snd-device' into for-next
Diffstat (limited to 'sound/core/timer.c')
-rw-r--r--sound/core/timer.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/sound/core/timer.c b/sound/core/timer.c
index a44235555896..490b489d713d 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1940,6 +1940,17 @@ static const struct file_operations snd_timer_f_ops =
.fasync = snd_timer_user_fasync,
};
+/* unregister the system timer */
+static void snd_timer_free_all(void)
+{
+ struct snd_timer *timer, *n;
+
+ list_for_each_entry_safe(timer, n, &snd_timer_list, device_list)
+ snd_timer_free(timer);
+}
+
+static struct device timer_dev;
+
/*
* ENTRY functions
*/
@@ -1948,30 +1959,39 @@ static int __init alsa_timer_init(void)
{
int err;
+ snd_device_initialize(&timer_dev, NULL);
+ dev_set_name(&timer_dev, "timer");
+
#ifdef SNDRV_OSS_INFO_DEV_TIMERS
snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1,
"system timer");
#endif
- if ((err = snd_timer_register_system()) < 0)
+ err = snd_timer_register_system();
+ if (err < 0) {
pr_err("ALSA: unable to register system timer (%i)\n", err);
- if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0,
- &snd_timer_f_ops, NULL, "timer")) < 0)
+ put_device(&timer_dev);
+ return err;
+ }
+
+ err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0,
+ &snd_timer_f_ops, NULL, &timer_dev);
+ if (err < 0) {
pr_err("ALSA: unable to register timer device (%i)\n", err);
+ snd_timer_free_all();
+ put_device(&timer_dev);
+ return err;
+ }
+
snd_timer_proc_init();
return 0;
}
static void __exit alsa_timer_exit(void)
{
- struct list_head *p, *n;
-
- snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0);
- /* unregister the system timer */
- list_for_each_safe(p, n, &snd_timer_list) {
- struct snd_timer *timer = list_entry(p, struct snd_timer, device_list);
- snd_timer_free(timer);
- }
+ snd_unregister_device(&timer_dev);
+ snd_timer_free_all();
+ put_device(&timer_dev);
snd_timer_proc_done();
#ifdef SNDRV_OSS_INFO_DEV_TIMERS
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1);