]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ASoC: Intel: sof_sdw: Allocate snd_soc_card dynamically
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Fri, 26 Apr 2024 15:21:17 +0000 (10:21 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 29 Apr 2024 15:10:02 +0000 (00:10 +0900)
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>
sound/soc/intel/boards/sof_sdw.c
sound/soc/intel/boards/sof_sdw_common.h

index d65c5da49000a6e69ff4154a90cd124612c208a0..384c3d41a9adc51055c248701323ace4635661bd 100644 (file)
@@ -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);
index 89253938ebaaa280f73904be8158fe1b9e3f479d..853278c6e5250714ec9d8d480a39609031e6c553 100644 (file)
@@ -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 */