Blob Blame History Raw
From 536aba1dd4939bf647f5d182d4f101ae548e6505 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Thu, 4 Jun 2020 17:06:32 +0900
Subject: [PATCH] ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c
Git-commit: 536aba1dd4939bf647f5d182d4f101ae548e6505
Patch-mainline: v5.9-rc1
References: jsc#SLE-16518

snd_soc_component_xxx() should be implemented at soc-component.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87r1uvw8zb.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 include/sound/soc-component.h |  4 ++++
 sound/soc/soc-component.c     | 16 ++++++++++++++++
 sound/soc/soc-core.c          | 29 ++++++++---------------------
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 481132141dc2..cb0d34fa77c6 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -324,6 +324,10 @@ static inline int snd_soc_component_cache_sync(
 	return regcache_sync(component->regmap);
 }
 
+int snd_soc_component_initialize(struct snd_soc_component *component,
+				 const struct snd_soc_component_driver *driver,
+				 struct device *dev, const char *name);
+
 /* component IO */
 int snd_soc_component_read(struct snd_soc_component *component,
 			   unsigned int reg, unsigned int *val);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 3c96a1adaa8b..5bf2e71d3d83 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -8,6 +8,22 @@
 #include <linux/module.h>
 #include <sound/soc.h>
 
+int snd_soc_component_initialize(struct snd_soc_component *component,
+				 const struct snd_soc_component_driver *driver,
+				 struct device *dev, const char *name)
+{
+	INIT_LIST_HEAD(&component->dai_list);
+	INIT_LIST_HEAD(&component->dobj_list);
+	INIT_LIST_HEAD(&component->card_list);
+	mutex_init(&component->io_mutex);
+
+	component->name		= name;
+	component->dev		= dev;
+	component->driver	= driver;
+
+	return 0;
+}
+
 /**
  * snd_soc_component_set_sysclk - configure COMPONENT system or master clock.
  * @component: COMPONENT
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 13a59736b2fc..e596e5a765da 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2378,26 +2378,6 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
 	return ret;
 }
 
-static int snd_soc_component_initialize(struct snd_soc_component *component,
-	const struct snd_soc_component_driver *driver, struct device *dev)
-{
-	INIT_LIST_HEAD(&component->dai_list);
-	INIT_LIST_HEAD(&component->dobj_list);
-	INIT_LIST_HEAD(&component->card_list);
-	mutex_init(&component->io_mutex);
-
-	component->name = fmt_single_name(dev, &component->id);
-	if (!component->name) {
-		dev_err(dev, "ASoC: Failed to allocate name\n");
-		return -ENOMEM;
-	}
-
-	component->dev = dev;
-	component->driver = driver;
-
-	return 0;
-}
-
 #define ENDIANNESS_MAP(name) \
 	(SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE)
 static u64 endianness_format_map[] = {
@@ -2460,12 +2440,19 @@ int snd_soc_add_component(struct device *dev,
 			struct snd_soc_dai_driver *dai_drv,
 			int num_dai)
 {
+	const char *name = fmt_single_name(dev, &component->id);
 	int ret;
 	int i;
 
+	if (!name) {
+		dev_err(dev, "ASoC: Failed to allocate name\n");
+		return -ENOMEM;
+	}
+
 	mutex_lock(&client_mutex);
 
-	ret = snd_soc_component_initialize(component, component_driver, dev);
+	ret = snd_soc_component_initialize(component, component_driver,
+					   dev, name);
 	if (ret)
 		goto err_free;
 
-- 
2.16.4