Unverified Commit 38068d91 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown
Browse files

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: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: default avatarPierre-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: default avatarMark Brown <broonie@kernel.org>
parent 6d339113
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -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(card->dev, "Entry\n");
	dev_dbg(&pdev->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);
+1 −0
Original line number Diff line number Diff line
@@ -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 */