mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 21:53:44 +00:00
spi: spi-axi-spi-engine: Use helper function devm_clk_get_enabled()
Since commit 7ef9651e97
("clk: Provide new devm_clk helpers for prepared
and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
replaced by devm_clk_get_enabled() when driver enables (and possibly
prepares) the clocks for the whole lifetime of the device. Moreover, it is
no longer necessary to unprepare and disable the clocks explicitly.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230823133938.1359106-6-lizetao1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
b3422ea391
commit
a08199b309
@ -485,30 +485,22 @@ static int spi_engine_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
spin_lock_init(&spi_engine->lock);
|
spin_lock_init(&spi_engine->lock);
|
||||||
|
|
||||||
spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
|
spi_engine->clk = devm_clk_get_enabled(&pdev->dev, "s_axi_aclk");
|
||||||
if (IS_ERR(spi_engine->clk)) {
|
if (IS_ERR(spi_engine->clk)) {
|
||||||
ret = PTR_ERR(spi_engine->clk);
|
ret = PTR_ERR(spi_engine->clk);
|
||||||
goto err_put_host;
|
goto err_put_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
spi_engine->ref_clk = devm_clk_get(&pdev->dev, "spi_clk");
|
spi_engine->ref_clk = devm_clk_get_enabled(&pdev->dev, "spi_clk");
|
||||||
if (IS_ERR(spi_engine->ref_clk)) {
|
if (IS_ERR(spi_engine->ref_clk)) {
|
||||||
ret = PTR_ERR(spi_engine->ref_clk);
|
ret = PTR_ERR(spi_engine->ref_clk);
|
||||||
goto err_put_host;
|
goto err_put_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(spi_engine->clk);
|
|
||||||
if (ret)
|
|
||||||
goto err_put_host;
|
|
||||||
|
|
||||||
ret = clk_prepare_enable(spi_engine->ref_clk);
|
|
||||||
if (ret)
|
|
||||||
goto err_clk_disable;
|
|
||||||
|
|
||||||
spi_engine->base = devm_platform_ioremap_resource(pdev, 0);
|
spi_engine->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (IS_ERR(spi_engine->base)) {
|
if (IS_ERR(spi_engine->base)) {
|
||||||
ret = PTR_ERR(spi_engine->base);
|
ret = PTR_ERR(spi_engine->base);
|
||||||
goto err_ref_clk_disable;
|
goto err_put_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION);
|
version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION);
|
||||||
@ -518,7 +510,7 @@ static int spi_engine_probe(struct platform_device *pdev)
|
|||||||
SPI_ENGINE_VERSION_MINOR(version),
|
SPI_ENGINE_VERSION_MINOR(version),
|
||||||
SPI_ENGINE_VERSION_PATCH(version));
|
SPI_ENGINE_VERSION_PATCH(version));
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto err_ref_clk_disable;
|
goto err_put_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
|
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET);
|
||||||
@ -527,7 +519,7 @@ static int spi_engine_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host);
|
ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_ref_clk_disable;
|
goto err_put_host;
|
||||||
|
|
||||||
host->dev.of_node = pdev->dev.of_node;
|
host->dev.of_node = pdev->dev.of_node;
|
||||||
host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE;
|
host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE;
|
||||||
@ -545,10 +537,6 @@ static int spi_engine_probe(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
err_free_irq:
|
err_free_irq:
|
||||||
free_irq(irq, host);
|
free_irq(irq, host);
|
||||||
err_ref_clk_disable:
|
|
||||||
clk_disable_unprepare(spi_engine->ref_clk);
|
|
||||||
err_clk_disable:
|
|
||||||
clk_disable_unprepare(spi_engine->clk);
|
|
||||||
err_put_host:
|
err_put_host:
|
||||||
spi_controller_put(host);
|
spi_controller_put(host);
|
||||||
return ret;
|
return ret;
|
||||||
@ -569,9 +557,6 @@ static void spi_engine_remove(struct platform_device *pdev)
|
|||||||
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
|
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
|
||||||
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
|
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
|
||||||
writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
|
writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET);
|
||||||
|
|
||||||
clk_disable_unprepare(spi_engine->ref_clk);
|
|
||||||
clk_disable_unprepare(spi_engine->clk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id spi_engine_match_table[] = {
|
static const struct of_device_id spi_engine_match_table[] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user