[3/7] ASoC: soc-link: remove unneeded parameter from snd_soc_link_xxx()

Message ID 87367w68la.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series
  • [1/7] ASoC: add soc-link.c
Related show

Commit Message

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

"rtd" can be created from "substream".
Let's cleanup snd_soc_link_xxx().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-link.h | 18 ++++++------------
 sound/soc/soc-link.c     | 26 ++++++++++++++------------
 sound/soc/soc-pcm.c      | 18 +++++++++---------
 3 files changed, 29 insertions(+), 33 deletions(-)

Patch

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
index 689aa93be78e..2a81dca945cd 100644
--- a/include/sound/soc-link.h
+++ b/include/sound/soc-link.h
@@ -9,18 +9,12 @@ 
 #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,
+int snd_soc_link_startup(struct snd_pcm_substream *substream);
+void snd_soc_link_shutdown(struct snd_pcm_substream *substream);
+int snd_soc_link_prepare(struct snd_pcm_substream *substream);
+int snd_soc_link_hw_params(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);
+void snd_soc_link_hw_free(struct snd_pcm_substream *substream);
+int snd_soc_link_trigger(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 be6a6ecfc9dc..691910e82bff 100644
--- a/sound/soc/soc-link.c
+++ b/sound/soc/soc-link.c
@@ -35,9 +35,9 @@  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 snd_soc_link_startup(struct snd_pcm_substream *substream)
 {
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int ret = 0;
 
 	if (rtd->dai_link->ops &&
@@ -47,17 +47,18 @@  int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd,
 	return soc_link_ret(rtd, ret);
 }
 
-void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream)
+void snd_soc_link_shutdown(struct snd_pcm_substream *substream)
 {
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
 	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 snd_soc_link_prepare(struct snd_pcm_substream *substream)
 {
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int ret = 0;
 
 	if (rtd->dai_link->ops &&
@@ -67,10 +68,10 @@  int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd,
 	return soc_link_ret(rtd, ret);
 }
 
-int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream,
+int snd_soc_link_hw_params(struct snd_pcm_substream *substream,
 			   struct snd_pcm_hw_params *params)
 {
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int ret = 0;
 
 	if (rtd->dai_link->ops &&
@@ -80,17 +81,18 @@  int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd,
 	return soc_link_ret(rtd, ret);
 }
 
-void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd,
-			  struct snd_pcm_substream *substream)
+void snd_soc_link_hw_free(struct snd_pcm_substream *substream)
 {
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
 	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 snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd)
 {
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	int ret = 0;
 
 	if (rtd->dai_link->ops &&
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 20857145bd6d..2b5068001efb 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -682,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);
 
-	snd_soc_link_shutdown(rtd, substream);
+	snd_soc_link_shutdown(substream);
 
 	soc_pcm_components_close(substream);
 
@@ -729,7 +729,7 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 	if (ret < 0)
 		goto component_err;
 
-	ret = snd_soc_link_startup(rtd, substream);
+	ret = snd_soc_link_startup(substream);
 	if (ret < 0) {
 		pr_err("ASoC: %s startup failed: %d\n",
 		       rtd->dai_link->name, ret);
@@ -816,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);
 
-	snd_soc_link_shutdown(rtd, substream);
+	snd_soc_link_shutdown(substream);
 rtd_startup_err:
 	soc_pcm_components_close(substream);
 component_err:
@@ -858,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 = snd_soc_link_prepare(rtd, substream);
+	ret = snd_soc_link_prepare(substream);
 	if (ret < 0) {
 		dev_err(rtd->card->dev,
 			"ASoC: machine prepare error: %d\n", ret);
@@ -948,7 +948,7 @@  static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 	if (ret)
 		goto out;
 
-	ret = snd_soc_link_hw_params(rtd, substream, params);
+	ret = snd_soc_link_hw_params(substream, params);
 	if (ret < 0) {
 		dev_err(rtd->card->dev,
 			"ASoC: machine hw_params failed: %d\n", ret);
@@ -1063,7 +1063,7 @@  static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 		codec_dai->rate = 0;
 	}
 
-	snd_soc_link_hw_free(rtd, substream);
+	snd_soc_link_hw_free(substream);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
@@ -1095,7 +1095,7 @@  static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	}
 
 	/* free any machine hw params */
-	snd_soc_link_hw_free(rtd, substream);
+	snd_soc_link_hw_free(substream);
 
 	/* free any component resources */
 	soc_pcm_components_hw_free(substream, NULL);
@@ -1118,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 = snd_soc_link_trigger(rtd, substream, cmd);
+	ret = snd_soc_link_trigger(substream, cmd);
 	if (ret < 0)
 		return ret;
 
@@ -1147,7 +1147,7 @@  static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
 			return ret;
 	}
 
-	ret = snd_soc_link_trigger(rtd, substream, cmd);
+	ret = snd_soc_link_trigger(substream, cmd);
 	if (ret < 0)
 		return ret;