Skip to content

Commit cd71865

Browse files
committed
ASoC: Intel: sof_sdw: Avoid overwrite of platform_component
The platform_component name string potentially being overwritten during probe can cause subsequent probes to fail. Make a local copy of the platform_component and use that when it might get overwritten. Fixes: 52db12d ("ASoC: Intel: boards: add sof_sdw machine driver") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
1 parent 7612b72 commit cd71865

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

sound/soc/intel/boards/sof_sdw.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,8 @@ static void sof_sdw_check_ssid_quirk(const struct snd_soc_acpi_mach *mach)
799799
sof_sdw_quirk = quirk_entry->value;
800800
}
801801

802-
static struct snd_soc_dai_link_component platform_component[] = {
803-
{
804-
/* name might be overridden during probe */
805-
.name = "0000:00:1f.3"
806-
}
802+
static struct snd_soc_dai_link_component platform_component = {
803+
.name = "0000:00:1f.3"
807804
};
808805

809806
static const struct snd_soc_ops sdw_ops = {
@@ -936,8 +933,8 @@ static int create_sdw_dailink(struct snd_soc_card *card,
936933
capture = (stream == SNDRV_PCM_STREAM_CAPTURE);
937934

938935
asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, playback, capture,
939-
cpus, num_cpus, platform_component,
940-
ARRAY_SIZE(platform_component), codecs, num_codecs,
936+
cpus, num_cpus, &intel_ctx->platform_component,
937+
1, codecs, num_codecs,
941938
1, asoc_sdw_rtd_init, &sdw_ops);
942939

943940
/*
@@ -1013,7 +1010,7 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
10131010

10141011
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
10151012
playback, capture, cpu_dai_name,
1016-
platform_component->name, codec_name,
1013+
platform_component.name, codec_name,
10171014
ssp_info->dais[0].dai_name, 1, NULL,
10181015
ssp_info->ops);
10191016
if (ret)
@@ -1037,7 +1034,7 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
10371034

10381035
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic01",
10391036
0, 1, // DMIC only supports capture
1040-
"DMIC01 Pin", platform_component->name,
1037+
"DMIC01 Pin", platform_component.name,
10411038
"dmic-codec", "dmic-hifi", 1,
10421039
asoc_sdw_dmic_init, NULL);
10431040
if (ret)
@@ -1047,7 +1044,7 @@ static int create_dmic_dailinks(struct snd_soc_card *card,
10471044

10481045
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, "dmic16k",
10491046
0, 1, // DMIC only supports capture
1050-
"DMIC16k Pin", platform_component->name,
1047+
"DMIC16k Pin", platform_component.name,
10511048
"dmic-codec", "dmic-hifi", 1,
10521049
/* don't call asoc_sdw_dmic_init() twice */
10531050
NULL, NULL);
@@ -1090,7 +1087,7 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
10901087

10911088
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
10921089
1, 0, // HDMI only supports playback
1093-
cpu_dai_name, platform_component->name,
1090+
cpu_dai_name, platform_component.name,
10941091
codec_name, codec_dai_name, 1,
10951092
i == 0 ? sof_sdw_hdmi_init : NULL, NULL);
10961093
if (ret)
@@ -1116,7 +1113,7 @@ static int create_bt_dailinks(struct snd_soc_card *card,
11161113
int ret;
11171114

11181115
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
1119-
1, 1, cpu_dai_name, platform_component->name,
1116+
1, 1, cpu_dai_name, platform_component.name,
11201117
snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
11211118
1, NULL, NULL);
11221119
if (ret)
@@ -1314,6 +1311,8 @@ static int mc_probe(struct platform_device *pdev)
13141311
if (!intel_ctx)
13151312
return -ENOMEM;
13161313

1314+
intel_ctx->platform_component = platform_component;
1315+
13171316
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
13181317
if (!ctx)
13191318
return -ENOMEM;

sound/soc/intel/boards/sof_sdw_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum {
5454

5555
struct intel_mc_ctx {
5656
struct sof_hdmi_private hdmi;
57+
struct snd_soc_dai_link_component platform_component;
5758
/* To store SDW Pin index for each SoundWire link */
5859
unsigned int sdw_pin_index[SDW_INTEL_MAX_LINKS];
5960
};

0 commit comments

Comments
 (0)