ASoC: intel: sof_sdw: Move sdw_pin_index into private struct
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Fri, 15 Sep 2023 07:56:08 +0000 (15:56 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 15 Sep 2023 12:27:24 +0000 (13:27 +0100)
Whilst it should not cause any issues as only a single instance of the
machine will be instantiated, it is still slightly better practice to
keep working data in the private data structure, rather than a global
variable. Move sdw_pin_index into the mc_private structure.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230915075611.1619548-2-yung-chuan.liao@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 961241100012466613310a8f68d1d1368ad6bcb3..eaecdb75686c57807e6c28e85e59bcae7469e13e 100644 (file)
@@ -22,11 +22,6 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");
 
 #define INC_ID(BE, CPU, LINK)  do { (BE)++; (CPU)++; (LINK)++; } while (0)
 
-#define SDW_MAX_LINKS          4
-
-/* To store SDW Pin index for each SoundWire link */
-static unsigned int sdw_pin_index[SDW_MAX_LINKS];
-
 static void log_quirks(struct device *dev)
 {
        if (SOF_JACK_JDSRC(sof_sdw_quirk))
@@ -1331,6 +1326,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
                              int adr_index,
                              int dai_index)
 {
+       struct mc_private *ctx = snd_soc_card_get_drvdata(card);
        struct device *dev = card->dev;
        const struct snd_soc_acpi_link_adr *adr_link_next;
        struct snd_soc_dai_link_component *codecs;
@@ -1452,7 +1448,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
                for (k = 0; k < cpu_dai_num; k++) {
                        cpu_name = devm_kasprintf(dev, GFP_KERNEL,
                                                  "SDW%d Pin%d", cpu_dai_id[k],
-                                                 sdw_pin_index[cpu_dai_id[k]]++);
+                                                 ctx->sdw_pin_index[cpu_dai_id[k]]++);
                        if (!cpu_name)
                                return -ENOMEM;
 
@@ -1600,7 +1596,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
                goto SSP;
 
        for (i = 0; i < SDW_MAX_LINKS; i++)
-               sdw_pin_index[i] = SDW_INTEL_BIDIR_PDI_BASE;
+               ctx->sdw_pin_index[i] = SDW_INTEL_BIDIR_PDI_BASE;
 
        for (; adr_link->num_adr; adr_link++) {
                /*
index 2f4fe6bc3d5d061d5e65c2130d9e7884b759b3ad..270aded488e1ce6bb57900a0ab875b3cb20a3d2b 100644 (file)
@@ -24,6 +24,8 @@
 #define SDW_MAX_CPU_DAIS 16
 #define SDW_INTEL_BIDIR_PDI_BASE 2
 
+#define SDW_MAX_LINKS          4
+
 /* 8 combinations with 4 links + unused group 0 */
 #define SDW_MAX_GROUPS 9
 
@@ -97,6 +99,8 @@ struct mc_private {
        struct snd_soc_jack sdw_headset;
        struct device *headset_codec_dev; /* only one headset per card */
        struct device *amp_dev1, *amp_dev2;
+       /* To store SDW Pin index for each SoundWire link */
+       unsigned int sdw_pin_index[SDW_MAX_LINKS];
 };
 
 extern unsigned long sof_sdw_quirk;