[PATCH v4 32/32] sound: soc: soc-usb: Rediscover USB SND devices on USB port add

From: Wesley Cheng
Date: Mon Jul 24 2023 - 22:36:40 EST


In case the USB backend device has not been initialized/probed, USB SND
device connections can still occur. When the USB backend is eventually
made available, previous USB SND device connections are not communicated to
the USB backend. Call snd_usb_rediscover_devices() to generate the connect
callbacks for all USB SND devices connected. This will allow for the USB
backend to be updated with the current set of devices available.

Signed-off-by: Wesley Cheng <quic_wcheng@xxxxxxxxxxx>
---
sound/soc/soc-usb.c | 2 ++
sound/usb/card.h | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c
index 84dc6d0b2eab..a9413e3d18df 100644
--- a/sound/soc/soc-usb.c
+++ b/sound/soc/soc-usb.c
@@ -111,6 +111,8 @@ struct snd_soc_usb *snd_soc_usb_add_port(struct device *dev, void *priv,
list_add_tail(&usb->list, &usb_ctx_list);
mutex_unlock(&ctx_mutex);

+ snd_usb_rediscover_devices();
+
return usb;
}
EXPORT_SYMBOL_GPL(snd_soc_usb_add_port);
diff --git a/sound/usb/card.h b/sound/usb/card.h
index dfd241334e3d..6a14b74b47da 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -236,6 +236,7 @@ static struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx,
{
return NULL;
}
-void snd_usb_rediscover_devices(void) { }
+
+static void snd_usb_rediscover_devices(void) { }
#endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */
#endif /* __USBAUDIO_CARD_H */