dmaengine: sun4i: Simplify error handling in probe()
Clean up error handling by using devm functions and dev_err_probe(). This should make it easier to add new code, as we can eliminate the "goto ladder" in sun4i_dma_probe(). Suggested-by: Chen-Yu Tsai <wens@kernel.org> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Reviewed-by: Julian Calaby <julian.calaby@gmail.com> Signed-off-by: Bence Csókás <csokas.bence@prolan.hu> Link: https://lore.kernel.org/r/20250625085450.154280-2-csokas.bence@prolan.hu Signed-off-by: Vinod Koul <vkoul@kernel.org>pull/1320/head
parent
e54dd5059d
commit
814f047fc9
|
|
@ -1249,11 +1249,10 @@ static int sun4i_dma_probe(struct platform_device *pdev)
|
||||||
if (priv->irq < 0)
|
if (priv->irq < 0)
|
||||||
return priv->irq;
|
return priv->irq;
|
||||||
|
|
||||||
priv->clk = devm_clk_get(&pdev->dev, NULL);
|
priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||||
if (IS_ERR(priv->clk)) {
|
if (IS_ERR(priv->clk))
|
||||||
dev_err(&pdev->dev, "No clock specified\n");
|
return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk),
|
||||||
return PTR_ERR(priv->clk);
|
"Couldn't start the clock\n");
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->cfg->has_reset) {
|
if (priv->cfg->has_reset) {
|
||||||
priv->rst = devm_reset_control_get_exclusive_deasserted(&pdev->dev, NULL);
|
priv->rst = devm_reset_control_get_exclusive_deasserted(&pdev->dev, NULL);
|
||||||
|
|
@ -1328,12 +1327,6 @@ static int sun4i_dma_probe(struct platform_device *pdev)
|
||||||
vchan_init(&vchan->vc, &priv->slave);
|
vchan_init(&vchan->vc, &priv->slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(priv->clk);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&pdev->dev, "Couldn't enable the clock\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the IRQs are all disabled and accounted for. The bootloader
|
* Make sure the IRQs are all disabled and accounted for. The bootloader
|
||||||
* likes to leave these dirty
|
* likes to leave these dirty
|
||||||
|
|
@ -1343,33 +1336,23 @@ static int sun4i_dma_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
ret = devm_request_irq(&pdev->dev, priv->irq, sun4i_dma_interrupt,
|
ret = devm_request_irq(&pdev->dev, priv->irq, sun4i_dma_interrupt,
|
||||||
0, dev_name(&pdev->dev), priv);
|
0, dev_name(&pdev->dev), priv);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(&pdev->dev, "Cannot request IRQ\n");
|
return dev_err_probe(&pdev->dev, ret, "Cannot request IRQ\n");
|
||||||
goto err_clk_disable;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = dma_async_device_register(&priv->slave);
|
ret = dmaenginem_async_device_register(&priv->slave);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_warn(&pdev->dev, "Failed to register DMA engine device\n");
|
return dev_err_probe(&pdev->dev, ret,
|
||||||
goto err_clk_disable;
|
"Failed to register DMA engine device\n");
|
||||||
}
|
|
||||||
|
|
||||||
ret = of_dma_controller_register(pdev->dev.of_node, sun4i_dma_of_xlate,
|
ret = of_dma_controller_register(pdev->dev.of_node, sun4i_dma_of_xlate,
|
||||||
priv);
|
priv);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(&pdev->dev, "of_dma_controller_register failed\n");
|
return dev_err_probe(&pdev->dev, ret,
|
||||||
goto err_dma_unregister;
|
"Failed to register translation function\n");
|
||||||
}
|
|
||||||
|
|
||||||
dev_dbg(&pdev->dev, "Successfully probed SUN4I_DMA\n");
|
dev_dbg(&pdev->dev, "Successfully probed SUN4I_DMA\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_dma_unregister:
|
|
||||||
dma_async_device_unregister(&priv->slave);
|
|
||||||
err_clk_disable:
|
|
||||||
clk_disable_unprepare(priv->clk);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sun4i_dma_remove(struct platform_device *pdev)
|
static void sun4i_dma_remove(struct platform_device *pdev)
|
||||||
|
|
@ -1380,9 +1363,6 @@ static void sun4i_dma_remove(struct platform_device *pdev)
|
||||||
disable_irq(priv->irq);
|
disable_irq(priv->irq);
|
||||||
|
|
||||||
of_dma_controller_free(pdev->dev.of_node);
|
of_dma_controller_free(pdev->dev.of_node);
|
||||||
dma_async_device_unregister(&priv->slave);
|
|
||||||
|
|
||||||
clk_disable_unprepare(priv->clk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sun4i_dma_config sun4i_a10_dma_cfg = {
|
static struct sun4i_dma_config sun4i_a10_dma_cfg = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue