diff mbox series

[18/21] ASoC: SOF: Intel: add hda_bus_ml_free helper

Message ID 20221027193540.259520-19-pierre-louis.bossart@linux.intel.com (mailing list archive)
State Accepted
Commit 02785b892c2203c08d49811cc67be2775c4e1f32
Headers show
Series ASoC: SOF: Intel: HDA: refactor codec and multi-link suport | expand

Commit Message

Pierre-Louis Bossart Oct. 27, 2022, 7:35 p.m. UTC
Add helper matching allocation done in hda_bus_ml_get_capabilities().

No functionality change, just clearer code partitioning.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/soc/sof/intel/hda-mlink.c | 14 ++++++++++++++
 sound/soc/sof/intel/hda.c       |  5 ++---
 sound/soc/sof/intel/hda.h       |  2 ++
 3 files changed, 18 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/sof/intel/hda-mlink.c b/sound/soc/sof/intel/hda-mlink.c
index 2cdee03e4a47..76ab9a2e7bb3 100644
--- a/sound/soc/sof/intel/hda-mlink.c
+++ b/sound/soc/sof/intel/hda-mlink.c
@@ -34,6 +34,20 @@  void hda_bus_ml_get_capabilities(struct hdac_bus *bus)
 		snd_hdac_ext_bus_get_ml_capabilities(bus);
 }
 
+void hda_bus_ml_free(struct hdac_bus *bus)
+{
+	struct hdac_ext_link *hlink;
+
+	if (!bus->mlcap)
+		return;
+
+	while (!list_empty(&bus->hlink_list)) {
+		hlink = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list);
+		list_del(&hlink->list);
+		kfree(hlink);
+	}
+}
+
 void hda_bus_ml_put_all(struct hdac_bus *bus)
 {
 	struct hdac_ext_link *hlink;
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index aa56f2967edc..619179e7f15c 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -1201,9 +1201,8 @@  int hda_dsp_remove(struct snd_sof_dev *sdev)
 		pci_free_irq_vectors(pci);
 
 	hda_dsp_stream_free(sdev);
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
-	snd_hdac_ext_link_free_all(bus);
-#endif
+
+	hda_bus_ml_free(sof_to_bus(sdev));
 
 	iounmap(sdev->bar[HDA_DSP_BAR]);
 	iounmap(bus->remap_addr);
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
index f0c9bb6d567d..ea73fd17ae28 100644
--- a/sound/soc/sof/intel/hda.h
+++ b/sound/soc/sof/intel/hda.h
@@ -764,6 +764,7 @@  static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
 
 void hda_bus_ml_get_capabilities(struct hdac_bus *bus);
+void hda_bus_ml_free(struct hdac_bus *bus);
 void hda_bus_ml_put_all(struct hdac_bus *bus);
 void hda_bus_ml_reset_losidv(struct hdac_bus *bus);
 int hda_bus_ml_resume(struct hdac_bus *bus);
@@ -772,6 +773,7 @@  int hda_bus_ml_suspend(struct hdac_bus *bus);
 #else
 
 static inline void hda_bus_ml_get_capabilities(struct hdac_bus *bus) { }
+static inline void hda_bus_ml_free(struct hdac_bus *bus) { }
 static inline void hda_bus_ml_put_all(struct hdac_bus *bus) { }
 static inline void hda_bus_ml_reset_losidv(struct hdac_bus *bus) { }
 static inline int hda_bus_ml_resume(struct hdac_bus *bus) { return 0; }