From 6cfb1cd60394c2d88c6868d147cf6882a9ca3b6c Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 19 Sep 2019 17:27:57 +0200 Subject: ASoC: xlnx: Use devm_platform_ioremap_resource() in xlnx_formatter_pcm_probe() Simplify this function implementation by using a known wrapper function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Link: https://lore.kernel.org/r/8f7cf483-6ab3-d00f-5606-863e9f5b31fc@web.de Signed-off-by: Mark Brown --- sound/soc/xilinx/xlnx_formatter_pcm.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'sound/soc/xilinx') diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index 48970efe7838..fb652e73abeb 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -564,7 +564,6 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev) int ret; u32 val; struct xlnx_pcm_drv_data *aud_drv_data; - struct resource *res; struct device *dev = &pdev->dev; aud_drv_data = devm_kzalloc(dev, sizeof(*aud_drv_data), GFP_KERNEL); @@ -584,13 +583,7 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev) return ret; } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "audio formatter node:addr to resource failed\n"); - ret = -ENXIO; - goto clk_err; - } - aud_drv_data->mmio = devm_ioremap_resource(dev, res); + aud_drv_data->mmio = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(aud_drv_data->mmio)) { dev_err(dev, "audio formatter ioremap failed\n"); ret = PTR_ERR(aud_drv_data->mmio); -- cgit v1.2.3 From 2bcba42492bf9579c5804692828c56d55b95c1ad Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 2 Oct 2019 14:32:29 +0900 Subject: ASoC: xilinx: xlnx_formatter_pcm: remove snd_pcm_ops snd_pcm_ops is no longer needed. Let's use component driver callback. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87bluzaf0y.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/xilinx/xlnx_formatter_pcm.c | 54 +++++++++++++++-------------------- 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'sound/soc/xilinx') diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index fb652e73abeb..296c4caf96a0 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -313,16 +313,14 @@ static irqreturn_t xlnx_s2mm_irq_handler(int irq, void *arg) return IRQ_NONE; } -static int xlnx_formatter_pcm_open(struct snd_pcm_substream *substream) +static int xlnx_formatter_pcm_open(struct snd_soc_component *component, + struct snd_pcm_substream *substream) { int err; u32 val, data_format_mode; u32 ch_count_mask, ch_count_shift, data_xfer_mode, data_xfer_shift; struct xlnx_pcm_stream_param *stream_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, - DRV_NAME); struct xlnx_pcm_drv_data *adata = dev_get_drvdata(component->dev); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && @@ -387,14 +385,12 @@ static int xlnx_formatter_pcm_open(struct snd_pcm_substream *substream) return 0; } -static int xlnx_formatter_pcm_close(struct snd_pcm_substream *substream) +static int xlnx_formatter_pcm_close(struct snd_soc_component *component, + struct snd_pcm_substream *substream) { int ret; struct xlnx_pcm_stream_param *stream_data = substream->runtime->private_data; - struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, - DRV_NAME); ret = xlnx_formatter_pcm_reset(stream_data->mmio); if (ret) { @@ -409,7 +405,8 @@ err_reset: } static snd_pcm_uframes_t -xlnx_formatter_pcm_pointer(struct snd_pcm_substream *substream) +xlnx_formatter_pcm_pointer(struct snd_soc_component *component, + struct snd_pcm_substream *substream) { u32 pos; struct snd_pcm_runtime *runtime = substream->runtime; @@ -423,16 +420,14 @@ xlnx_formatter_pcm_pointer(struct snd_pcm_substream *substream) return bytes_to_frames(runtime, pos); } -static int xlnx_formatter_pcm_hw_params(struct snd_pcm_substream *substream, +static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component, + struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { u32 low, high, active_ch, val, bytes_per_ch, bits_per_sample; u32 aes_reg1_val, aes_reg2_val; int status; u64 size; - struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, - DRV_NAME); struct snd_pcm_runtime *runtime = substream->runtime; struct xlnx_pcm_stream_param *stream_data = runtime->private_data; @@ -500,12 +495,14 @@ static int xlnx_formatter_pcm_hw_params(struct snd_pcm_substream *substream, return 0; } -static int xlnx_formatter_pcm_hw_free(struct snd_pcm_substream *substream) +static int xlnx_formatter_pcm_hw_free(struct snd_soc_component *component, + struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int xlnx_formatter_pcm_trigger(struct snd_pcm_substream *substream, +static int xlnx_formatter_pcm_trigger(struct snd_soc_component *component, + struct snd_pcm_substream *substream, int cmd) { u32 val; @@ -532,10 +529,9 @@ static int xlnx_formatter_pcm_trigger(struct snd_pcm_substream *substream, return 0; } -static int xlnx_formatter_pcm_new(struct snd_soc_pcm_runtime *rtd) +static int xlnx_formatter_pcm_new(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, - DRV_NAME); snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, component->dev, xlnx_pcm_hardware.buffer_bytes_max, @@ -543,20 +539,16 @@ static int xlnx_formatter_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_pcm_ops xlnx_formatter_pcm_ops = { - .open = xlnx_formatter_pcm_open, - .close = xlnx_formatter_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = xlnx_formatter_pcm_hw_params, - .hw_free = xlnx_formatter_pcm_hw_free, - .trigger = xlnx_formatter_pcm_trigger, - .pointer = xlnx_formatter_pcm_pointer, -}; - static const struct snd_soc_component_driver xlnx_asoc_component = { - .name = DRV_NAME, - .ops = &xlnx_formatter_pcm_ops, - .pcm_new = xlnx_formatter_pcm_new, + .name = DRV_NAME, + .open = xlnx_formatter_pcm_open, + .close = xlnx_formatter_pcm_close, + .ioctl = snd_soc_pcm_lib_ioctl, + .hw_params = xlnx_formatter_pcm_hw_params, + .hw_free = xlnx_formatter_pcm_hw_free, + .trigger = xlnx_formatter_pcm_trigger, + .pointer = xlnx_formatter_pcm_pointer, + .pcm_construct = xlnx_formatter_pcm_new, }; static int xlnx_formatter_pcm_probe(struct platform_device *pdev) -- cgit v1.2.3