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

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

@ -173,29 +173,20 @@ static int stm32_sai_probe(struct platform_device *pdev)
if (!STM_SAI_IS_F4(sai)) {
sai->pclk = devm_clk_get(&pdev->dev, "pclk");
if (IS_ERR(sai->pclk)) {
if (PTR_ERR(sai->pclk) != -EPROBE_DEFER)
dev_err(&pdev->dev, "missing bus clock pclk: %ld\n",
PTR_ERR(sai->pclk));
return PTR_ERR(sai->pclk);
}
if (IS_ERR(sai->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->pclk),
"missing bus clock pclk\n");
}
sai->clk_x8k = devm_clk_get(&pdev->dev, "x8k");
if (IS_ERR(sai->clk_x8k)) {
if (PTR_ERR(sai->clk_x8k) != -EPROBE_DEFER)
dev_err(&pdev->dev, "missing x8k parent clock: %ld\n",
PTR_ERR(sai->clk_x8k));
return PTR_ERR(sai->clk_x8k);
}
if (IS_ERR(sai->clk_x8k))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->clk_x8k),
"missing x8k parent clock\n");
sai->clk_x11k = devm_clk_get(&pdev->dev, "x11k");
if (IS_ERR(sai->clk_x11k)) {
if (PTR_ERR(sai->clk_x11k) != -EPROBE_DEFER)
dev_err(&pdev->dev, "missing x11k parent clock: %ld\n",
PTR_ERR(sai->clk_x11k));
return PTR_ERR(sai->clk_x11k);
}
if (IS_ERR(sai->clk_x11k))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->clk_x11k),
"missing x11k parent clock\n");
/* init irqs */
sai->irq = platform_get_irq(pdev, 0);
@ -204,12 +195,10 @@ static int stm32_sai_probe(struct platform_device *pdev)
/* reset */
rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst)) {
if (PTR_ERR(rst) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Reset controller error %ld\n",
PTR_ERR(rst));
return PTR_ERR(rst);
}
if (IS_ERR(rst))
return dev_err_probe(&pdev->dev, PTR_ERR(rst),
"Reset controller error\n");
reset_control_assert(rst);
udelay(2);
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_config);
if (IS_ERR(sai->regmap)) {
if (PTR_ERR(sai->regmap) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Regmap init error %ld\n",
PTR_ERR(sai->regmap));
return PTR_ERR(sai->regmap);
}
if (IS_ERR(sai->regmap))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->regmap),
"Regmap init error\n");
/* Get direction property */
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);
sai->sai_ck = devm_clk_get(&pdev->dev, "sai_ck");
if (IS_ERR(sai->sai_ck)) {
if (PTR_ERR(sai->sai_ck) != -EPROBE_DEFER)
dev_err(&pdev->dev, "Missing kernel clock sai_ck: %ld\n",
PTR_ERR(sai->sai_ck));
return PTR_ERR(sai->sai_ck);
}
if (IS_ERR(sai->sai_ck))
return dev_err_probe(&pdev->dev, PTR_ERR(sai->sai_ck),
"Missing kernel clock sai_ck\n");
ret = clk_prepare(sai->pdata->pclk);
if (ret < 0)
@ -1551,11 +1545,8 @@ static int stm32_sai_sub_probe(struct platform_device *pdev)
conf = &stm32_sai_pcm_config_spdif;
ret = snd_dmaengine_pcm_register(&pdev->dev, conf, 0);
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "Could not register pcm dma\n");
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret, "Could not register pcm dma\n");
ret = snd_soc_register_component(&pdev->dev, &stm32_component,
&sai->cpu_dai_drv, 1);

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

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