Commit 89da061f authored by Takashi Iwai's avatar Takashi Iwai

ALSA: timer: Handle the device directly

This is a relatively straightforward change, using the struct device
directly for managing the ALSA timer device.
Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7c35860d
...@@ -1951,6 +1951,8 @@ static void snd_timer_free_all(void) ...@@ -1951,6 +1951,8 @@ static void snd_timer_free_all(void)
snd_timer_free(timer); snd_timer_free(timer);
} }
static struct device timer_dev;
/* /*
* ENTRY functions * ENTRY functions
*/ */
...@@ -1959,6 +1961,9 @@ static int __init alsa_timer_init(void) ...@@ -1959,6 +1961,9 @@ static int __init alsa_timer_init(void)
{ {
int err; int err;
snd_device_initialize(&timer_dev, NULL);
dev_set_name(&timer_dev, "timer");
#ifdef SNDRV_OSS_INFO_DEV_TIMERS #ifdef SNDRV_OSS_INFO_DEV_TIMERS
snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1, snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1,
"system timer"); "system timer");
...@@ -1967,14 +1972,17 @@ static int __init alsa_timer_init(void) ...@@ -1967,14 +1972,17 @@ static int __init alsa_timer_init(void)
err = snd_timer_register_system(); err = snd_timer_register_system();
if (err < 0) { if (err < 0) {
pr_err("ALSA: unable to register system timer (%i)\n", err); pr_err("ALSA: unable to register system timer (%i)\n", err);
put_device(&timer_dev);
return err; return err;
} }
err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_TIMER, NULL, 0,
&snd_timer_f_ops, NULL, "timer"); &snd_timer_f_ops, NULL,
&timer_dev, NULL, NULL);
if (err < 0) { if (err < 0) {
pr_err("ALSA: unable to register timer device (%i)\n", err); pr_err("ALSA: unable to register timer device (%i)\n", err);
snd_timer_free_all(); snd_timer_free_all();
put_device(&timer_dev);
return err; return err;
} }
...@@ -1986,6 +1994,7 @@ static void __exit alsa_timer_exit(void) ...@@ -1986,6 +1994,7 @@ static void __exit alsa_timer_exit(void)
{ {
snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0); snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0);
snd_timer_free_all(); snd_timer_free_all();
put_device(&timer_dev);
snd_timer_proc_done(); snd_timer_proc_done();
#ifdef SNDRV_OSS_INFO_DEV_TIMERS #ifdef SNDRV_OSS_INFO_DEV_TIMERS
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1); snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment