mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
spi: ti-qspi: 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-18-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
3a14bf4f54
commit
76a24627b9
|
|
@ -765,7 +765,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
|
|||
int ret = 0, num_cs, irq;
|
||||
dma_cap_mask_t mask;
|
||||
|
||||
host = spi_alloc_host(&pdev->dev, sizeof(*qspi));
|
||||
host = devm_spi_alloc_host(&pdev->dev, sizeof(*qspi));
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -793,8 +793,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
|
|||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (r == NULL) {
|
||||
dev_err(&pdev->dev, "missing platform data\n");
|
||||
ret = -ENODEV;
|
||||
goto free_host;
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -812,28 +811,22 @@ static int ti_qspi_probe(struct platform_device *pdev)
|
|||
qspi->mmap_size = resource_size(res_mmap);
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
ret = irq;
|
||||
goto free_host;
|
||||
}
|
||||
if (irq < 0)
|
||||
return irq;
|
||||
|
||||
mutex_init(&qspi->list_lock);
|
||||
|
||||
qspi->base = devm_ioremap_resource(&pdev->dev, r);
|
||||
if (IS_ERR(qspi->base)) {
|
||||
ret = PTR_ERR(qspi->base);
|
||||
goto free_host;
|
||||
}
|
||||
if (IS_ERR(qspi->base))
|
||||
return PTR_ERR(qspi->base);
|
||||
|
||||
|
||||
if (of_property_present(np, "syscon-chipselects")) {
|
||||
qspi->ctrl_base =
|
||||
syscon_regmap_lookup_by_phandle_args(np, "syscon-chipselects",
|
||||
1, &qspi->ctrl_reg);
|
||||
if (IS_ERR(qspi->ctrl_base)) {
|
||||
ret = PTR_ERR(qspi->ctrl_base);
|
||||
goto free_host;
|
||||
}
|
||||
if (IS_ERR(qspi->ctrl_base))
|
||||
return PTR_ERR(qspi->ctrl_base);
|
||||
}
|
||||
|
||||
qspi->fclk = devm_clk_get(&pdev->dev, "fck");
|
||||
|
|
@ -895,8 +888,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
|
|||
ti_qspi_dma_cleanup(qspi);
|
||||
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
free_host:
|
||||
spi_controller_put(host);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -904,16 +896,12 @@ static void ti_qspi_remove(struct platform_device *pdev)
|
|||
{
|
||||
struct ti_qspi *qspi = platform_get_drvdata(pdev);
|
||||
|
||||
spi_controller_get(qspi->host);
|
||||
|
||||
spi_unregister_controller(qspi->host);
|
||||
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
ti_qspi_dma_cleanup(qspi);
|
||||
|
||||
spi_controller_put(qspi->host);
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops ti_qspi_pm_ops = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user