提交 a55fc44f 编写于 作者: T Takashi Iwai 提交者: Jialin Zhang

ALSA: usb-audio: Inform the delayed registration more properly

stable inclusion
from stable-v5.10.143
commit 1d29a63585b3344137ceeaf19f5a3bfd222f7c9e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0U6

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1d29a63585b3344137ceeaf19f5a3bfd222f7c9e

--------------------------------

[ Upstream commit 7e1afce5 ]

The info message that was added in the commit a4aad563 ("ALSA:
usb-audio: Inform devices that need delayed registration") is actually
useful to know the need for the delayed registration.  However, it
turned out that this doesn't catch the all cases; namely, this warned
only when a PCM stream is attached onto the existing PCM instance, but
it doesn't count for a newly created PCM instance.  This made
confusion as if there were no further delayed registration.

This patch moves the check to the code path for either adding a stream
or creating a PCM instance.  Also, make it simpler by checking the
card->registered flag instead of querying each snd_device state.

Fixes: a4aad563 ("ALSA: usb-audio: Inform devices that need delayed registration")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216082
Link: https://lore.kernel.org/r/20220831125901.4660-1-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 1cd42a28
...@@ -496,6 +496,10 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip, ...@@ -496,6 +496,10 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,
return 0; return 0;
} }
} }
if (chip->card->registered)
chip->need_delayed_register = true;
/* look for an empty stream */ /* look for an empty stream */
list_for_each_entry(as, &chip->pcm_list, list) { list_for_each_entry(as, &chip->pcm_list, list) {
if (as->fmt_type != fp->fmt_type) if (as->fmt_type != fp->fmt_type)
...@@ -503,9 +507,6 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip, ...@@ -503,9 +507,6 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,
subs = &as->substream[stream]; subs = &as->substream[stream];
if (subs->ep_num) if (subs->ep_num)
continue; continue;
if (snd_device_get_state(chip->card, as->pcm) !=
SNDRV_DEV_BUILD)
chip->need_delayed_register = true;
err = snd_pcm_new_stream(as->pcm, stream, 1); err = snd_pcm_new_stream(as->pcm, stream, 1);
if (err < 0) if (err < 0)
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册