Skip to content

Commit 6c965d3

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: Intel: sof_sdw: Avoid NULL check fail when re-probing
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: 59f8b62 ("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>
1 parent 8ce5ace commit 6c965d3

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

sound/soc/intel/boards/sof_sdw.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,6 @@ static void sof_sdw_check_ssid_quirk(const struct snd_soc_acpi_mach *mach)
780780
sof_sdw_quirk = quirk_entry->value;
781781
}
782782

783-
static struct snd_soc_dai_link_component platform_component[] = {
784-
{
785-
/* name might be overridden during probe */
786-
.name = "0000:00:1f.3"
787-
}
788-
};
789-
790783
static const struct snd_soc_ops sdw_ops = {
791784
.startup = asoc_sdw_startup,
792785
.prepare = asoc_sdw_prepare,
@@ -836,6 +829,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
836829
struct snd_soc_dai_link_ch_map *codec_maps;
837830
struct snd_soc_dai_link_component *codecs;
838831
struct snd_soc_dai_link_component *cpus;
832+
struct snd_soc_dai_link_component *platform;
839833
int num_cpus = hweight32(sof_dai->link_mask[stream]);
840834
int num_codecs = sof_dai->num_devs[stream];
841835
int playback, capture;
@@ -876,6 +870,10 @@ static int create_sdw_dailink(struct snd_soc_card *card,
876870
if (!codecs)
877871
return -ENOMEM;
878872

873+
platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
874+
if (!platform)
875+
return -ENOMEM;
876+
879877
codec_maps = devm_kcalloc(dev, num_codecs, sizeof(*codec_maps), GFP_KERNEL);
880878
if (!codec_maps)
881879
return -ENOMEM;
@@ -917,8 +915,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
917915
capture = (stream == SNDRV_PCM_STREAM_CAPTURE);
918916

919917
asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, playback, capture,
920-
cpus, num_cpus, platform_component,
921-
ARRAY_SIZE(platform_component), codecs, num_codecs,
918+
cpus, num_cpus, platform, 1, codecs, num_codecs,
922919
1, asoc_sdw_rtd_init, &sdw_ops);
923920

924921
/*
@@ -994,7 +991,7 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
994991

995992
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
996993
playback, capture, cpu_dai_name,
997-
platform_component->name, codec_name,
994+
"dummy", codec_name,
998995
ssp_info->dais[0].dai_name, 1, NULL,
999996
ssp_info->ops);
1000997
if (ret)
@@ -1018,7 +1015,7 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
10181015

10191016
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic01",
10201017
0, 1, // DMIC only supports capture
1021-
"DMIC01 Pin", platform_component->name,
1018+
"DMIC01 Pin", "dummy",
10221019
"dmic-codec", "dmic-hifi", 1,
10231020
asoc_sdw_dmic_init, NULL);
10241021
if (ret)
@@ -1028,7 +1025,7 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
10281025

10291026
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic16k",
10301027
0, 1, // DMIC only supports capture
1031-
"DMIC16k Pin", platform_component->name,
1028+
"DMIC16k Pin", "dummy",
10321029
"dmic-codec", "dmic-hifi", 1,
10331030
/* don't call asoc_sdw_dmic_init() twice */
10341031
NULL, NULL);
@@ -1071,7 +1068,7 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
10711068

10721069
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
10731070
1, 0, // HDMI only supports playback
1074-
cpu_dai_name, platform_component->name,
1071+
cpu_dai_name, "dummy",
10751072
codec_name, codec_dai_name, 1,
10761073
i == 0 ? sof_sdw_hdmi_init : NULL, NULL);
10771074
if (ret)
@@ -1097,7 +1094,7 @@ static int create_bt_dailinks(struct snd_soc_card *card,
10971094
int ret;
10981095

10991096
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
1100-
1, 1, cpu_dai_name, platform_component->name,
1097+
1, 1, cpu_dai_name, "dummy",
11011098
snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
11021099
1, NULL, NULL);
11031100
if (ret)

0 commit comments

Comments
 (0)