mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
spi: uniphier: switch to managed controller allocation
Switch to device managed controller allocation to simplify error handling and to avoid having to take another reference during deregistration. Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260505072909.618363-20-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f8689d5a9e
commit
789986b145
|
|
@ -649,7 +649,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
|
|||
int irq;
|
||||
int ret;
|
||||
|
||||
host = spi_alloc_host(&pdev->dev, sizeof(*priv));
|
||||
host = devm_spi_alloc_host(&pdev->dev, sizeof(*priv));
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -660,30 +660,26 @@ static int uniphier_spi_probe(struct platform_device *pdev)
|
|||
priv->is_save_param = false;
|
||||
|
||||
priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(priv->base)) {
|
||||
ret = PTR_ERR(priv->base);
|
||||
goto out_host_put;
|
||||
}
|
||||
if (IS_ERR(priv->base))
|
||||
return PTR_ERR(priv->base);
|
||||
|
||||
priv->base_dma_addr = res->start;
|
||||
|
||||
priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
|
||||
if (IS_ERR(priv->clk)) {
|
||||
dev_err(&pdev->dev, "failed to get clock\n");
|
||||
ret = PTR_ERR(priv->clk);
|
||||
goto out_host_put;
|
||||
return PTR_ERR(priv->clk);
|
||||
}
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
ret = irq;
|
||||
goto out_host_put;
|
||||
}
|
||||
if (irq < 0)
|
||||
return irq;
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
|
||||
0, "uniphier-spi", priv);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to request IRQ\n");
|
||||
goto out_host_put;
|
||||
return ret;
|
||||
}
|
||||
|
||||
init_completion(&priv->xfer_done);
|
||||
|
|
@ -710,10 +706,9 @@ static int uniphier_spi_probe(struct platform_device *pdev)
|
|||
|
||||
host->dma_tx = dma_request_chan(&pdev->dev, "tx");
|
||||
if (IS_ERR_OR_NULL(host->dma_tx)) {
|
||||
if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
|
||||
ret = -EPROBE_DEFER;
|
||||
goto out_host_put;
|
||||
}
|
||||
if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
host->dma_tx = NULL;
|
||||
dma_tx_burst = INT_MAX;
|
||||
} else {
|
||||
|
|
@ -762,8 +757,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
|
|||
host->dma_tx = NULL;
|
||||
}
|
||||
|
||||
out_host_put:
|
||||
spi_controller_put(host);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -771,16 +764,12 @@ static void uniphier_spi_remove(struct platform_device *pdev)
|
|||
{
|
||||
struct spi_controller *host = platform_get_drvdata(pdev);
|
||||
|
||||
spi_controller_get(host);
|
||||
|
||||
spi_unregister_controller(host);
|
||||
|
||||
if (host->dma_tx)
|
||||
dma_release_channel(host->dma_tx);
|
||||
if (host->dma_rx)
|
||||
dma_release_channel(host->dma_rx);
|
||||
|
||||
spi_controller_put(host);
|
||||
}
|
||||
|
||||
static const struct of_device_id uniphier_spi_match[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user