mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 13:23:35 -04:00
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 <yung-chuan.liao@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20240426152123.36284-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
6d339113df
commit
38068d91cf
@@ -1882,12 +1882,6 @@ static int sof_sdw_card_late_probe(struct snd_soc_card *card)
|
||||
/* SoC card */
|
||||
static const char sdw_card_long_name[] = "Intel Soundwire SOF";
|
||||
|
||||
static struct snd_soc_card card_sof_sdw = {
|
||||
.name = "soundwire",
|
||||
.owner = THIS_MODULE,
|
||||
.late_probe = sof_sdw_card_late_probe,
|
||||
};
|
||||
|
||||
/* helper to get the link that the codec DAI is used */
|
||||
static struct snd_soc_dai_link *mc_find_codec_dai_used(struct snd_soc_card *card,
|
||||
const char *dai_name)
|
||||
@@ -1939,20 +1933,24 @@ static void mc_dailink_exit_loop(struct snd_soc_card *card)
|
||||
|
||||
static int mc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = &card_sof_sdw;
|
||||
struct snd_soc_acpi_mach *mach = dev_get_platdata(&pdev->dev);
|
||||
struct snd_soc_card *card;
|
||||
struct mc_private *ctx;
|
||||
int amp_num = 0, i;
|
||||
int ret;
|
||||
|
||||
card->dev = &pdev->dev;
|
||||
dev_dbg(&pdev->dev, "Entry\n");
|
||||
|
||||
dev_dbg(card->dev, "Entry\n");
|
||||
|
||||
ctx = devm_kzalloc(card->dev, sizeof(*ctx), GFP_KERNEL);
|
||||
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
card = &ctx->card;
|
||||
card->dev = &pdev->dev;
|
||||
card->name = "soundwire",
|
||||
card->owner = THIS_MODULE,
|
||||
card->late_probe = sof_sdw_card_late_probe,
|
||||
|
||||
snd_soc_card_set_drvdata(card, ctx);
|
||||
|
||||
dmi_check_system(sof_sdw_quirk_table);
|
||||
|
||||
@@ -101,6 +101,7 @@ struct sof_sdw_codec_info {
|
||||
};
|
||||
|
||||
struct mc_private {
|
||||
struct snd_soc_card card;
|
||||
struct snd_soc_jack sdw_headset;
|
||||
struct sof_hdmi_private hdmi;
|
||||
struct device *headset_codec_dev; /* only one headset per card */
|
||||
|
||||
Reference in New Issue
Block a user