From: Gabor Juhos <j4g8y7@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: Varadarajan Narayanan <quic_varada@quicinc.com>,
Sricharan Ramabadhran <quic_srichara@quicinc.com>,
Md Sadre Alam <quic_mdalam@quicinc.com>,
linux-spi@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, Gabor Juhos <j4g8y7@gmail.com>
Subject: [PATCH] spi: spi-qpic-snand: simplify clock handling by using devm_clk_get_enabled()
Date: Tue, 16 Sep 2025 19:43:46 +0200 [thread overview]
Message-ID: <20250916-qpic-snand-devm_clk_get_enabled-v1-1-09953493b7f1@gmail.com> (raw)
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>
next reply other threads:[~2025-09-16 17:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 17:43 Gabor Juhos [this message]
2025-09-19 14:11 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250916-qpic-snand-devm_clk_get_enabled-v1-1-09953493b7f1@gmail.com \
--to=j4g8y7@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=quic_mdalam@quicinc.com \
--cc=quic_srichara@quicinc.com \
--cc=quic_varada@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®