Skip to content

Commit 89da061

Browse files
committed
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: Jaroslav Kysela <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 7c35860 commit 89da061

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sound/core/timer.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,8 @@ static void snd_timer_free_all(void)
19511951
snd_timer_free(timer);
19521952
}
19531953

1954+
static struct device timer_dev;
1955+
19541956
/*
19551957
* ENTRY functions
19561958
*/
@@ -1959,6 +1961,9 @@ static int __init alsa_timer_init(void)
19591961
{
19601962
int err;
19611963

1964+
snd_device_initialize(&timer_dev, NULL);
1965+
dev_set_name(&timer_dev, "timer");
1966+
19621967
#ifdef SNDRV_OSS_INFO_DEV_TIMERS
19631968
snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1,
19641969
"system timer");
@@ -1967,14 +1972,17 @@ static int __init alsa_timer_init(void)
19671972
err = snd_timer_register_system();
19681973
if (err < 0) {
19691974
pr_err("ALSA: unable to register system timer (%i)\n", err);
1975+
put_device(&timer_dev);
19701976
return err;
19711977
}
19721978

1973-
err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0,
1974-
&snd_timer_f_ops, NULL, "timer");
1979+
err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_TIMER, NULL, 0,
1980+
&snd_timer_f_ops, NULL,
1981+
&timer_dev, NULL, NULL);
19751982
if (err < 0) {
19761983
pr_err("ALSA: unable to register timer device (%i)\n", err);
19771984
snd_timer_free_all();
1985+
put_device(&timer_dev);
19781986
return err;
19791987
}
19801988

@@ -1986,6 +1994,7 @@ static void __exit alsa_timer_exit(void)
19861994
{
19871995
snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0);
19881996
snd_timer_free_all();
1997+
put_device(&timer_dev);
19891998
snd_timer_proc_done();
19901999
#ifdef SNDRV_OSS_INFO_DEV_TIMERS
19912000
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1);

0 commit comments

Comments
 (0)