diff mbox series

[2/7] ASoC: soc-link: move soc_rtd_xxx()

Message ID 874ksc68lo.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: add soc-link | expand

Commit Message

Kuninori Morimoto May 19, 2020, 1:01 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

dai_link related function should be implemented at soc-link.c.
This patch moves soc-pcm soc_rtd_xxx() to soc-link as snd_soc_link_xxx()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-link.h | 13 ++++++++
 sound/soc/soc-link.c     | 65 ++++++++++++++++++++++++++++++++++++
 sound/soc/soc-pcm.c      | 72 +++++-----------------------------------
 3 files changed, 87 insertions(+), 63 deletions(-)
diff mbox series

Patch

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
index 7fc5cead5942..689aa93be78e 100644
--- a/include/sound/soc-link.h
+++ b/include/sound/soc-link.h
@@ -9,5 +9,18 @@ 
 #define __SOC_LINK_H
 
 int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream);
+void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream);
+int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream);
+int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params);
+void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd,
+			  struct snd_pcm_substream *substream);
+int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream, int cmd);
 
 #endif /* __SOC_LINK_H */
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
index 4bdd8d0dd93a..be6a6ecfc9dc 100644
--- a/sound/soc/soc-link.c
+++ b/sound/soc/soc-link.c
@@ -34,3 +34,68 @@  int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
 
 	return soc_link_ret(rtd, ret);
 }
+
+int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->startup)
+		ret = rtd->dai_link->ops->startup(substream);
+
+	return soc_link_ret(rtd, ret);
+}
+
+void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream)
+{
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->shutdown)
+		rtd->dai_link->ops->shutdown(substream);
+}
+
+int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->prepare)
+		ret = rtd->dai_link->ops->prepare(substream);
+
+	return soc_link_ret(rtd, ret);
+}
+
+int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->hw_params)
+		ret = rtd->dai_link->ops->hw_params(substream, params);
+
+	return soc_link_ret(rtd, ret);
+}
+
+void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd,
+			  struct snd_pcm_substream *substream)
+{
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->hw_free)
+		rtd->dai_link->ops->hw_free(substream);
+}
+
+int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream, int cmd)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->trigger)
+		ret = rtd->dai_link->ops->trigger(substream, cmd);
+
+	return soc_link_ret(rtd, ret);
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index b7899da4217e..20857145bd6d 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -202,60 +202,6 @@  static inline void dpcm_remove_debugfs_state(struct snd_soc_dpcm *dpcm)
 }
 #endif
 
-static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->startup)
-		return rtd->dai_link->ops->startup(substream);
-	return 0;
-}
-
-static void soc_rtd_shutdown(struct snd_soc_pcm_runtime *rtd,
-			     struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->shutdown)
-		rtd->dai_link->ops->shutdown(substream);
-}
-
-static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->prepare)
-		return rtd->dai_link->ops->prepare(substream);
-	return 0;
-}
-
-static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd,
-			     struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->hw_params)
-		return rtd->dai_link->ops->hw_params(substream, params);
-	return 0;
-}
-
-static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd,
-			    struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->hw_free)
-		rtd->dai_link->ops->hw_free(substream);
-}
-
-static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream,
-			   int cmd)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->trigger)
-		return rtd->dai_link->ops->trigger(substream, cmd);
-	return 0;
-}
-
 /**
  * snd_soc_runtime_action() - Increment/Decrement active count for
  * PCM runtime components
@@ -736,7 +682,7 @@  static int soc_pcm_close(struct snd_pcm_substream *substream)
 	for_each_rtd_dais(rtd, i, dai)
 		snd_soc_dai_shutdown(dai, substream);
 
-	soc_rtd_shutdown(rtd, substream);
+	snd_soc_link_shutdown(rtd, substream);
 
 	soc_pcm_components_close(substream);
 
@@ -783,7 +729,7 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 	if (ret < 0)
 		goto component_err;
 
-	ret = soc_rtd_startup(rtd, substream);
+	ret = snd_soc_link_startup(rtd, substream);
 	if (ret < 0) {
 		pr_err("ASoC: %s startup failed: %d\n",
 		       rtd->dai_link->name, ret);
@@ -870,7 +816,7 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 	for_each_rtd_dais(rtd, i, dai)
 		snd_soc_dai_shutdown(dai, substream);
 
-	soc_rtd_shutdown(rtd, substream);
+	snd_soc_link_shutdown(rtd, substream);
 rtd_startup_err:
 	soc_pcm_components_close(substream);
 component_err:
@@ -912,7 +858,7 @@  static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	ret = soc_rtd_prepare(rtd, substream);
+	ret = snd_soc_link_prepare(rtd, substream);
 	if (ret < 0) {
 		dev_err(rtd->card->dev,
 			"ASoC: machine prepare error: %d\n", ret);
@@ -1002,7 +948,7 @@  static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 	if (ret)
 		goto out;
 
-	ret = soc_rtd_hw_params(rtd, substream, params);
+	ret = snd_soc_link_hw_params(rtd, substream, params);
 	if (ret < 0) {
 		dev_err(rtd->card->dev,
 			"ASoC: machine hw_params failed: %d\n", ret);
@@ -1117,7 +1063,7 @@  static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 		codec_dai->rate = 0;
 	}
 
-	soc_rtd_hw_free(rtd, substream);
+	snd_soc_link_hw_free(rtd, substream);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
@@ -1149,7 +1095,7 @@  static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	}
 
 	/* free any machine hw params */
-	soc_rtd_hw_free(rtd, substream);
+	snd_soc_link_hw_free(rtd, substream);
 
 	/* free any component resources */
 	soc_pcm_components_hw_free(substream, NULL);
@@ -1172,7 +1118,7 @@  static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
 	struct snd_soc_component *component;
 	int i, ret;
 
-	ret = soc_rtd_trigger(rtd, substream, cmd);
+	ret = snd_soc_link_trigger(rtd, substream, cmd);
 	if (ret < 0)
 		return ret;
 
@@ -1201,7 +1147,7 @@  static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
 			return ret;
 	}
 
-	ret = soc_rtd_trigger(rtd, substream, cmd);
+	ret = snd_soc_link_trigger(rtd, substream, cmd);
 	if (ret < 0)
 		return ret;