ASoC: stm: Use dev_err_probe() helper

Use the dev_err_probe() helper, instead of open-coding the same
operation.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20211214020843.2225831-22-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2021-12-14 11:08:42 +09:00 коммит произвёл Mark Brown
Родитель 27c6eaebcf
Коммит efc162cbd4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
4 изменённых файлов: 57 добавлений и 111 удалений

Просмотреть файл

@ -1045,36 +1045,24 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,
/* Get clocks */ /* Get clocks */
i2s->pclk = devm_clk_get(&pdev->dev, "pclk"); i2s->pclk = devm_clk_get(&pdev->dev, "pclk");
if (IS_ERR(i2s->pclk)) { if (IS_ERR(i2s->pclk))
if (PTR_ERR(i2s->pclk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(i2s->pclk),
dev_err(&pdev->dev, "Could not get pclk: %ld\n", "Could not get pclk\n");
PTR_ERR(i2s->pclk));
return PTR_ERR(i2s->pclk);
}
i2s->i2sclk = devm_clk_get(&pdev->dev, "i2sclk"); i2s->i2sclk = devm_clk_get(&pdev->dev, "i2sclk");
if (IS_ERR(i2s->i2sclk)) { if (IS_ERR(i2s->i2sclk))
if (PTR_ERR(i2s->i2sclk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(i2s->i2sclk),
dev_err(&pdev->dev, "Could not get i2sclk: %ld\n", "Could not get i2sclk\n");
PTR_ERR(i2s->i2sclk));
return PTR_ERR(i2s->i2sclk);
}
i2s->x8kclk = devm_clk_get(&pdev->dev, "x8k"); i2s->x8kclk = devm_clk_get(&pdev->dev, "x8k");
if (IS_ERR(i2s->x8kclk)) { if (IS_ERR(i2s->x8kclk))
if (PTR_ERR(i2s->x8kclk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(i2s->x8kclk),
dev_err(&pdev->dev, "Could not get x8k parent clock: %ld\n", "Could not get x8k parent clock\n");
PTR_ERR(i2s->x8kclk));
return PTR_ERR(i2s->x8kclk);
}
i2s->x11kclk = devm_clk_get(&pdev->dev, "x11k"); i2s->x11kclk = devm_clk_get(&pdev->dev, "x11k");
if (IS_ERR(i2s->x11kclk)) { if (IS_ERR(i2s->x11kclk))
if (PTR_ERR(i2s->x11kclk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(i2s->x11kclk),
dev_err(&pdev->dev, "Could not get x11k parent clock: %ld\n", "Could not get x11k parent clock\n");
PTR_ERR(i2s->x11kclk));
return PTR_ERR(i2s->x11kclk);
}
/* Register mclk provider if requested */ /* Register mclk provider if requested */
if (of_find_property(np, "#clock-cells", NULL)) { if (of_find_property(np, "#clock-cells", NULL)) {
@ -1097,12 +1085,10 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,
/* Reset */ /* Reset */
rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst)) { if (IS_ERR(rst))
if (PTR_ERR(rst) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(rst),
dev_err(&pdev->dev, "Reset controller error %ld\n", "Reset controller error\n");
PTR_ERR(rst));
return PTR_ERR(rst);
}
reset_control_assert(rst); reset_control_assert(rst);
udelay(2); udelay(2);
reset_control_deassert(rst); reset_control_deassert(rst);
@ -1145,21 +1131,15 @@ static int stm32_i2s_probe(struct platform_device *pdev)
i2s->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "pclk", i2s->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "pclk",
i2s->base, i2s->regmap_conf); i2s->base, i2s->regmap_conf);
if (IS_ERR(i2s->regmap)) { if (IS_ERR(i2s->regmap))
if (PTR_ERR(i2s->regmap) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(i2s->regmap),
dev_err(&pdev->dev, "Regmap init error %ld\n", "Regmap init error\n");
PTR_ERR(i2s->regmap));
return PTR_ERR(i2s->regmap);
}
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
ret = snd_dmaengine_pcm_register(&pdev->dev, &stm32_i2s_pcm_config, 0); ret = snd_dmaengine_pcm_register(&pdev->dev, &stm32_i2s_pcm_config, 0);
if (ret) { if (ret)
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, ret, "PCM DMA register error\n");
dev_err(&pdev->dev, "PCM DMA register error %d\n", ret);
return ret;
}
ret = snd_soc_register_component(&pdev->dev, &stm32_i2s_component, ret = snd_soc_register_component(&pdev->dev, &stm32_i2s_component,
i2s->dai_drv, 1); i2s->dai_drv, 1);

Просмотреть файл

@ -173,29 +173,20 @@ static int stm32_sai_probe(struct platform_device *pdev)
if (!STM_SAI_IS_F4(sai)) { if (!STM_SAI_IS_F4(sai)) {
sai->pclk = devm_clk_get(&pdev->dev, "pclk"); sai->pclk = devm_clk_get(&pdev->dev, "pclk");
if (IS_ERR(sai->pclk)) { if (IS_ERR(sai->pclk))
if (PTR_ERR(sai->pclk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(sai->pclk),
dev_err(&pdev->dev, "missing bus clock pclk: %ld\n", "missing bus clock pclk\n");
PTR_ERR(sai->pclk));
return PTR_ERR(sai->pclk);
}
} }
sai->clk_x8k = devm_clk_get(&pdev->dev, "x8k"); sai->clk_x8k = devm_clk_get(&pdev->dev, "x8k");
if (IS_ERR(sai->clk_x8k)) { if (IS_ERR(sai->clk_x8k))
if (PTR_ERR(sai->clk_x8k) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(sai->clk_x8k),
dev_err(&pdev->dev, "missing x8k parent clock: %ld\n", "missing x8k parent clock\n");
PTR_ERR(sai->clk_x8k));
return PTR_ERR(sai->clk_x8k);
}
sai->clk_x11k = devm_clk_get(&pdev->dev, "x11k"); sai->clk_x11k = devm_clk_get(&pdev->dev, "x11k");
if (IS_ERR(sai->clk_x11k)) { if (IS_ERR(sai->clk_x11k))
if (PTR_ERR(sai->clk_x11k) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(sai->clk_x11k),
dev_err(&pdev->dev, "missing x11k parent clock: %ld\n", "missing x11k parent clock\n");
PTR_ERR(sai->clk_x11k));
return PTR_ERR(sai->clk_x11k);
}
/* init irqs */ /* init irqs */
sai->irq = platform_get_irq(pdev, 0); sai->irq = platform_get_irq(pdev, 0);
@ -204,12 +195,10 @@ static int stm32_sai_probe(struct platform_device *pdev)
/* reset */ /* reset */
rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst)) { if (IS_ERR(rst))
if (PTR_ERR(rst) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(rst),
dev_err(&pdev->dev, "Reset controller error %ld\n", "Reset controller error\n");
PTR_ERR(rst));
return PTR_ERR(rst);
}
reset_control_assert(rst); reset_control_assert(rst);
udelay(2); udelay(2);
reset_control_deassert(rst); reset_control_deassert(rst);

Просмотреть файл

@ -1379,12 +1379,9 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev,
*/ */
sai->regmap = devm_regmap_init_mmio(&pdev->dev, base, sai->regmap = devm_regmap_init_mmio(&pdev->dev, base,
sai->regmap_config); sai->regmap_config);
if (IS_ERR(sai->regmap)) { if (IS_ERR(sai->regmap))
if (PTR_ERR(sai->regmap) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(sai->regmap),
dev_err(&pdev->dev, "Regmap init error %ld\n", "Regmap init error\n");
PTR_ERR(sai->regmap));
return PTR_ERR(sai->regmap);
}
/* Get direction property */ /* Get direction property */
if (of_property_match_string(np, "dma-names", "tx") >= 0) { if (of_property_match_string(np, "dma-names", "tx") >= 0) {
@ -1472,12 +1469,9 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev,
of_node_put(args.np); of_node_put(args.np);
sai->sai_ck = devm_clk_get(&pdev->dev, "sai_ck"); sai->sai_ck = devm_clk_get(&pdev->dev, "sai_ck");
if (IS_ERR(sai->sai_ck)) { if (IS_ERR(sai->sai_ck))
if (PTR_ERR(sai->sai_ck) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(sai->sai_ck),
dev_err(&pdev->dev, "Missing kernel clock sai_ck: %ld\n", "Missing kernel clock sai_ck\n");
PTR_ERR(sai->sai_ck));
return PTR_ERR(sai->sai_ck);
}
ret = clk_prepare(sai->pdata->pclk); ret = clk_prepare(sai->pdata->pclk);
if (ret < 0) if (ret < 0)
@ -1551,11 +1545,8 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
conf = &stm32_sai_pcm_config_spdif; conf = &stm32_sai_pcm_config_spdif;
ret = snd_dmaengine_pcm_register(&pdev->dev, conf, 0); ret = snd_dmaengine_pcm_register(&pdev->dev, conf, 0);
if (ret) { if (ret)
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, ret, "Could not register pcm dma\n");
dev_err(&pdev->dev, "Could not register pcm dma\n");
return ret;
}
ret = snd_soc_register_component(&pdev->dev, &stm32_component, ret = snd_soc_register_component(&pdev->dev, &stm32_component,
&sai->cpu_dai_drv, 1); &sai->cpu_dai_drv, 1);

Просмотреть файл

@ -406,12 +406,9 @@ static int stm32_spdifrx_dma_ctrl_register(struct device *dev,
int ret; int ret;
spdifrx->ctrl_chan = dma_request_chan(dev, "rx-ctrl"); spdifrx->ctrl_chan = dma_request_chan(dev, "rx-ctrl");
if (IS_ERR(spdifrx->ctrl_chan)) { if (IS_ERR(spdifrx->ctrl_chan))
if (PTR_ERR(spdifrx->ctrl_chan) != -EPROBE_DEFER) return dev_err_probe(dev, PTR_ERR(spdifrx->ctrl_chan),
dev_err(dev, "dma_request_slave_channel error %ld\n", "dma_request_slave_channel error\n");
PTR_ERR(spdifrx->ctrl_chan));
return PTR_ERR(spdifrx->ctrl_chan);
}
spdifrx->dmab = devm_kzalloc(dev, sizeof(struct snd_dma_buffer), spdifrx->dmab = devm_kzalloc(dev, sizeof(struct snd_dma_buffer),
GFP_KERNEL); GFP_KERNEL);
@ -930,12 +927,9 @@ static int stm32_spdifrx_parse_of(struct platform_device *pdev,
spdifrx->phys_addr = res->start; spdifrx->phys_addr = res->start;
spdifrx->kclk = devm_clk_get(&pdev->dev, "kclk"); spdifrx->kclk = devm_clk_get(&pdev->dev, "kclk");
if (IS_ERR(spdifrx->kclk)) { if (IS_ERR(spdifrx->kclk))
if (PTR_ERR(spdifrx->kclk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(spdifrx->kclk),
dev_err(&pdev->dev, "Could not get kclk: %ld\n", "Could not get kclk\n");
PTR_ERR(spdifrx->kclk));
return PTR_ERR(spdifrx->kclk);
}
spdifrx->irq = platform_get_irq(pdev, 0); spdifrx->irq = platform_get_irq(pdev, 0);
if (spdifrx->irq < 0) if (spdifrx->irq < 0)
@ -987,12 +981,9 @@ static int stm32_spdifrx_probe(struct platform_device *pdev)
spdifrx->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "kclk", spdifrx->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "kclk",
spdifrx->base, spdifrx->base,
spdifrx->regmap_conf); spdifrx->regmap_conf);
if (IS_ERR(spdifrx->regmap)) { if (IS_ERR(spdifrx->regmap))
if (PTR_ERR(spdifrx->regmap) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(spdifrx->regmap),
dev_err(&pdev->dev, "Regmap init error %ld\n", "Regmap init error\n");
PTR_ERR(spdifrx->regmap));
return PTR_ERR(spdifrx->regmap);
}
ret = devm_request_irq(&pdev->dev, spdifrx->irq, stm32_spdifrx_isr, 0, ret = devm_request_irq(&pdev->dev, spdifrx->irq, stm32_spdifrx_isr, 0,
dev_name(&pdev->dev), spdifrx); dev_name(&pdev->dev), spdifrx);
@ -1002,12 +993,10 @@ static int stm32_spdifrx_probe(struct platform_device *pdev)
} }
rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst)) { if (IS_ERR(rst))
if (PTR_ERR(rst) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(rst),
dev_err(&pdev->dev, "Reset controller error %ld\n", "Reset controller error\n");
PTR_ERR(rst));
return PTR_ERR(rst);
}
reset_control_assert(rst); reset_control_assert(rst);
udelay(2); udelay(2);
reset_control_deassert(rst); reset_control_deassert(rst);
@ -1016,11 +1005,8 @@ static int stm32_spdifrx_probe(struct platform_device *pdev)
pcm_config = &stm32_spdifrx_pcm_config; pcm_config = &stm32_spdifrx_pcm_config;
ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, 0); ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, 0);
if (ret) { if (ret)
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, ret, "PCM DMA register error\n");
dev_err(&pdev->dev, "PCM DMA register error %d\n", ret);
return ret;
}
ret = snd_soc_register_component(&pdev->dev, ret = snd_soc_register_component(&pdev->dev,
&stm32_spdifrx_component, &stm32_spdifrx_component,