From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: [PATCH v2 16/39] ASoC: rt5514-spi: replace platform to component Date: Mon, 29 Jan 2018 02:45:13 +0000 Message-ID: <87h8r575b2.wl%kuninori.morimoto.gx@renesas.com> References: <87607l8k9i.wl%kuninori.morimoto.gx@renesas.com> <874ln58k4s.wl%kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from relmlie1.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa0.perex.cz (Postfix) with ESMTP id BCA9F26735E for ; Mon, 29 Jan 2018 03:45:17 +0100 (CET) In-Reply-To: <874ln58k4s.wl%kuninori.morimoto.gx@renesas.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: Linux-ALSA List-Id: alsa-devel@alsa-project.org From: Kuninori Morimoto Now platform can be replaced to component, let's do it. This patch merges rt5514_spi_dai_component into rt5514_spi_component Signed-off-by: Kuninori Morimoto --- sound/soc/codecs/rt5514-spi.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 2144edc..84184d9 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -35,6 +35,8 @@ #include "rt5514-spi.h" +#define DRV_NAME "rt5514-spi" + static struct spi_device *rt5514_spi; struct rt5514_dsp { @@ -211,8 +213,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); int ret; u8 buf[8]; @@ -235,8 +238,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, static int rt5514_spi_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); mutex_lock(&rt5514_dsp->dma_lock); rt5514_dsp->substream = NULL; @@ -252,8 +256,9 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer( { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); return bytes_to_frames(runtime, rt5514_dsp->dma_offset); } @@ -267,18 +272,18 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer( .page = snd_pcm_lib_get_vmalloc_page, }; -static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) +static int rt5514_spi_pcm_probe(struct snd_soc_component *component) { struct rt5514_dsp *rt5514_dsp; int ret; - rt5514_dsp = devm_kzalloc(platform->dev, sizeof(*rt5514_dsp), + rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp), GFP_KERNEL); rt5514_dsp->dev = &rt5514_spi->dev; mutex_init(&rt5514_dsp->dma_lock); INIT_DELAYED_WORK(&rt5514_dsp->copy_work, rt5514_spi_copy_work); - snd_soc_platform_set_drvdata(platform, rt5514_dsp); + snd_soc_component_set_drvdata(component, rt5514_dsp); if (rt5514_spi->irq) { ret = devm_request_threaded_irq(&rt5514_spi->dev, @@ -296,15 +301,12 @@ static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) return 0; } -static const struct snd_soc_platform_driver rt5514_spi_platform = { +static const struct snd_soc_component_driver rt5514_spi_component = { + .name = DRV_NAME, .probe = rt5514_spi_pcm_probe, .ops = &rt5514_spi_pcm_ops, }; -static const struct snd_soc_component_driver rt5514_spi_dai_component = { - .name = "rt5514-spi-dai", -}; - /** * rt5514_spi_burst_read - Read data from SPI by rt5514 address. * @addr: Start address. @@ -445,14 +447,8 @@ static int rt5514_spi_probe(struct spi_device *spi) rt5514_spi = spi; - ret = devm_snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); - if (ret < 0) { - dev_err(&spi->dev, "Failed to register platform.\n"); - return ret; - } - ret = devm_snd_soc_register_component(&spi->dev, - &rt5514_spi_dai_component, + &rt5514_spi_component, &rt5514_spi_dai, 1); if (ret < 0) { dev_err(&spi->dev, "Failed to register component.\n"); -- 1.9.1