All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 0/x] ASoC: replace platform to component
@ 2017-06-20  2:25 Kuninori Morimoto
  2017-06-20  2:26 ` [RFC][PATCH 1/x] ASoC: snd_soc_component_driver has snd_pcm_ops Kuninori Morimoto
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-20  2:25 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA


Hi Mark, Lars-Peter

Now, we can replace "platform" to "component".
It will be large patch-set. To avoid many posting big-patch-set,
I will post few of then as example.

1) - 2) : prepare for last missing parts for replace
3) - 4) : example of replace patch
5)      : remove platform

Kuninori Morimoto (xx):
      1) ASoC: snd_soc_component_driver has snd_pcm_ops
      2) ASoC: snd_soc_component_driver has snd_compr_ops
      3) ASoC: replace platform to component on sh/rcar
      4) ASoC: replace platform to component on sst-xxx
      5) ASoC: remove platform related things

Big change of this replace are
 1) snd_soc_lookup_platform() will be snd_soc_lookup_component()
 2) debugfs_create_file("platform", xxx) will be debugfs_create_file("component", xxx)
 3) remove platform_list

1st Note is that it is still using rtd->platform_com style.
I guess it will be removed or replaced in the future, but it is not
this patch-set purpose.

2nd Note is that, as you can see, above example is merging few
components into 1 component.
Almost all cases, 1 component is for register DAI, 1 component is
for register platform. I think we can merge these into 1 component.

I have 1 concern. Current snd_soc_unregister_component() is checking
"dev" only. This means, 1 device : 1 component can only be correctly handled.
I don't know detail, but below case, maybe works.

	snd_soc_register_component(dev, driver_A);
	snd_soc_register_component(dev, driver_B);

	snd_soc_unregister_component(dev);
	snd_soc_unregister_component(dev);

I think we want to have "driver" parameter on unregister, like

	snd_soc_unregister_component(dev, driver_A);
	snd_soc_unregister_component(dev, driver_B);

For example, tegra sound driver is registering its component, and
snd_dmaengine_pcm_register() which register its component.
One headache is that snd_dmaengine_pcm_unregister() is using
snd_soc_lookup_platform() which will be replaced to
snd_soc_lookup_component(). And its parameter is only "dev".

We want to have below
	snd_soc_lookup_component(dev, driver);
	snd_soc_unregister_component(dev, driver);

Can I replace current unregister before "replace platform" patch set ?
(= many drivers are using it)

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC][PATCH 1/x] ASoC: snd_soc_component_driver has snd_pcm_ops
  2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
@ 2017-06-20  2:26 ` Kuninori Morimoto
  2017-06-20  2:27 ` [RFC][PATCH 2/x] ASoC: snd_soc_component_driver has snd_compr_ops Kuninori Morimoto
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-20  2:26 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA

snd_soc_platform_driver has snd_pcm_ops,
and it will be replaced into snd_soc_component_driver in the future.
To prepare it, component driver has it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h             |  5 ++-
 sound/soc/davinci/davinci-i2s.c | 15 +++++++--
 sound/soc/soc-core.c            | 23 ++++++++++---
 sound/soc/soc-pcm.c             | 71 +++++++++++++++++++++++++++++++++++------
 4 files changed, 97 insertions(+), 17 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9c94b97..341a958 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -809,6 +809,8 @@ struct snd_soc_component_driver {
 		int subseq);
 	int (*stream_event)(struct snd_soc_component *, int event);
 
+	const struct snd_pcm_ops *ops;
+
 	/* probe ordering - for components with runtime dependencies */
 	int probe_order;
 	int remove_order;
@@ -1230,7 +1232,8 @@ struct snd_soc_pcm_runtime {
 	struct snd_pcm *pcm;
 	struct snd_compr *compr;
 	struct snd_soc_codec *codec;
-	struct snd_soc_platform *platform;
+	struct snd_soc_platform *platform; /* will be removed */
+	struct snd_soc_component *platform_com;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai;
 
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 3849616..a90b954 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -191,6 +191,7 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
 	u32 spcr;
 	u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST;
@@ -211,7 +212,12 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev,
 	if (playback) {
 		/* Stop the DMA to avoid data loss */
 		/* while the transmitter is out of reset to handle XSYNCERR */
-		if (platform->driver->ops->trigger) {
+		if (platform_com->driver->ops->trigger) {
+			int ret = platform_com->driver->ops->trigger(substream,
+				SNDRV_PCM_TRIGGER_STOP);
+			if (ret < 0)
+				printk(KERN_DEBUG "Playback DMA stop failed\n");
+		} else if (platform->driver->ops->trigger) {
 			int ret = platform->driver->ops->trigger(substream,
 				SNDRV_PCM_TRIGGER_STOP);
 			if (ret < 0)
@@ -233,7 +239,12 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev,
 		toggle_clock(dev, playback);
 
 		/* Restart the DMA */
-		if (platform->driver->ops->trigger) {
+		if (platform_com->driver->ops->trigger) {
+			int ret = platform_com->driver->ops->trigger(substream,
+				SNDRV_PCM_TRIGGER_START);
+			if (ret < 0)
+				printk(KERN_DEBUG "Playback DMA start failed\n");
+		} else if (platform->driver->ops->trigger) {
 			int ret = platform->driver->ops->trigger(substream,
 				SNDRV_PCM_TRIGGER_START);
 			if (ret < 0)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cfa9cf1..95ab9f6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1100,6 +1100,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 		}
 
 		rtd->platform = platform;
+		rtd->platform_com = &platform->component;
 	}
 	if (!rtd->platform) {
 		dev_err(card->dev, "ASoC: platform %s not registered\n",
@@ -1172,11 +1173,14 @@ static void soc_remove_link_components(struct snd_soc_card *card,
 {
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_component *component;
 	int i;
 
 	/* remove the platform */
-	if (platform && platform->component.driver->remove_order == order)
+	if (platform_com && platform_com->driver->remove_order == order)
+		soc_remove_component(platform_com);
+	else if (platform && platform->component.driver->remove_order == order)
 		soc_remove_component(&platform->component);
 
 	/* remove the CODEC-side CODEC */
@@ -1543,6 +1547,7 @@ static int soc_probe_link_components(struct snd_soc_card *card,
 				     int order)
 {
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_component *component;
 	int i, ret;
 
@@ -1565,7 +1570,11 @@ static int soc_probe_link_components(struct snd_soc_card *card,
 	}
 
 	/* probe the platform */
-	if (platform->component.driver->probe_order == order) {
+	if (platform_com->driver->probe_order == order) {
+		ret = soc_probe_component(card, platform_com);
+		if (ret < 0)
+			return ret;
+	} else if (platform->component.driver->probe_order == order) {
 		ret = soc_probe_component(card, &platform->component);
 		if (ret < 0)
 			return ret;
@@ -3332,8 +3341,11 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
 static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 
-	if (platform->driver->pcm_new)
+	if (platform_com->driver->pcm_new)
+		return platform_com->driver->pcm_new(rtd);
+	else if (platform->driver->pcm_new)
 		return platform->driver->pcm_new(rtd);
 	else
 		return 0;
@@ -3343,8 +3355,11 @@ static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
 {
 	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 
-	if (platform->driver->pcm_free)
+	if (platform_com->driver->pcm_free)
+		platform_com->driver->pcm_free(pcm);
+	else if (platform->driver->pcm_free)
 		platform->driver->pcm_free(pcm);
 }
 
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index efc5831..6d919e6 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -450,6 +450,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	const char *codec_dai_name = "multicodec";
@@ -475,7 +476,14 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 		}
 	}
 
-	if (platform->driver->ops && platform->driver->ops->open) {
+	if (platform_com->driver->ops && platform_com->driver->ops->open) {
+		ret = platform_com->driver->ops->open(substream);
+		if (ret < 0) {
+			dev_err(platform_com->dev, "ASoC: can't open platform"
+				" %s: %d\n", platform_com->name, ret);
+			goto platform_err;
+		}
+	} else if (platform->driver->ops && platform->driver->ops->open) {
 		ret = platform->driver->ops->open(substream);
 		if (ret < 0) {
 			dev_err(platform->dev, "ASoC: can't open platform"
@@ -590,7 +598,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 			codec_dai->driver->ops->shutdown(substream, codec_dai);
 	}
 
-	if (platform->driver->ops && platform->driver->ops->close)
+	if (platform_com->driver->ops && platform_com->driver->ops->close)
+		platform_com->driver->ops->close(substream);
+	else if (platform->driver->ops && platform->driver->ops->close)
 		platform->driver->ops->close(substream);
 
 platform_err:
@@ -655,6 +665,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	int i;
@@ -687,7 +698,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 	if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown)
 		rtd->dai_link->ops->shutdown(substream);
 
-	if (platform->driver->ops && platform->driver->ops->close)
+	if (platform_com->driver->ops && platform_com->driver->ops->close)
+		platform_com->driver->ops->close(substream);
+	else if (platform->driver->ops && platform->driver->ops->close)
 		platform->driver->ops->close(substream);
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -741,6 +754,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	int i, ret = 0;
@@ -756,7 +770,14 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 		}
 	}
 
-	if (platform->driver->ops && platform->driver->ops->prepare) {
+	if (platform_com->driver->ops && platform_com->driver->ops->prepare) {
+		ret = platform_com->driver->ops->prepare(substream);
+		if (ret < 0) {
+			dev_err(platform_com->dev, "ASoC: platform prepare error:"
+				" %d\n", ret);
+			goto out;
+		}
+	} else if (platform->driver->ops && platform->driver->ops->prepare) {
 		ret = platform->driver->ops->prepare(substream);
 		if (ret < 0) {
 			dev_err(platform->dev, "ASoC: platform prepare error:"
@@ -847,6 +868,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int i, ret = 0;
 
@@ -911,7 +933,14 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 	if (ret < 0)
 		goto interface_err;
 
-	if (platform->driver->ops && platform->driver->ops->hw_params) {
+	if (platform_com->driver->ops && platform_com->driver->ops->hw_params) {
+		ret = platform_com->driver->ops->hw_params(substream, params);
+		if (ret < 0) {
+			dev_err(platform_com->dev, "ASoC: %s hw params failed: %d\n",
+				platform_com->name, ret);
+			goto platform_err;
+		}
+	} else if (platform->driver->ops && platform->driver->ops->hw_params) {
 		ret = platform->driver->ops->hw_params(substream, params);
 		if (ret < 0) {
 			dev_err(platform->dev, "ASoC: %s hw params failed: %d\n",
@@ -959,6 +988,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
@@ -995,7 +1025,9 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 		rtd->dai_link->ops->hw_free(substream);
 
 	/* free any DMA resources */
-	if (platform->driver->ops && platform->driver->ops->hw_free)
+	if (platform_com->driver->ops && platform_com->driver->ops->hw_free)
+		platform_com->driver->ops->hw_free(substream);
+	else if (platform->driver->ops && platform->driver->ops->hw_free)
 		platform->driver->ops->hw_free(substream);
 
 	/* now free hw params for the DAIs  */
@@ -1016,6 +1048,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	int i, ret;
@@ -1030,7 +1063,11 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		}
 	}
 
-	if (platform->driver->ops && platform->driver->ops->trigger) {
+	if (platform_com->driver->ops && platform_com->driver->ops->trigger) {
+		ret = platform_com->driver->ops->trigger(substream, cmd);
+		if (ret < 0)
+			return ret;
+	} else if (platform->driver->ops && platform->driver->ops->trigger) {
 		ret = platform->driver->ops->trigger(substream, cmd);
 		if (ret < 0)
 			return ret;
@@ -1086,6 +1123,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1094,7 +1132,9 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 	snd_pcm_sframes_t codec_delay = 0;
 	int i;
 
-	if (platform->driver->ops && platform->driver->ops->pointer)
+	if (platform_com->driver->ops && platform_com->driver->ops->pointer)
+		offset = platform_com->driver->ops->pointer(substream);
+	else if (platform->driver->ops && platform->driver->ops->pointer)
 		offset = platform->driver->ops->pointer(substream);
 
 	if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay)
@@ -2281,9 +2321,13 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 
-	if (platform->driver->ops && platform->driver->ops->ioctl)
+	if (platform_com->driver->ops && platform_com->driver->ops->ioctl)
+		return platform_com->driver->ops->ioctl(substream, cmd, arg);
+	else if (platform->driver->ops && platform->driver->ops->ioctl)
 		return platform->driver->ops->ioctl(substream, cmd, arg);
+
 	return snd_pcm_lib_ioctl(substream, cmd, arg);
 }
 
@@ -2644,6 +2688,7 @@ static void soc_pcm_free(struct snd_pcm *pcm)
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_component *component;
@@ -2741,7 +2786,13 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 		rtd->ops.ioctl		= soc_pcm_ioctl;
 	}
 
-	if (platform->driver->ops) {
+	if (platform_com->driver->ops) {
+		rtd->ops.ack		= platform_com->driver->ops->ack;
+		rtd->ops.copy		= platform_com->driver->ops->copy;
+		rtd->ops.silence	= platform_com->driver->ops->silence;
+		rtd->ops.page		= platform_com->driver->ops->page;
+		rtd->ops.mmap		= platform_com->driver->ops->mmap;
+	} else if (platform->driver->ops) {
 		rtd->ops.ack		= platform->driver->ops->ack;
 		rtd->ops.copy		= platform->driver->ops->copy;
 		rtd->ops.silence	= platform->driver->ops->silence;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC][PATCH 2/x] ASoC: snd_soc_component_driver has snd_compr_ops
  2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
  2017-06-20  2:26 ` [RFC][PATCH 1/x] ASoC: snd_soc_component_driver has snd_pcm_ops Kuninori Morimoto
@ 2017-06-20  2:27 ` Kuninori Morimoto
  2017-06-20  2:27 ` [RFC][PATCH 3/x] ASoC: replace platform to component on sh/rcar Kuninori Morimoto
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-20  2:27 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA

snd_soc_platform_driver has snd_compr_ops,
and it will be replaced into snd_soc_component_driver in the future.
To prepare it, component driver has it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h      |   1 +
 sound/soc/soc-compress.c | 116 +++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 97 insertions(+), 20 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 341a958..8ebfb53 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -810,6 +810,7 @@ struct snd_soc_component_driver {
 	int (*stream_event)(struct snd_soc_component *, int event);
 
 	const struct snd_pcm_ops *ops;
+	const struct snd_compr_ops *compr_ops;
 
 	/* probe ordering - for components with runtime dependencies */
 	int probe_order;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index bfd71b8..61ebc1e 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -30,6 +30,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
@@ -44,7 +45,14 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 		}
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->open) {
+		ret = platform_com->driver->compr_ops->open(cstream);
+		if (ret < 0) {
+			pr_err("compress asoc: can't open platform %s\n",
+			       platform_com->name);
+			goto plat_err;
+		}
+	} else if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
 		ret = platform->driver->compr_ops->open(cstream);
 		if (ret < 0) {
 			pr_err("compress asoc: can't open platform %s\n",
@@ -68,7 +76,9 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	return 0;
 
 machine_err:
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
+		platform_com->driver->compr_ops->free(cstream);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 plat_err:
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -83,6 +93,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	struct snd_soc_dpcm *dpcm;
 	struct snd_soc_dapm_widget_list *list;
@@ -106,7 +117,14 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	}
 
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->open) {
+		ret = platform_com->driver->compr_ops->open(cstream);
+		if (ret < 0) {
+			pr_err("compress asoc: can't open platform %s\n",
+			       platform_com->name);
+			goto plat_err;
+		}
+	} else if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
 		ret = platform->driver->compr_ops->open(cstream);
 		if (ret < 0) {
 			pr_err("compress asoc: can't open platform %s\n",
@@ -166,7 +184,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown)
 		fe->dai_link->compr_ops->shutdown(cstream);
 machine_err:
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
+		platform_com->driver->compr_ops->free(cstream);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 plat_err:
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -209,6 +229,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int stream;
@@ -234,7 +255,9 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown)
 		rtd->dai_link->compr_ops->shutdown(cstream);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
+		platform_com->driver->compr_ops->free(cstream);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -266,6 +289,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	struct snd_soc_dpcm *dpcm;
 	int stream, ret;
@@ -303,7 +327,9 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown)
 		fe->dai_link->compr_ops->shutdown(cstream);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
+		platform_com->driver->compr_ops->free(cstream);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
@@ -318,13 +344,18 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->trigger) {
+		ret = platform_com->driver->compr_ops->trigger(cstream, cmd);
+		if (ret < 0)
+			goto out;
+	} else if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
 		ret = platform->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
 			goto out;
@@ -352,13 +383,18 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	int ret = 0, stream;
 
 	if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
 		cmd == SND_COMPR_TRIGGER_DRAIN) {
 
-		if (platform->driver->compr_ops &&
+		if (platform_com->driver->compr_ops &&
+		    platform_com->driver->compr_ops->trigger)
+			return platform_com->driver->compr_ops->trigger(cstream,
+									cmd);
+		else if (platform->driver->compr_ops &&
 		    platform->driver->compr_ops->trigger)
 			return platform->driver->compr_ops->trigger(cstream,
 								    cmd);
@@ -378,7 +414,11 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 			goto out;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->trigger) {
+		ret = platform_com->driver->compr_ops->trigger(cstream, cmd);
+		if (ret < 0)
+			goto out;
+	} else 	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
 		ret = platform->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
 			goto out;
@@ -414,6 +454,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
@@ -431,7 +472,11 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 			goto err;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->set_params) {
+		ret = platform_com->driver->compr_ops->set_params(cstream, params);
+		if (ret < 0)
+			goto err;
+	} else 	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
 		ret = platform->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
 			goto err;
@@ -469,6 +514,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
 	struct snd_soc_platform *platform = fe->platform;
+	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	int ret = 0, stream;
 
@@ -485,7 +531,11 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 			goto out;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->set_params) {
+		ret = platform_com->driver->compr_ops->set_params(cstream, params);
+		if (ret < 0)
+			goto out;
+	} else 	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
 		ret = platform->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
 			goto out;
@@ -529,6 +579,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
@@ -540,7 +591,9 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 			goto err;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_params)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_params)
+		ret = platform_com->driver->compr_ops->get_params(cstream, params);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_params)
 		ret = platform->driver->compr_ops->get_params(cstream, params);
 
 err:
@@ -553,11 +606,14 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_caps)
+		ret = platform_com->driver->compr_ops->get_caps(cstream, caps);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps)
 		ret = platform->driver->compr_ops->get_caps(cstream, caps);
 
 	mutex_unlock(&rtd->pcm_mutex);
@@ -569,11 +625,14 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_codec_caps)
+		ret = platform_com->driver->compr_ops->get_codec_caps(cstream, codec);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps)
 		ret = platform->driver->compr_ops->get_codec_caps(cstream, codec);
 
 	mutex_unlock(&rtd->pcm_mutex);
@@ -584,6 +643,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
@@ -595,7 +655,9 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 			goto err;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->ack)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->ack)
+		ret = platform_com->driver->compr_ops->ack(cstream, bytes);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->ack)
 		ret = platform->driver->compr_ops->ack(cstream, bytes);
 
 err:
@@ -608,6 +670,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 
@@ -616,7 +679,9 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer)
 		cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->pointer)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->pointer)
+		ret = platform_com->driver->compr_ops->pointer(cstream, tstamp);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->pointer)
 		ret = platform->driver->compr_ops->pointer(cstream, tstamp);
 
 	mutex_unlock(&rtd->pcm_mutex);
@@ -628,11 +693,14 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->copy)
+		ret = platform_com->driver->compr_ops->copy(cstream, buf, count);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
 		ret = platform->driver->compr_ops->copy(cstream, buf, count);
 
 	mutex_unlock(&rtd->pcm_mutex);
@@ -644,6 +712,7 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
@@ -653,7 +722,9 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 			return ret;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->set_metadata)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->set_metadata)
+		ret = platform_com->driver->compr_ops->set_metadata(cstream, metadata);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->set_metadata)
 		ret = platform->driver->compr_ops->set_metadata(cstream, metadata);
 
 	return ret;
@@ -664,6 +735,7 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
 
@@ -673,7 +745,9 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 			return ret;
 	}
 
-	if (platform->driver->compr_ops && platform->driver->compr_ops->get_metadata)
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_metadata)
+		ret = platform_com->driver->compr_ops->get_metadata(cstream, metadata);
+	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_metadata)
 		ret = platform->driver->compr_ops->get_metadata(cstream, metadata);
 
 	return ret;
@@ -721,6 +795,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_platform *platform = rtd->platform;
+	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_compr *compr;
@@ -799,7 +874,8 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 		memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
 
 	/* Add copy callback for not memory mapped DSPs */
-	if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
+	if ((platform_com->driver->compr_ops && platform_com->driver->compr_ops->copy) ||
+	    (platform->driver->compr_ops && platform->driver->compr_ops->copy))
 		compr->ops->copy = soc_compr_copy;
 
 	mutex_init(&compr->lock);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC][PATCH 3/x] ASoC: replace platform to component on sh/rcar
  2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
  2017-06-20  2:26 ` [RFC][PATCH 1/x] ASoC: snd_soc_component_driver has snd_pcm_ops Kuninori Morimoto
  2017-06-20  2:27 ` [RFC][PATCH 2/x] ASoC: snd_soc_component_driver has snd_compr_ops Kuninori Morimoto
@ 2017-06-20  2:27 ` Kuninori Morimoto
  2017-06-20  2:27 ` [RFC][PATCH 4/x] ASoC: replace platform to component on sst-xxx Kuninori Morimoto
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-20  2:27 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA

Now platform can be replaced to component, let's do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/core.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 409bac3..c03fb9f 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1339,12 +1339,9 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd)
 		PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
 }
 
-static struct snd_soc_platform_driver rsnd_soc_platform = {
+static const struct snd_soc_component_driver rsnd_soc_component = {
 	.ops		= &rsnd_pcm_ops,
 	.pcm_new	= rsnd_pcm_new,
-};
-
-static const struct snd_soc_component_driver rsnd_soc_component = {
 	.name		= "rsnd",
 };
 
@@ -1455,17 +1452,11 @@ static int rsnd_probe(struct platform_device *pdev)
 	/*
 	 *	asoc register
 	 */
-	ret = snd_soc_register_platform(dev, &rsnd_soc_platform);
-	if (ret < 0) {
-		dev_err(dev, "cannot snd soc register\n");
-		return ret;
-	}
-
 	ret = snd_soc_register_component(dev, &rsnd_soc_component,
 					 priv->daidrv, rsnd_rdai_nr(priv));
 	if (ret < 0) {
 		dev_err(dev, "cannot snd dai register\n");
-		goto exit_snd_soc;
+		goto exit_snd_probe;
 	}
 
 	pm_runtime_enable(dev);
@@ -1473,8 +1464,6 @@ static int rsnd_probe(struct platform_device *pdev)
 	dev_info(dev, "probed\n");
 	return ret;
 
-exit_snd_soc:
-	snd_soc_unregister_platform(dev);
 exit_snd_probe:
 	for_each_rsnd_dai(rdai, priv, i) {
 		rsnd_dai_call(remove, &rdai->playback, priv);
@@ -1511,7 +1500,6 @@ static int rsnd_remove(struct platform_device *pdev)
 		remove_func[i](priv);
 
 	snd_soc_unregister_component(&pdev->dev);
-	snd_soc_unregister_platform(&pdev->dev);
 
 	return ret;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC][PATCH 4/x] ASoC: replace platform to component on sst-xxx
  2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2017-06-20  2:27 ` [RFC][PATCH 3/x] ASoC: replace platform to component on sh/rcar Kuninori Morimoto
@ 2017-06-20  2:27 ` Kuninori Morimoto
  2017-06-20  2:28 ` [RFC][PATCH 5/x] ASoC: remove platform related things Kuninori Morimoto
  2017-06-21  4:32 ` [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-20  2:27 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA

Now platform can be replaced to component, let's do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/intel/atom/sst-atom-controls.c          | 36 +++++++++++------------
 sound/soc/intel/atom/sst-mfld-platform-compress.c |  3 +-
 sound/soc/intel/atom/sst-mfld-platform-pcm.c      | 32 ++++++--------------
 sound/soc/intel/atom/sst-mfld-platform.h          |  2 +-
 4 files changed, 29 insertions(+), 44 deletions(-)

diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
index 0f3604b..3672d36 100644
--- a/sound/soc/intel/atom/sst-atom-controls.c
+++ b/sound/soc/intel/atom/sst-atom-controls.c
@@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl,
  * name. First part of control name contains the pipe name (widget name).
  */
 static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w,
-	struct snd_soc_platform *platform)
+	struct snd_soc_component *component)
 {
 	struct snd_kcontrol *kctl;
 	int index, ret = 0;
-	struct snd_card *card = platform->component.card->snd_card;
+	struct snd_card *card = component->card->snd_card;
 	char *idx;
 
 	down_read(&card->controls_rwsem);
@@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w,
 /**
  * sst_fill_linked_widgets - fill the parent pointer for the linked widget
  */
-static void sst_fill_linked_widgets(struct snd_soc_platform *platform,
+static void sst_fill_linked_widgets(struct snd_soc_component *component,
 						struct sst_ids *ids)
 {
 	struct snd_soc_dapm_widget *w;
 	unsigned int len = strlen(ids->parent_wname);
 
-	list_for_each_entry(w, &platform->component.card->widgets, list) {
+	list_for_each_entry(w, &component->card->widgets, list) {
 		if (!strncmp(ids->parent_wname, w->name, len)) {
 			ids->parent_w = w;
 			break;
@@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform,
 /**
  * sst_map_modules_to_pipe - fill algo/gains list for all pipes
  */
-static int sst_map_modules_to_pipe(struct snd_soc_platform *platform)
+static int sst_map_modules_to_pipe(struct snd_soc_component *component)
 {
 	struct snd_soc_dapm_widget *w;
 	int ret = 0;
 
-	list_for_each_entry(w, &platform->component.card->widgets, list) {
+	list_for_each_entry(w, &component->card->widgets, list) {
 		if (is_sst_dapm_widget(w) && (w->priv)) {
 			struct sst_ids *ids = w->priv;
 
-			dev_dbg(platform->dev, "widget type=%d name=%s\n",
+			dev_dbg(component->dev, "widget type=%d name=%s\n",
 					w->id, w->name);
 			INIT_LIST_HEAD(&ids->algo_list);
 			INIT_LIST_HEAD(&ids->gain_list);
-			ret = sst_fill_widget_module_info(w, platform);
+			ret = sst_fill_widget_module_info(w, component);
 
 			if (ret < 0)
 				return ret;
 
 			/* fill linked widgets */
 			if (ids->parent_wname !=  NULL)
-				sst_fill_linked_widgets(platform, ids);
+				sst_fill_linked_widgets(component, ids);
 		}
 	}
 	return 0;
 }
 
-int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform)
+int sst_dsp_init_v2_dpcm(struct snd_soc_component *component)
 {
 	int i, ret = 0;
 	struct snd_soc_dapm_context *dapm =
-			snd_soc_component_get_dapm(&platform->component);
-	struct sst_data *drv = snd_soc_platform_get_drvdata(platform);
+			snd_soc_component_get_dapm(component);
+	struct sst_data *drv = snd_soc_component_get_drvdata(component);
 	unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3;
 
-	drv->byte_stream = devm_kzalloc(platform->dev,
+	drv->byte_stream = devm_kzalloc(component->dev,
 					SST_MAX_BIN_BYTES, GFP_KERNEL);
 	if (!drv->byte_stream)
 		return -ENOMEM;
@@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform)
 		sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT;
 	}
 
-	ret = snd_soc_add_platform_controls(platform, sst_gain_controls,
+	ret = snd_soc_add_component_controls(component, sst_gain_controls,
 			ARRAY_SIZE(sst_gain_controls));
 	if (ret)
 		return ret;
 
 	/* Initialize algo control params */
-	ret = sst_algo_control_init(platform->dev);
+	ret = sst_algo_control_init(component->dev);
 	if (ret)
 		return ret;
-	ret = snd_soc_add_platform_controls(platform, sst_algo_controls,
+	ret = snd_soc_add_component_controls(component, sst_algo_controls,
 			ARRAY_SIZE(sst_algo_controls));
 	if (ret)
 		return ret;
 
-	ret = snd_soc_add_platform_controls(platform, sst_slot_controls,
+	ret = snd_soc_add_component_controls(component, sst_slot_controls,
 			ARRAY_SIZE(sst_slot_controls));
 	if (ret)
 		return ret;
 
-	ret = sst_map_modules_to_pipe(platform);
+	ret = sst_map_modules_to_pipe(component);
 
 	return ret;
 }
diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c
index 1bead81..8df425f 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-compress.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c
@@ -107,8 +107,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
 	struct snd_sst_params str_params;
 	struct sst_compress_cb cb;
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
-	struct sst_data *ctx = snd_soc_platform_get_drvdata(platform);
+	struct sst_data *ctx = snd_soc_component_get_drvdata(rtd->platform_com);
 
 	stream = cstream->runtime->private_data;
 	/* construct fw structure for this*/
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index b082b31..62ef74e 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
 	return retval;
 }
 
-static int sst_soc_probe(struct snd_soc_platform *platform)
+static int sst_soc_probe(struct snd_soc_component *component)
 {
-	struct sst_data *drv = dev_get_drvdata(platform->dev);
+	struct sst_data *drv = dev_get_drvdata(component->dev);
 
-	drv->soc_card = platform->component.card;
-	return sst_dsp_init_v2_dpcm(platform);
+	drv->soc_card = component->card;
+	return sst_dsp_init_v2_dpcm(component);
 }
 
-static struct snd_soc_platform_driver sst_soc_platform_drv  = {
+static struct snd_soc_component_driver sst_soc_platform_drv  = {
+	.name		= "sst",
 	.probe		= sst_soc_probe,
 	.ops		= &sst_platform_ops,
 	.compr_ops	= &sst_platform_compr_ops,
 	.pcm_new	= sst_pcm_new,
 };
 
-static const struct snd_soc_component_driver sst_component = {
-	.name		= "sst",
-};
-
-
 static int sst_platform_probe(struct platform_device *pdev)
 {
 	struct sst_data *drv;
@@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev)
 	mutex_init(&drv->lock);
 	dev_set_drvdata(&pdev->dev, drv);
 
-	ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv);
-	if (ret) {
-		dev_err(&pdev->dev, "registering soc platform failed\n");
-		return ret;
-	}
-
-	ret = snd_soc_register_component(&pdev->dev, &sst_component,
+	ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv,
 				sst_platform_dai, ARRAY_SIZE(sst_platform_dai));
-	if (ret) {
+	if (ret)
 		dev_err(&pdev->dev, "registering cpu dais failed\n");
-		snd_soc_unregister_platform(&pdev->dev);
-	}
+
 	return ret;
 }
 
 static int sst_platform_remove(struct platform_device *pdev)
 {
-
-	snd_soc_unregister_component(&pdev->dev);
-	snd_soc_unregister_platform(&pdev->dev);
 	dev_dbg(&pdev->dev, "sst_platform_remove success\n");
 	return 0;
 }
diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h
index cb32cc7..4d432c7 100644
--- a/sound/soc/intel/atom/sst-mfld-platform.h
+++ b/sound/soc/intel/atom/sst-mfld-platform.h
@@ -155,7 +155,7 @@ struct sst_device {
 
 struct sst_data;
 
-int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform);
+int sst_dsp_init_v2_dpcm(struct snd_soc_component *component);
 int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute);
 int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable);
 int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC][PATCH 5/x] ASoC: remove platform related things
  2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2017-06-20  2:27 ` [RFC][PATCH 4/x] ASoC: replace platform to component on sst-xxx Kuninori Morimoto
@ 2017-06-20  2:28 ` Kuninori Morimoto
  2017-06-21  4:32 ` [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-20  2:28 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA

Now, all platform code are replaced to component.
This patch removes all platform code.

platform_list_read_file() is replaced to component_list_read_file(),
and snd_soc_lookup_platform() is replaced to snd_soc_lookup_component()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h      | 101 +---------------------
 sound/soc/soc-compress.c |  78 +----------------
 sound/soc/soc-core.c     | 220 +++++------------------------------------------
 sound/soc/soc-devres.c   |  35 --------
 sound/soc/soc-io.c       |  21 -----
 sound/soc/soc-pcm.c      |  68 ++-------------
 6 files changed, 34 insertions(+), 489 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 8ebfb53..78a23f9 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -401,9 +401,7 @@ enum snd_soc_bias_level {
 struct snd_soc_pcm_runtime;
 struct snd_soc_dai;
 struct snd_soc_dai_driver;
-struct snd_soc_platform;
 struct snd_soc_dai_link;
-struct snd_soc_platform_driver;
 struct snd_soc_codec;
 struct snd_soc_codec_driver;
 struct snd_soc_component;
@@ -455,15 +453,7 @@ static inline int snd_soc_resume(struct device *dev)
 }
 #endif
 int snd_soc_poweroff(struct device *dev);
-int snd_soc_register_platform(struct device *dev,
-		const struct snd_soc_platform_driver *platform_drv);
-int devm_snd_soc_register_platform(struct device *dev,
-		const struct snd_soc_platform_driver *platform_drv);
-void snd_soc_unregister_platform(struct device *dev);
-int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
-		const struct snd_soc_platform_driver *platform_drv);
-void snd_soc_remove_platform(struct snd_soc_platform *platform);
-struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev);
+
 int snd_soc_register_codec(struct device *dev,
 		const struct snd_soc_codec_driver *codec_drv,
 		struct snd_soc_dai_driver *dai_drv, int num_dai);
@@ -475,13 +465,10 @@ int devm_snd_soc_register_component(struct device *dev,
 			 const struct snd_soc_component_driver *cmpnt_drv,
 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
+struct snd_soc_component *snd_soc_lookup_component(struct device *dev);
 int snd_soc_cache_init(struct snd_soc_codec *codec);
 int snd_soc_cache_exit(struct snd_soc_codec *codec);
 
-int snd_soc_platform_read(struct snd_soc_platform *platform,
-					unsigned int reg);
-int snd_soc_platform_write(struct snd_soc_platform *platform,
-					unsigned int reg, unsigned int val);
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
 #ifdef CONFIG_SND_SOC_COMPRESS
 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
@@ -612,8 +599,6 @@ int snd_soc_add_component_controls(struct snd_soc_component *component,
 	const struct snd_kcontrol_new *controls, unsigned int num_controls);
 int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
 	const struct snd_kcontrol_new *controls, unsigned int num_controls);
-int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
-	const struct snd_kcontrol_new *controls, unsigned int num_controls);
 int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
 	const struct snd_kcontrol_new *controls, int num_controls);
 int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
@@ -877,8 +862,6 @@ struct snd_soc_component {
 	void (*remove)(struct snd_soc_component *);
 	int (*suspend)(struct snd_soc_component *);
 	int (*resume)(struct snd_soc_component *);
-	int (*pcm_new)(struct snd_soc_pcm_runtime *);
-	void (*pcm_free)(struct snd_pcm *);
 
 	/* machine specific init */
 	int (*init)(struct snd_soc_component *component);
@@ -952,39 +935,12 @@ struct snd_soc_codec_driver {
 	bool ignore_pmdown_time;  /* Doesn't benefit from pmdown delay */
 };
 
-/* SoC platform interface */
-struct snd_soc_platform_driver {
-
-	int (*probe)(struct snd_soc_platform *);
-	int (*remove)(struct snd_soc_platform *);
-	struct snd_soc_component_driver component_driver;
-
-	/* pcm creation and destruction */
-	int (*pcm_new)(struct snd_soc_pcm_runtime *);
-	void (*pcm_free)(struct snd_pcm *);
-
-	/* platform stream pcm ops */
-	const struct snd_pcm_ops *ops;
-
-	/* platform stream compress ops */
-	const struct snd_compr_ops *compr_ops;
-};
-
 struct snd_soc_dai_link_component {
 	const char *name;
 	struct device_node *of_node;
 	const char *dai_name;
 };
 
-struct snd_soc_platform {
-	struct device *dev;
-	const struct snd_soc_platform_driver *driver;
-
-	struct list_head list;
-
-	struct snd_soc_component component;
-};
-
 struct snd_soc_dai_link {
 	/* config - must be set by machine driver */
 	const char *name;			/* Codec name */
@@ -1233,7 +1189,6 @@ struct snd_soc_pcm_runtime {
 	struct snd_pcm *pcm;
 	struct snd_compr *compr;
 	struct snd_soc_codec *codec;
-	struct snd_soc_platform *platform; /* will be removed */
 	struct snd_soc_component *platform_com;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai;
@@ -1316,19 +1271,6 @@ static inline struct snd_soc_codec *snd_soc_component_to_codec(
 }
 
 /**
- * snd_soc_component_to_platform() - Casts a component to the platform it is embedded in
- * @component: The component to cast to a platform
- *
- * This function must only be used on components that are known to be platforms.
- * Otherwise the behavior is undefined.
- */
-static inline struct snd_soc_platform *snd_soc_component_to_platform(
-	struct snd_soc_component *component)
-{
-	return container_of(component, struct snd_soc_platform, component);
-}
-
-/**
  * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
  *  embedded in
  * @dapm: The DAPM context to cast to the component
@@ -1357,20 +1299,6 @@ static inline struct snd_soc_codec *snd_soc_dapm_to_codec(
 }
 
 /**
- * snd_soc_dapm_to_platform() - Casts a DAPM context to the platform it is
- *  embedded in
- * @dapm: The DAPM context to cast to the platform.
- *
- * This function must only be used on DAPM contexts that are known to be part of
- * a platform (e.g. in a platform driver). Otherwise the behavior is undefined.
- */
-static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
-	struct snd_soc_dapm_context *dapm)
-{
-	return snd_soc_component_to_platform(snd_soc_dapm_to_component(dapm));
-}
-
-/**
  * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
  *  component
  * @component: The component for which to get the DAPM context
@@ -1549,17 +1477,6 @@ static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
 	return snd_soc_component_get_drvdata(&codec->component);
 }
 
-static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
-		void *data)
-{
-	snd_soc_component_set_drvdata(&platform->component, data);
-}
-
-static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
-{
-	return snd_soc_component_get_drvdata(&platform->component);
-}
-
 static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
 {
 	INIT_LIST_HEAD(&card->widgets);
@@ -1646,20 +1563,6 @@ static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
 	return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol));
 }
 
-/**
- * snd_soc_kcontrol_platform() - Returns the platform that registered the control
- * @kcontrol: The control for which to get the platform
- *
- * Note: This function will only work correctly if the control has been
- * registered with snd_soc_add_platform_controls() or via table based setup of
- * a snd_soc_platform_driver. Otherwise the behavior is undefined.
- */
-static inline struct snd_soc_platform *snd_soc_kcontrol_platform(
-	struct snd_kcontrol *kcontrol)
-{
-	return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol));
-}
-
 int snd_soc_util_init(void);
 void snd_soc_util_exit(void);
 
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 61ebc1e..18f5fe9 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -29,7 +29,6 @@
 static int soc_compr_open(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
@@ -52,13 +51,6 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 			       platform_com->name);
 			goto plat_err;
 		}
-	} else if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
-		ret = platform->driver->compr_ops->open(cstream);
-		if (ret < 0) {
-			pr_err("compress asoc: can't open platform %s\n",
-				platform->component.name);
-			goto plat_err;
-		}
 	}
 
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) {
@@ -78,8 +70,6 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 machine_err:
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
 		platform_com->driver->compr_ops->free(cstream);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
-		platform->driver->compr_ops->free(cstream);
 plat_err:
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
 		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
@@ -92,7 +82,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
-	struct snd_soc_platform *platform = fe->platform;
 	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	struct snd_soc_dpcm *dpcm;
@@ -124,13 +113,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 			       platform_com->name);
 			goto plat_err;
 		}
-	} else if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
-		ret = platform->driver->compr_ops->open(cstream);
-		if (ret < 0) {
-			pr_err("compress asoc: can't open platform %s\n",
-				platform->component.name);
-			goto plat_err;
-		}
 	}
 
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) {
@@ -186,8 +168,6 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 machine_err:
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
 		platform_com->driver->compr_ops->free(cstream);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
-		platform->driver->compr_ops->free(cstream);
 plat_err:
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
 		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
@@ -228,7 +208,6 @@ static void close_delayed_work(struct work_struct *work)
 static int soc_compr_free(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
@@ -257,8 +236,6 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
 		platform_com->driver->compr_ops->free(cstream);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
-		platform->driver->compr_ops->free(cstream);
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
 		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
@@ -288,7 +265,6 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
-	struct snd_soc_platform *platform = fe->platform;
 	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	struct snd_soc_dpcm *dpcm;
@@ -329,8 +305,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->free)
 		platform_com->driver->compr_ops->free(cstream);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->free)
-		platform->driver->compr_ops->free(cstream);
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
 		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
@@ -343,7 +317,6 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 {
 
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
@@ -355,10 +328,6 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 		ret = platform_com->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
 			goto out;
-	} else if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
-		ret = platform->driver->compr_ops->trigger(cstream, cmd);
-		if (ret < 0)
-			goto out;
 	}
 
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger)
@@ -382,7 +351,6 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
-	struct snd_soc_platform *platform = fe->platform;
 	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	int ret = 0, stream;
@@ -394,10 +362,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 		    platform_com->driver->compr_ops->trigger)
 			return platform_com->driver->compr_ops->trigger(cstream,
 									cmd);
-		else if (platform->driver->compr_ops &&
-		    platform->driver->compr_ops->trigger)
-			return platform->driver->compr_ops->trigger(cstream,
-								    cmd);
 	}
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK)
@@ -418,10 +382,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 		ret = platform_com->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
 			goto out;
-	} else 	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
-		ret = platform->driver->compr_ops->trigger(cstream, cmd);
-		if (ret < 0)
-			goto out;
 	}
 
 	fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
@@ -453,7 +413,6 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 					struct snd_compr_params *params)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
@@ -476,10 +435,6 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 		ret = platform_com->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
 			goto err;
-	} else 	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
-		ret = platform->driver->compr_ops->set_params(cstream, params);
-		if (ret < 0)
-			goto err;
 	}
 
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) {
@@ -513,7 +468,6 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 {
 	struct snd_soc_pcm_runtime *fe = cstream->private_data;
 	struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
-	struct snd_soc_platform *platform = fe->platform;
 	struct snd_soc_component *platform_com = fe->platform_com;
 	struct snd_soc_dai *cpu_dai = fe->cpu_dai;
 	int ret = 0, stream;
@@ -535,10 +489,6 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 		ret = platform_com->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
 			goto out;
-	} else 	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
-		ret = platform->driver->compr_ops->set_params(cstream, params);
-		if (ret < 0)
-			goto out;
 	}
 
 	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) {
@@ -578,7 +528,6 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 					struct snd_codec *params)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
@@ -593,8 +542,6 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_params)
 		ret = platform_com->driver->compr_ops->get_params(cstream, params);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_params)
-		ret = platform->driver->compr_ops->get_params(cstream, params);
 
 err:
 	mutex_unlock(&rtd->pcm_mutex);
@@ -605,7 +552,6 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
 				struct snd_compr_caps *caps)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 
@@ -613,8 +559,6 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_caps)
 		ret = platform_com->driver->compr_ops->get_caps(cstream, caps);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps)
-		ret = platform->driver->compr_ops->get_caps(cstream, caps);
 
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
@@ -624,7 +568,6 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 				struct snd_compr_codec_caps *codec)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 
@@ -632,8 +575,6 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_codec_caps)
 		ret = platform_com->driver->compr_ops->get_codec_caps(cstream, codec);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps)
-		ret = platform->driver->compr_ops->get_codec_caps(cstream, codec);
 
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
@@ -642,7 +583,6 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
@@ -657,8 +597,6 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->ack)
 		ret = platform_com->driver->compr_ops->ack(cstream, bytes);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->ack)
-		ret = platform->driver->compr_ops->ack(cstream, bytes);
 
 err:
 	mutex_unlock(&rtd->pcm_mutex);
@@ -669,7 +607,6 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 			struct snd_compr_tstamp *tstamp)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
@@ -681,8 +618,6 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->pointer)
 		ret = platform_com->driver->compr_ops->pointer(cstream, tstamp);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->pointer)
-		ret = platform->driver->compr_ops->pointer(cstream, tstamp);
 
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
@@ -692,7 +627,6 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 			  char __user *buf, size_t count)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	int ret = 0;
 
@@ -700,8 +634,6 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->copy)
 		ret = platform_com->driver->compr_ops->copy(cstream, buf, count);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
-		ret = platform->driver->compr_ops->copy(cstream, buf, count);
 
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
@@ -711,7 +643,6 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 				struct snd_compr_metadata *metadata)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
@@ -724,8 +655,6 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->set_metadata)
 		ret = platform_com->driver->compr_ops->set_metadata(cstream, metadata);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->set_metadata)
-		ret = platform->driver->compr_ops->set_metadata(cstream, metadata);
 
 	return ret;
 }
@@ -734,7 +663,6 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 				struct snd_compr_metadata *metadata)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret = 0;
@@ -747,8 +675,6 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 
 	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->get_metadata)
 		ret = platform_com->driver->compr_ops->get_metadata(cstream, metadata);
-	else if (platform->driver->compr_ops && platform->driver->compr_ops->get_metadata)
-		ret = platform->driver->compr_ops->get_metadata(cstream, metadata);
 
 	return ret;
 }
@@ -794,7 +720,6 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_codec *codec = rtd->codec;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
@@ -874,8 +799,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 		memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
 
 	/* Add copy callback for not memory mapped DSPs */
-	if ((platform_com->driver->compr_ops && platform_com->driver->compr_ops->copy) ||
-	    (platform->driver->compr_ops && platform->driver->compr_ops->copy))
+	if (platform_com->driver->compr_ops && platform_com->driver->compr_ops->copy)
 		compr->ops->copy = soc_compr_copy;
 
 	mutex_init(&compr->lock);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 95ab9f6..5588a0d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -56,7 +56,6 @@
 #endif
 
 static DEFINE_MUTEX(client_mutex);
-static LIST_HEAD(platform_list);
 static LIST_HEAD(codec_list);
 static LIST_HEAD(component_list);
 
@@ -412,22 +411,22 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
 	.llseek = default_llseek,/* read accesses f_pos */
 };
 
-static ssize_t platform_list_read_file(struct file *file,
+static ssize_t component_list_read_file(struct file *file,
 				       char __user *user_buf,
 				       size_t count, loff_t *ppos)
 {
 	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	ssize_t len, ret = 0;
-	struct snd_soc_platform *platform;
+	struct snd_soc_component *component;
 
 	if (!buf)
 		return -ENOMEM;
 
 	mutex_lock(&client_mutex);
 
-	list_for_each_entry(platform, &platform_list, list) {
+	list_for_each_entry(component, &component_list, list) {
 		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
-			       platform->component.name);
+			       component->name);
 		if (len >= 0)
 			ret += len;
 		if (ret > PAGE_SIZE) {
@@ -445,8 +444,8 @@ static ssize_t platform_list_read_file(struct file *file,
 	return ret;
 }
 
-static const struct file_operations platform_list_fops = {
-	.read = platform_list_read_file,
+static const struct file_operations component_list_fops = {
+	.read = component_list_read_file,
 	.llseek = default_llseek,/* read accesses f_pos */
 };
 
@@ -494,8 +493,8 @@ static void snd_soc_debugfs_init(void)
 				 &dai_list_fops))
 		pr_warn("ASoC: Failed to create DAI list debugfs file\n");
 
-	if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL,
-				 &platform_list_fops))
+	if (!debugfs_create_file("component", 0444, snd_soc_debugfs_root, NULL,
+				 &component_list_fops))
 		pr_warn("ASoC: Failed to create platform list debugfs file\n");
 }
 
@@ -1036,7 +1035,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 	struct snd_soc_dai_link_component *codecs = dai_link->codecs;
 	struct snd_soc_dai_link_component cpu_dai_component;
 	struct snd_soc_dai **codec_dais;
-	struct snd_soc_platform *platform;
+	struct snd_soc_component *component;
 	struct device_node *platform_of_node;
 	const char *platform_name;
 	int i;
@@ -1086,23 +1085,22 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 		platform_name = "snd-soc-dummy";
 
 	/* find one from the set of registered platforms */
-	list_for_each_entry(platform, &platform_list, list) {
-		platform_of_node = platform->dev->of_node;
-		if (!platform_of_node && platform->dev->parent->of_node)
-			platform_of_node = platform->dev->parent->of_node;
+	list_for_each_entry(component, &component_list, list) {
+		platform_of_node = component->dev->of_node;
+		if (!platform_of_node && component->dev->parent->of_node)
+			platform_of_node = component->dev->parent->of_node;
 
 		if (dai_link->platform_of_node) {
 			if (platform_of_node != dai_link->platform_of_node)
 				continue;
 		} else {
-			if (strcmp(platform->component.name, platform_name))
+			if (strcmp(component->name, platform_name))
 				continue;
 		}
 
-		rtd->platform = platform;
-		rtd->platform_com = &platform->component;
+		rtd->platform_com = component;
 	}
-	if (!rtd->platform) {
+	if (!rtd->platform_com) {
 		dev_err(card->dev, "ASoC: platform %s not registered\n",
 			dai_link->platform_name);
 		goto _err_defer;
@@ -1172,7 +1170,6 @@ static void soc_remove_link_components(struct snd_soc_card *card,
 	struct snd_soc_pcm_runtime *rtd, int order)
 {
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_component *component;
 	int i;
@@ -1180,8 +1177,6 @@ static void soc_remove_link_components(struct snd_soc_card *card,
 	/* remove the platform */
 	if (platform_com && platform_com->driver->remove_order == order)
 		soc_remove_component(platform_com);
-	else if (platform && platform->component.driver->remove_order == order)
-		soc_remove_component(&platform->component);
 
 	/* remove the CODEC-side CODEC */
 	for (i = 0; i < rtd->num_codecs; i++) {
@@ -1546,7 +1541,6 @@ static int soc_probe_link_components(struct snd_soc_card *card,
 			struct snd_soc_pcm_runtime *rtd,
 				     int order)
 {
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_component *component;
 	int i, ret;
@@ -1574,10 +1568,6 @@ static int soc_probe_link_components(struct snd_soc_card *card,
 		ret = soc_probe_component(card, platform_com);
 		if (ret < 0)
 			return ret;
-	} else if (platform->component.driver->probe_order == order) {
-		ret = soc_probe_component(card, &platform->component);
-		if (ret < 0)
-			return ret;
 	}
 
 	return 0;
@@ -2494,24 +2484,6 @@ int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
 EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
 
 /**
- * snd_soc_add_platform_controls - add an array of controls to a platform.
- * Convenience function to add a list of controls.
- *
- * @platform: platform to add controls to
- * @controls: array of controls to add
- * @num_controls: number of elements in the array
- *
- * Return 0 for success, else error.
- */
-int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
-	const struct snd_kcontrol_new *controls, unsigned int num_controls)
-{
-	return snd_soc_add_component_controls(&platform->component, controls,
-		num_controls);
-}
-EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
-
-/**
  * snd_soc_add_card_controls - add an array of controls to a SoC card.
  * Convenience function to add a list of controls.
  *
@@ -3149,8 +3121,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	component->remove = component->driver->remove;
 	component->suspend = component->driver->suspend;
 	component->resume = component->driver->resume;
-	component->pcm_new = component->driver->pcm_new;
-	component->pcm_free = component->driver->pcm_free;
 
 	dapm = &component->dapm;
 	dapm->dev = dev;
@@ -3324,168 +3294,22 @@ void snd_soc_unregister_component(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
 
-static int snd_soc_platform_drv_probe(struct snd_soc_component *component)
-{
-	struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
-
-	return platform->driver->probe(platform);
-}
-
-static void snd_soc_platform_drv_remove(struct snd_soc_component *component)
-{
-	struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
-
-	platform->driver->remove(platform);
-}
-
-static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_soc_platform *platform = rtd->platform;
-	struct snd_soc_component *platform_com = rtd->platform_com;
-
-	if (platform_com->driver->pcm_new)
-		return platform_com->driver->pcm_new(rtd);
-	else if (platform->driver->pcm_new)
-		return platform->driver->pcm_new(rtd);
-	else
-		return 0;
-}
-
-static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm)
-{
-	struct snd_soc_pcm_runtime *rtd = pcm->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
-	struct snd_soc_component *platform_com = rtd->platform_com;
-
-	if (platform_com->driver->pcm_free)
-		platform_com->driver->pcm_free(pcm);
-	else if (platform->driver->pcm_free)
-		platform->driver->pcm_free(pcm);
-}
-
-/**
- * snd_soc_add_platform - Add a platform to the ASoC core
- * @dev: The parent device for the platform
- * @platform: The platform to add
- * @platform_drv: The driver for the platform
- */
-int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
-		const struct snd_soc_platform_driver *platform_drv)
+struct snd_soc_component *snd_soc_lookup_component(struct device *dev)
 {
-	int ret;
-
-	ret = snd_soc_component_initialize(&platform->component,
-			&platform_drv->component_driver, dev);
-	if (ret)
-		return ret;
-
-	platform->dev = dev;
-	platform->driver = platform_drv;
-
-	if (platform_drv->probe)
-		platform->component.probe = snd_soc_platform_drv_probe;
-	if (platform_drv->remove)
-		platform->component.remove = snd_soc_platform_drv_remove;
-	if (platform_drv->pcm_new)
-		platform->component.pcm_new = snd_soc_platform_drv_pcm_new;
-	if (platform_drv->pcm_free)
-		platform->component.pcm_free = snd_soc_platform_drv_pcm_free;
-
-#ifdef CONFIG_DEBUG_FS
-	platform->component.debugfs_prefix = "platform";
-#endif
-
-	mutex_lock(&client_mutex);
-	snd_soc_component_add_unlocked(&platform->component);
-	list_add(&platform->list, &platform_list);
-	mutex_unlock(&client_mutex);
-
-	dev_dbg(dev, "ASoC: Registered platform '%s'\n",
-		platform->component.name);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_add_platform);
-
-/**
- * snd_soc_register_platform - Register a platform with the ASoC core
- *
- * @dev: The device for the platform
- * @platform_drv: The driver for the platform
- */
-int snd_soc_register_platform(struct device *dev,
-		const struct snd_soc_platform_driver *platform_drv)
-{
-	struct snd_soc_platform *platform;
-	int ret;
-
-	dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev));
-
-	platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
-	if (platform == NULL)
-		return -ENOMEM;
-
-	ret = snd_soc_add_platform(dev, platform, platform_drv);
-	if (ret)
-		kfree(platform);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_register_platform);
-
-/**
- * snd_soc_remove_platform - Remove a platform from the ASoC core
- * @platform: the platform to remove
- */
-void snd_soc_remove_platform(struct snd_soc_platform *platform)
-{
-
-	mutex_lock(&client_mutex);
-	list_del(&platform->list);
-	snd_soc_component_del_unlocked(&platform->component);
-	mutex_unlock(&client_mutex);
-
-	dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n",
-		platform->component.name);
-
-	snd_soc_component_cleanup(&platform->component);
-}
-EXPORT_SYMBOL_GPL(snd_soc_remove_platform);
-
-struct snd_soc_platform *snd_soc_lookup_platform(struct device *dev)
-{
-	struct snd_soc_platform *platform;
+	struct snd_soc_component *component;
 
 	mutex_lock(&client_mutex);
-	list_for_each_entry(platform, &platform_list, list) {
-		if (dev == platform->dev) {
+	list_for_each_entry(component, &component_list, list) {
+		if (dev == component->dev) {
 			mutex_unlock(&client_mutex);
-			return platform;
+			return component;
 		}
 	}
 	mutex_unlock(&client_mutex);
 
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(snd_soc_lookup_platform);
-
-/**
- * snd_soc_unregister_platform - Unregister a platform from the ASoC core
- *
- * @dev: platform to unregister
- */
-void snd_soc_unregister_platform(struct device *dev)
-{
-	struct snd_soc_platform *platform;
-
-	platform = snd_soc_lookup_platform(dev);
-	if (!platform)
-		return;
-
-	snd_soc_remove_platform(platform);
-	kfree(platform);
-}
-EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
+EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
 
 static u64 codec_format_map[] = {
 	SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE,
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index a57921e..7ac745d 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -52,41 +52,6 @@ int devm_snd_soc_register_component(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
 
-static void devm_platform_release(struct device *dev, void *res)
-{
-	snd_soc_unregister_platform(*(struct device **)res);
-}
-
-/**
- * devm_snd_soc_register_platform - resource managed platform registration
- * @dev: Device used to manage platform
- * @platform_drv: platform to register
- *
- * Register a platform driver with automatic unregistration when the device is
- * unregistered.
- */
-int devm_snd_soc_register_platform(struct device *dev,
-			const struct snd_soc_platform_driver *platform_drv)
-{
-	struct device **ptr;
-	int ret;
-
-	ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	ret = snd_soc_register_platform(dev, platform_drv);
-	if (ret == 0) {
-		*ptr = dev;
-		devres_add(dev, ptr);
-	} else {
-		devres_free(ptr);
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(devm_snd_soc_register_platform);
-
 static void devm_card_release(struct device *dev, void *res)
 {
 	snd_soc_unregister_card(*(struct snd_soc_card **)res);
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index 9b39390..c909330 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -250,24 +250,3 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
 	return snd_soc_component_test_bits(&codec->component, reg, mask, value);
 }
 EXPORT_SYMBOL_GPL(snd_soc_test_bits);
-
-int snd_soc_platform_read(struct snd_soc_platform *platform,
-					unsigned int reg)
-{
-	unsigned int val;
-	int ret;
-
-	ret = snd_soc_component_read(&platform->component, reg, &val);
-	if (ret < 0)
-		return -1;
-
-	return val;
-}
-EXPORT_SYMBOL_GPL(snd_soc_platform_read);
-
-int snd_soc_platform_write(struct snd_soc_platform *platform,
-					 unsigned int reg, unsigned int val)
-{
-	return snd_soc_component_write(&platform->component, reg, val);
-}
-EXPORT_SYMBOL_GPL(snd_soc_platform_write);
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 6d919e6..9f9a117 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -449,7 +449,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_pcm_runtime *runtime = substream->runtime;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
@@ -462,7 +461,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	pm_runtime_get_sync(cpu_dai->dev);
 	for (i = 0; i < rtd->num_codecs; i++)
 		pm_runtime_get_sync(rtd->codec_dais[i]->dev);
-	pm_runtime_get_sync(platform->dev);
+	pm_runtime_get_sync(platform_com->dev);
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -483,13 +482,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 				" %s: %d\n", platform_com->name, ret);
 			goto platform_err;
 		}
-	} else if (platform->driver->ops && platform->driver->ops->open) {
-		ret = platform->driver->ops->open(substream);
-		if (ret < 0) {
-			dev_err(platform->dev, "ASoC: can't open platform"
-				" %s: %d\n", platform->component.name, ret);
-			goto platform_err;
-		}
 	}
 
 	for (i = 0; i < rtd->num_codecs; i++) {
@@ -600,8 +592,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 
 	if (platform_com->driver->ops && platform_com->driver->ops->close)
 		platform_com->driver->ops->close(substream);
-	else if (platform->driver->ops && platform->driver->ops->close)
-		platform->driver->ops->close(substream);
 
 platform_err:
 	if (cpu_dai->driver->ops->shutdown)
@@ -609,8 +599,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 out:
 	mutex_unlock(&rtd->pcm_mutex);
 
-	pm_runtime_mark_last_busy(platform->dev);
-	pm_runtime_put_autosuspend(platform->dev);
+	pm_runtime_mark_last_busy(platform_com->dev);
+	pm_runtime_put_autosuspend(platform_com->dev);
 	for (i = 0; i < rtd->num_codecs; i++) {
 		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
 		pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
@@ -664,7 +654,6 @@ static void close_delayed_work(struct work_struct *work)
 static int soc_pcm_close(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
@@ -700,8 +689,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	if (platform_com->driver->ops && platform_com->driver->ops->close)
 		platform_com->driver->ops->close(substream);
-	else if (platform->driver->ops && platform->driver->ops->close)
-		platform->driver->ops->close(substream);
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		if (snd_soc_runtime_ignore_pmdown_time(rtd)) {
@@ -724,8 +711,8 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	mutex_unlock(&rtd->pcm_mutex);
 
-	pm_runtime_mark_last_busy(platform->dev);
-	pm_runtime_put_autosuspend(platform->dev);
+	pm_runtime_mark_last_busy(platform_com->dev);
+	pm_runtime_put_autosuspend(platform_com->dev);
 
 	for (i = 0; i < rtd->num_codecs; i++) {
 		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
@@ -753,7 +740,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
@@ -777,13 +763,6 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 				" %d\n", ret);
 			goto out;
 		}
-	} else if (platform->driver->ops && platform->driver->ops->prepare) {
-		ret = platform->driver->ops->prepare(substream);
-		if (ret < 0) {
-			dev_err(platform->dev, "ASoC: platform prepare error:"
-				" %d\n", ret);
-			goto out;
-		}
 	}
 
 	for (i = 0; i < rtd->num_codecs; i++) {
@@ -867,7 +846,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int i, ret = 0;
@@ -940,13 +918,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 				platform_com->name, ret);
 			goto platform_err;
 		}
-	} else if (platform->driver->ops && platform->driver->ops->hw_params) {
-		ret = platform->driver->ops->hw_params(substream, params);
-		if (ret < 0) {
-			dev_err(platform->dev, "ASoC: %s hw params failed: %d\n",
-			       platform->component.name, ret);
-			goto platform_err;
-		}
 	}
 
 	/* store the parameters for each DAIs */
@@ -987,7 +958,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
@@ -1027,8 +997,6 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	/* free any DMA resources */
 	if (platform_com->driver->ops && platform_com->driver->ops->hw_free)
 		platform_com->driver->ops->hw_free(substream);
-	else if (platform->driver->ops && platform->driver->ops->hw_free)
-		platform->driver->ops->hw_free(substream);
 
 	/* now free hw params for the DAIs  */
 	for (i = 0; i < rtd->num_codecs; i++) {
@@ -1047,7 +1015,6 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
@@ -1067,10 +1034,6 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 		ret = platform_com->driver->ops->trigger(substream, cmd);
 		if (ret < 0)
 			return ret;
-	} else if (platform->driver->ops && platform->driver->ops->trigger) {
-		ret = platform->driver->ops->trigger(substream, cmd);
-		if (ret < 0)
-			return ret;
 	}
 
 	if (cpu_dai->driver->ops && cpu_dai->driver->ops->trigger) {
@@ -1122,7 +1085,6 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
 static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
@@ -1134,8 +1096,6 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
 
 	if (platform_com->driver->ops && platform_com->driver->ops->pointer)
 		offset = platform_com->driver->ops->pointer(substream);
-	else if (platform->driver->ops && platform->driver->ops->pointer)
-		offset = platform->driver->ops->pointer(substream);
 
 	if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay)
 		delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
@@ -2320,13 +2280,10 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream,
 		     unsigned int cmd, void *arg)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 
 	if (platform_com->driver->ops && platform_com->driver->ops->ioctl)
 		return platform_com->driver->ops->ioctl(substream, cmd, arg);
-	else if (platform->driver->ops && platform->driver->ops->ioctl)
-		return platform->driver->ops->ioctl(substream, cmd, arg);
 
 	return snd_pcm_lib_ioctl(substream, cmd, arg);
 }
@@ -2679,15 +2636,14 @@ static void soc_pcm_free(struct snd_pcm *pcm)
 
 	list_for_each_entry(component, &rtd->card->component_dev_list,
 			    card_list) {
-		if (component->pcm_free)
-			component->pcm_free(pcm);
+		if (component->driver->pcm_free)
+			component->driver->pcm_free(pcm);
 	}
 }
 
 /* create a new pcm */
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 {
-	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *platform_com = rtd->platform_com;
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
@@ -2792,12 +2748,6 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 		rtd->ops.silence	= platform_com->driver->ops->silence;
 		rtd->ops.page		= platform_com->driver->ops->page;
 		rtd->ops.mmap		= platform_com->driver->ops->mmap;
-	} else if (platform->driver->ops) {
-		rtd->ops.ack		= platform->driver->ops->ack;
-		rtd->ops.copy		= platform->driver->ops->copy;
-		rtd->ops.silence	= platform->driver->ops->silence;
-		rtd->ops.page		= platform->driver->ops->page;
-		rtd->ops.mmap		= platform->driver->ops->mmap;
 	}
 
 	if (playback)
@@ -2807,8 +2757,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops);
 
 	list_for_each_entry(component, &rtd->card->component_dev_list, card_list) {
-		if (component->pcm_new) {
-			ret = component->pcm_new(rtd);
+		if (component->driver->pcm_new) {
+			ret = component->driver->pcm_new(rtd);
 			if (ret < 0) {
 				dev_err(component->dev,
 					"ASoC: pcm constructor failed: %d\n",
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RFC][PATCH 0/x] ASoC: replace platform to component
  2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2017-06-20  2:28 ` [RFC][PATCH 5/x] ASoC: remove platform related things Kuninori Morimoto
@ 2017-06-21  4:32 ` Kuninori Morimoto
  2017-06-21 16:15   ` Mark Brown
  5 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-21  4:32 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter; +Cc: Simon, Linux-Renesas, Linux-ALSA


Hi Mark, Lars-Peter

> 1st Note is that it is still using rtd->platform_com style.

It is still using this "rtd->xxx" style, but we should expand it.
I'm thinking that we can connect each component to rtd by using list
and we can get it by "driver" (or something).
Then, we can add new snd_soc_lookup_runtime() function for it.
But, what do you think ?

	- rtd->platform_com = component;
	+ list_add(component->rtd_list, rtd->list_head);

	- struct device *dev = rtd->platform_com->dev;
	+ struct snd_soc_component *component = snd_soc_lookup_runtime(rtd, driver);
	+ struct device *dev = component->dev;

struct snd_soc_component *snd_soc_lookup_runtime(rtd, driver)
{
	...
	list_for_each_entry(component, &rtd->list_head, xxx) {
		if (driver == component->driver)
			return component;
	}

	return NULL;
}


Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC][PATCH 0/x] ASoC: replace platform to component
  2017-06-21  4:32 ` [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
@ 2017-06-21 16:15   ` Mark Brown
  2017-06-22  1:01     ` Kuninori Morimoto
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2017-06-21 16:15 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Lars-Peter, Simon, Linux-Renesas, Linux-ALSA

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

On Wed, Jun 21, 2017 at 04:32:30AM +0000, Kuninori Morimoto wrote:

> 	- struct device *dev = rtd->platform_com->dev;
> 	+ struct snd_soc_component *component = snd_soc_lookup_runtime(rtd, driver);

This seems like a fairly sensible idiom, and it'll also help deal with
some of the issues we have right now with CODEC<->CODEC links I think.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC][PATCH 0/x] ASoC: replace platform to component
  2017-06-21 16:15   ` Mark Brown
@ 2017-06-22  1:01     ` Kuninori Morimoto
  0 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-06-22  1:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: Lars-Peter, Simon, Linux-Renesas, Linux-ALSA


Hi Mark

> > 	- struct device *dev = rtd->platform_com->dev;
> > 	+ struct snd_soc_component *component = snd_soc_lookup_runtime(rtd, driver);
> 
> This seems like a fairly sensible idiom, and it'll also help deal with
> some of the issues we have right now with CODEC<->CODEC links I think.

Thanks
I will consider and try to create such patch

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-06-22  1:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-20  2:25 [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
2017-06-20  2:26 ` [RFC][PATCH 1/x] ASoC: snd_soc_component_driver has snd_pcm_ops Kuninori Morimoto
2017-06-20  2:27 ` [RFC][PATCH 2/x] ASoC: snd_soc_component_driver has snd_compr_ops Kuninori Morimoto
2017-06-20  2:27 ` [RFC][PATCH 3/x] ASoC: replace platform to component on sh/rcar Kuninori Morimoto
2017-06-20  2:27 ` [RFC][PATCH 4/x] ASoC: replace platform to component on sst-xxx Kuninori Morimoto
2017-06-20  2:28 ` [RFC][PATCH 5/x] ASoC: remove platform related things Kuninori Morimoto
2017-06-21  4:32 ` [RFC][PATCH 0/x] ASoC: replace platform to component Kuninori Morimoto
2017-06-21 16:15   ` Mark Brown
2017-06-22  1:01     ` Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.