Skip to content

Commit 38068d9

Browse files
ujfalusibroonie
authored andcommitted
ASoC: Intel: sof_sdw: Allocate snd_soc_card dynamically
The static card_sof_sdw struct is modified during runtime and in case the module is not removed, but the card is, then the next time the card is created the card_sof_sdw will contain information from the previous card which might lead to hard to debug issues, side effects. Move the snd_soc_card into mc_private and use that to make sure that the card is initialized correctly. Reviewed-by: Bard Liao <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6d33911 commit 38068d9

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

sound/soc/intel/boards/sof_sdw.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,12 +1882,6 @@ static int sof_sdw_card_late_probe(struct snd_soc_card *card)
18821882
/* SoC card */
18831883
static const char sdw_card_long_name[] = "Intel Soundwire SOF";
18841884

1885-
static struct snd_soc_card card_sof_sdw = {
1886-
.name = "soundwire",
1887-
.owner = THIS_MODULE,
1888-
.late_probe = sof_sdw_card_late_probe,
1889-
};
1890-
18911885
/* helper to get the link that the codec DAI is used */
18921886
static struct snd_soc_dai_link *mc_find_codec_dai_used(struct snd_soc_card *card,
18931887
const char *dai_name)
@@ -1939,20 +1933,24 @@ static void mc_dailink_exit_loop(struct snd_soc_card *card)
19391933

19401934
static int mc_probe(struct platform_device *pdev)
19411935
{
1942-
struct snd_soc_card *card = &card_sof_sdw;
19431936
struct snd_soc_acpi_mach *mach = dev_get_platdata(&pdev->dev);
1937+
struct snd_soc_card *card;
19441938
struct mc_private *ctx;
19451939
int amp_num = 0, i;
19461940
int ret;
19471941

1948-
card->dev = &pdev->dev;
1949-
1950-
dev_dbg(card->dev, "Entry\n");
1942+
dev_dbg(&pdev->dev, "Entry\n");
19511943

1952-
ctx = devm_kzalloc(card->dev, sizeof(*ctx), GFP_KERNEL);
1944+
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
19531945
if (!ctx)
19541946
return -ENOMEM;
19551947

1948+
card = &ctx->card;
1949+
card->dev = &pdev->dev;
1950+
card->name = "soundwire",
1951+
card->owner = THIS_MODULE,
1952+
card->late_probe = sof_sdw_card_late_probe,
1953+
19561954
snd_soc_card_set_drvdata(card, ctx);
19571955

19581956
dmi_check_system(sof_sdw_quirk_table);

sound/soc/intel/boards/sof_sdw_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct sof_sdw_codec_info {
101101
};
102102

103103
struct mc_private {
104+
struct snd_soc_card card;
104105
struct snd_soc_jack sdw_headset;
105106
struct sof_hdmi_private hdmi;
106107
struct device *headset_codec_dev; /* only one headset per card */

0 commit comments

Comments
 (0)