]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ASoC: Intel: sof_sdw: Avoid NULL check fail when re-probing
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Mon, 5 May 2025 14:14:09 +0000 (15:14 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 5 May 2025 22:48:39 +0000 (07:48 +0900)
The static platform_component name string is overwritten on card tear
down by sof_link_unload(). After this has happened the NULL check
on it in asoc_sdw_init_simple_dai_link() will fail when the driver
is reprobed, causing the machine driver to fail probe. However, it
also turns out that the ASoC core sets this string for all topology
systems in soc_check_tplg_fes() anyway, after the aforementioned
NULL check. So there is no need for the machine driver to set
the platform name to anything meaningful at all.

Replace all the platform_component stuff with some simple place
holders and importantly since the core tampers with the
snd_soc_dai_link_component in multiple places allocate a new one
for each usage.

Fixes: 59f8b622d52e ("ASoC: intel/sdw_utils: refactor init_dai_link() and init_simple_dai_link()")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20250505141409.2614010-3-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/sof_sdw.c

index 29b813943cccbf9ca41b03235cfd2bce3db2c4ab..51b29ebdf4052bc721d4b1dff6b89ee305f2affb 100644 (file)
@@ -780,13 +780,6 @@ static void sof_sdw_check_ssid_quirk(const struct snd_soc_acpi_mach *mach)
                sof_sdw_quirk = quirk_entry->value;
 }
 
-static struct snd_soc_dai_link_component platform_component[] = {
-       {
-               /* name might be overridden during probe */
-               .name = "0000:00:1f.3"
-       }
-};
-
 static const struct snd_soc_ops sdw_ops = {
        .startup = asoc_sdw_startup,
        .prepare = asoc_sdw_prepare,
@@ -836,6 +829,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
                struct snd_soc_dai_link_ch_map *codec_maps;
                struct snd_soc_dai_link_component *codecs;
                struct snd_soc_dai_link_component *cpus;
+               struct snd_soc_dai_link_component *platform;
                int num_cpus = hweight32(sof_dai->link_mask[stream]);
                int num_codecs = sof_dai->num_devs[stream];
                int playback, capture;
@@ -876,6 +870,10 @@ static int create_sdw_dailink(struct snd_soc_card *card,
                if (!codecs)
                        return -ENOMEM;
 
+               platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
+               if (!platform)
+                       return -ENOMEM;
+
                codec_maps = devm_kcalloc(dev, num_codecs, sizeof(*codec_maps), GFP_KERNEL);
                if (!codec_maps)
                        return -ENOMEM;
@@ -917,8 +915,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
                capture = (stream == SNDRV_PCM_STREAM_CAPTURE);
 
                asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, playback, capture,
-                                      cpus, num_cpus, platform_component,
-                                      ARRAY_SIZE(platform_component), codecs, num_codecs,
+                                      cpus, num_cpus, platform, 1, codecs, num_codecs,
                                       1, asoc_sdw_rtd_init, &sdw_ops);
 
                /*
@@ -994,7 +991,7 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
 
                ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
                                                    playback, capture, cpu_dai_name,
-                                                   platform_component->name, codec_name,
+                                                   "dummy", codec_name,
                                                    ssp_info->dais[0].dai_name, 1, NULL,
                                                    ssp_info->ops);
                if (ret)
@@ -1018,7 +1015,7 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
 
        ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic01",
                                            0, 1, // DMIC only supports capture
-                                           "DMIC01 Pin", platform_component->name,
+                                           "DMIC01 Pin", "dummy",
                                            "dmic-codec", "dmic-hifi", 1,
                                            asoc_sdw_dmic_init, NULL);
        if (ret)
@@ -1028,7 +1025,7 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
 
        ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic16k",
                                            0, 1, // DMIC only supports capture
-                                           "DMIC16k Pin", platform_component->name,
+                                           "DMIC16k Pin", "dummy",
                                            "dmic-codec", "dmic-hifi", 1,
                                            /* don't call asoc_sdw_dmic_init() twice */
                                            NULL, NULL);
@@ -1071,7 +1068,7 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
 
                ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
                                                    1, 0, // HDMI only supports playback
-                                                   cpu_dai_name, platform_component->name,
+                                                   cpu_dai_name, "dummy",
                                                    codec_name, codec_dai_name, 1,
                                                    i == 0 ? sof_sdw_hdmi_init : NULL, NULL);
                if (ret)
@@ -1097,7 +1094,7 @@ static int create_bt_dailinks(struct snd_soc_card *card,
        int ret;
 
        ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
-                                           1, 1, cpu_dai_name, platform_component->name,
+                                           1, 1, cpu_dai_name, "dummy",
                                            snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
                                            1, NULL, NULL);
        if (ret)