mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-21 23:57:36 -04:00
spi: img-spfi: 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/20260429091333.165363-14-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
@@ -530,7 +530,7 @@ static int img_spfi_probe(struct platform_device *pdev)
|
||||
int ret;
|
||||
u32 max_speed_hz;
|
||||
|
||||
host = spi_alloc_host(&pdev->dev, sizeof(*spfi));
|
||||
host = devm_spi_alloc_host(&pdev->dev, sizeof(*spfi));
|
||||
if (!host)
|
||||
return -ENOMEM;
|
||||
platform_set_drvdata(pdev, host);
|
||||
@@ -541,36 +541,32 @@ static int img_spfi_probe(struct platform_device *pdev)
|
||||
spin_lock_init(&spfi->lock);
|
||||
|
||||
spfi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(spfi->regs)) {
|
||||
ret = PTR_ERR(spfi->regs);
|
||||
goto put_spi;
|
||||
}
|
||||
if (IS_ERR(spfi->regs))
|
||||
return PTR_ERR(spfi->regs);
|
||||
|
||||
spfi->phys = res->start;
|
||||
|
||||
spfi->irq = platform_get_irq(pdev, 0);
|
||||
if (spfi->irq < 0) {
|
||||
ret = spfi->irq;
|
||||
goto put_spi;
|
||||
}
|
||||
if (spfi->irq < 0)
|
||||
return spfi->irq;
|
||||
|
||||
ret = devm_request_irq(spfi->dev, spfi->irq, img_spfi_irq,
|
||||
IRQ_TYPE_LEVEL_HIGH, dev_name(spfi->dev), spfi);
|
||||
if (ret)
|
||||
goto put_spi;
|
||||
return ret;
|
||||
|
||||
spfi->sys_clk = devm_clk_get(spfi->dev, "sys");
|
||||
if (IS_ERR(spfi->sys_clk)) {
|
||||
ret = PTR_ERR(spfi->sys_clk);
|
||||
goto put_spi;
|
||||
}
|
||||
if (IS_ERR(spfi->sys_clk))
|
||||
return PTR_ERR(spfi->sys_clk);
|
||||
|
||||
spfi->spfi_clk = devm_clk_get(spfi->dev, "spfi");
|
||||
if (IS_ERR(spfi->spfi_clk)) {
|
||||
ret = PTR_ERR(spfi->spfi_clk);
|
||||
goto put_spi;
|
||||
}
|
||||
if (IS_ERR(spfi->spfi_clk))
|
||||
return PTR_ERR(spfi->spfi_clk);
|
||||
|
||||
ret = clk_prepare_enable(spfi->sys_clk);
|
||||
if (ret)
|
||||
goto put_spi;
|
||||
return ret;
|
||||
|
||||
ret = clk_prepare_enable(spfi->spfi_clk);
|
||||
if (ret)
|
||||
goto disable_pclk;
|
||||
@@ -658,8 +654,6 @@ static int img_spfi_probe(struct platform_device *pdev)
|
||||
clk_disable_unprepare(spfi->spfi_clk);
|
||||
disable_pclk:
|
||||
clk_disable_unprepare(spfi->sys_clk);
|
||||
put_spi:
|
||||
spi_controller_put(host);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -669,8 +663,6 @@ static void img_spfi_remove(struct platform_device *pdev)
|
||||
struct spi_controller *host = platform_get_drvdata(pdev);
|
||||
struct img_spfi *spfi = spi_controller_get_devdata(host);
|
||||
|
||||
spi_controller_get(host);
|
||||
|
||||
spi_unregister_controller(host);
|
||||
|
||||
if (spfi->tx_ch)
|
||||
@@ -683,8 +675,6 @@ static void img_spfi_remove(struct platform_device *pdev)
|
||||
clk_disable_unprepare(spfi->spfi_clk);
|
||||
clk_disable_unprepare(spfi->sys_clk);
|
||||
}
|
||||
|
||||
spi_controller_put(host);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
|
||||
Reference in New Issue
Block a user