drivers/spi/spi-qpic-snand.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-)
The devm_clk_get_enabled() function prepares and enables the
particular clock, which then automatically gets disabled and
unprepared on probe failure and on device removal.
Use that function instead of devm_clk_get() and remove the
clk_prepare_enable()/clk_disable_unprepare() calls in order
to simplify the code.
This also ensures that the clocks are handled in the correct
order during device removal.
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
drivers/spi/spi-qpic-snand.c | 29 +++--------------------------
1 file changed, 3 insertions(+), 26 deletions(-)
diff --git a/drivers/spi/spi-qpic-snand.c b/drivers/spi/spi-qpic-snand.c
index 28755dbce399d836ab6209e44f02f05532386344..58ceea1ea8fb4e02b4c9989a38d1ea38520d88b0 100644
--- a/drivers/spi/spi-qpic-snand.c
+++ b/drivers/spi/spi-qpic-snand.c
@@ -1542,15 +1542,15 @@ static int qcom_spi_probe(struct platform_device *pdev)
snandc->props = dev_data;
- snandc->core_clk = devm_clk_get(dev, "core");
+ snandc->core_clk = devm_clk_get_enabled(dev, "core");
if (IS_ERR(snandc->core_clk))
return PTR_ERR(snandc->core_clk);
- snandc->aon_clk = devm_clk_get(dev, "aon");
+ snandc->aon_clk = devm_clk_get_enabled(dev, "aon");
if (IS_ERR(snandc->aon_clk))
return PTR_ERR(snandc->aon_clk);
- snandc->qspi->iomacro_clk = devm_clk_get(dev, "iom");
+ snandc->qspi->iomacro_clk = devm_clk_get_enabled(dev, "iom");
if (IS_ERR(snandc->qspi->iomacro_clk))
return PTR_ERR(snandc->qspi->iomacro_clk);
@@ -1564,18 +1564,6 @@ static int qcom_spi_probe(struct platform_device *pdev)
if (dma_mapping_error(dev, snandc->base_dma))
return -ENXIO;
- ret = clk_prepare_enable(snandc->core_clk);
- if (ret)
- goto err_dis_core_clk;
-
- ret = clk_prepare_enable(snandc->aon_clk);
- if (ret)
- goto err_dis_aon_clk;
-
- ret = clk_prepare_enable(snandc->qspi->iomacro_clk);
- if (ret)
- goto err_dis_iom_clk;
-
ret = qcom_nandc_alloc(snandc);
if (ret)
goto err_snand_alloc;
@@ -1616,12 +1604,6 @@ static int qcom_spi_probe(struct platform_device *pdev)
err_spi_init:
qcom_nandc_unalloc(snandc);
err_snand_alloc:
- clk_disable_unprepare(snandc->qspi->iomacro_clk);
-err_dis_iom_clk:
- clk_disable_unprepare(snandc->aon_clk);
-err_dis_aon_clk:
- clk_disable_unprepare(snandc->core_clk);
-err_dis_core_clk:
dma_unmap_resource(dev, res->start, resource_size(res),
DMA_BIDIRECTIONAL, 0);
return ret;
@@ -1636,11 +1618,6 @@ static void qcom_spi_remove(struct platform_device *pdev)
spi_unregister_controller(ctlr);
nand_ecc_unregister_on_host_hw_engine(&snandc->qspi->ecc_eng);
qcom_nandc_unalloc(snandc);
-
- clk_disable_unprepare(snandc->aon_clk);
- clk_disable_unprepare(snandc->core_clk);
- clk_disable_unprepare(snandc->qspi->iomacro_clk);
-
dma_unmap_resource(&pdev->dev, snandc->base_dma, resource_size(res),
DMA_BIDIRECTIONAL, 0);
}
---
base-commit: b28a55db452edb1d997edee723d8dcbef7f065a3
change-id: 20250910-qpic-snand-devm_clk_get_enabled-6b71a9d6f2bb
Best regards,
--
Gabor Juhos <j4g8y7@gmail.com>
On Tue, 16 Sep 2025 19:43:46 +0200, Gabor Juhos wrote: > The devm_clk_get_enabled() function prepares and enables the > particular clock, which then automatically gets disabled and > unprepared on probe failure and on device removal. > > Use that function instead of devm_clk_get() and remove the > clk_prepare_enable()/clk_disable_unprepare() calls in order > to simplify the code. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next Thanks! [1/1] spi: spi-qpic-snand: simplify clock handling by using devm_clk_get_enabled() commit: a24802b0a2a238eaa610b0b0e87a4500a35de64a All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
© 2016 - 2025 Red Hat, Inc.