[PATCH 4/5] ASoC: simple-card: fix probe failure on platform component

Robert Hancock robert.hancock at calian.com
Wed Jan 5 23:51:45 CET 2022


A previous change to simple-card resulted in asoc_simple_parse_dai
attempting to retrieve the dai_name for platform components, which are
unlikely to have a valid DAI name. This caused simple-card to fail to
probe when using the xlnx_formatter_pcm as the platform component, since
it does not register any DAI components.

Since the dai_name is not used for platform components, just skip trying
to retrieve it for those.

Fixes: f107294c6422 ("ASoC: simple-card: support snd_soc_dai_link_component style for cpu")
Signed-off-by: Robert Hancock <robert.hancock at calian.com>
---
 sound/soc/generic/simple-card.c | 52 ++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index a89d1cfdda32..1295836e04f4 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -30,6 +30,7 @@ static const struct snd_soc_ops simple_ops = {
 
 static int asoc_simple_parse_dai(struct device_node *node,
 				 struct snd_soc_dai_link_component *dlc,
+				 bool is_plat,
 				 int *is_single_link)
 {
 	struct of_phandle_args args;
@@ -46,28 +47,31 @@ static int asoc_simple_parse_dai(struct device_node *node,
 	if (ret)
 		return ret;
 
-	/*
-	 * FIXME
-	 *
-	 * Here, dlc->dai_name is pointer to CPU/Codec DAI name.
-	 * If user unbinded CPU or Codec driver, but not for Sound Card,
-	 * dlc->dai_name is keeping unbinded CPU or Codec
-	 * driver's pointer.
-	 *
-	 * If user re-bind CPU or Codec driver again, ALSA SoC will try
-	 * to rebind Card via snd_soc_try_rebind_card(), but because of
-	 * above reason, it might can't bind Sound Card.
-	 * Because Sound Card is pointing to released dai_name pointer.
-	 *
-	 * To avoid this rebind Card issue,
-	 * 1) It needs to alloc memory to keep dai_name eventhough
-	 *    CPU or Codec driver was unbinded, or
-	 * 2) user need to rebind Sound Card everytime
-	 *    if he unbinded CPU or Codec.
-	 */
-	ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
-	if (ret < 0)
-		return ret;
+	/* dai_name is not required and may not exist for plat component */
+	if (!is_plat) {
+		/*
+		 * FIXME
+		 *
+		 * Here, dlc->dai_name is pointer to CPU/Codec DAI name.
+		 * If user unbinded CPU or Codec driver, but not for Sound Card,
+		 * dlc->dai_name is keeping unbinded CPU or Codec
+		 * driver's pointer.
+		 *
+		 * If user re-bind CPU or Codec driver again, ALSA SoC will try
+		 * to rebind Card via snd_soc_try_rebind_card(), but because of
+		 * above reason, it might can't bind Sound Card.
+		 * Because Sound Card is pointing to released dai_name pointer.
+		 *
+		 * To avoid this rebind Card issue,
+		 * 1) It needs to alloc memory to keep dai_name eventhough
+		 *    CPU or Codec driver was unbinded, or
+		 * 2) user need to rebind Sound Card everytime
+		 *    if he unbinded CPU or Codec.
+		 */
+		ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
+		if (ret < 0)
+			return ret;
+	}
 
 	dlc->of_node = args.np;
 
@@ -134,7 +138,7 @@ static int simple_parse_node(struct asoc_simple_priv *priv,
 
 	simple_parse_mclk_fs(top, np, dai_props, prefix);
 
-	ret = asoc_simple_parse_dai(np, dlc, cpu);
+	ret = asoc_simple_parse_dai(np, dlc, false, cpu);
 	if (ret)
 		return ret;
 
@@ -289,7 +293,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
 	if (ret < 0)
 		goto dai_link_of_err;
 
-	ret = asoc_simple_parse_dai(plat, platforms, NULL);
+	ret = asoc_simple_parse_dai(plat, platforms, true, NULL);
 	if (ret < 0)
 		goto dai_link_of_err;
 
-- 
2.31.1



More information about the Alsa-devel mailing list