Commit c32cb76e authored by Li Zetao's avatar Li Zetao Committed by Mark Brown

spi: spi-cavium-thunderx: Use helper function devm_clk_get_enabled()

Since commit 7ef9651e ("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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230823133938.1359106-10-lizetao1@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f64b1600
...@@ -49,16 +49,12 @@ static int thunderx_spi_probe(struct pci_dev *pdev, ...@@ -49,16 +49,12 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
p->regs.tx = 0x1010; p->regs.tx = 0x1010;
p->regs.data = 0x1080; p->regs.data = 0x1080;
p->clk = devm_clk_get(dev, NULL); p->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(p->clk)) { if (IS_ERR(p->clk)) {
ret = PTR_ERR(p->clk); ret = PTR_ERR(p->clk);
goto error; goto error;
} }
ret = clk_prepare_enable(p->clk);
if (ret)
goto error;
p->sys_freq = clk_get_rate(p->clk); p->sys_freq = clk_get_rate(p->clk);
if (!p->sys_freq) if (!p->sys_freq)
p->sys_freq = SYS_FREQ_DEFAULT; p->sys_freq = SYS_FREQ_DEFAULT;
...@@ -82,7 +78,6 @@ static int thunderx_spi_probe(struct pci_dev *pdev, ...@@ -82,7 +78,6 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
return 0; return 0;
error: error:
clk_disable_unprepare(p->clk);
pci_release_regions(pdev); pci_release_regions(pdev);
spi_controller_put(host); spi_controller_put(host);
return ret; return ret;
...@@ -97,7 +92,6 @@ static void thunderx_spi_remove(struct pci_dev *pdev) ...@@ -97,7 +92,6 @@ static void thunderx_spi_remove(struct pci_dev *pdev)
if (!p) if (!p)
return; return;
clk_disable_unprepare(p->clk);
pci_release_regions(pdev); pci_release_regions(pdev);
/* Put everything in a known state. */ /* Put everything in a known state. */
writeq(0, p->register_base + OCTEON_SPI_CFG(p)); writeq(0, p->register_base + OCTEON_SPI_CFG(p));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment