[ALSA] Unregister device files at disconnection
Orignally proposed by Sam Revitch <sam.revitch@gmail.com>. Unregister device files at disconnection to avoid the futher accesses. Also, the dev_unregister callback is removed and replaced with the combination of disconnect + free. A new function snd_card_free_when_closed() is introduced, which is used in USB disconnect callback. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
This commit is contained in:
committed by
Jaroslav Kysela
parent
746d4a02e6
commit
c461482c80
@@ -1310,21 +1310,19 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
|
||||
card->mixer_oss = mixer;
|
||||
snd_mixer_oss_build(mixer);
|
||||
snd_mixer_oss_proc_init(mixer);
|
||||
} else if (cmd == SND_MIXER_OSS_NOTIFY_DISCONNECT) {
|
||||
mixer = card->mixer_oss;
|
||||
if (mixer == NULL || !mixer->oss_dev_alloc)
|
||||
return 0;
|
||||
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, mixer->card, 0);
|
||||
mixer->oss_dev_alloc = 0;
|
||||
} else { /* free */
|
||||
} else {
|
||||
mixer = card->mixer_oss;
|
||||
if (mixer == NULL)
|
||||
return 0;
|
||||
if (mixer->oss_dev_alloc) {
|
||||
#ifdef SNDRV_OSS_INFO_DEV_MIXERS
|
||||
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_MIXERS, mixer->card->number);
|
||||
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_MIXERS, mixer->card->number);
|
||||
#endif
|
||||
if (mixer->oss_dev_alloc)
|
||||
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, mixer->card, 0);
|
||||
mixer->oss_dev_alloc = 0;
|
||||
}
|
||||
if (cmd == SND_MIXER_OSS_NOTIFY_DISCONNECT)
|
||||
return 0;
|
||||
snd_mixer_oss_proc_done(mixer);
|
||||
return snd_mixer_oss_free1(mixer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user