* [PATCH 0/4] cleanups in spi
@ 2026-04-04 3:44 Pei Xiao
2026-04-04 3:44 ` [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback Pei Xiao
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Pei Xiao @ 2026-04-04 3:44 UTC (permalink / raw)
To: broonie, gch981213, linux-spi, linux-mediatek; +Cc: Pei Xiao
hi Mark,
Some cleanups in spi. Thanks!
1.spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
It might be that the previous unused variable caused it not to be merged.
2.spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled()
It was not merged. Upon checking, runtime is not used.
3.spi: mtk-snfi: unregister ECC engine on probe failure and remove()
callback
'copy from' b0dc7e7c56573e7a52080f25f3179a45f3dd7e6f
spi: amlogic: spifc-a4: unregister ECC engine on probe failure and remove() callback
4.ch341
In Chinese, the pronunciation of this manufacturer includes an 'n' sound.
It's a bit strange that the manufacturer's name was wrong, so I still want
to correct it.
Pei Xiao (4):
spi: mtk-snfi: unregister ECC engine on probe failure and remove()
callback
spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled()
spi: ch341: Correct vendor name
drivers/spi/spi-ch341.c | 4 ++--
drivers/spi/spi-mtk-snfi.c | 14 ++++++++++++++
drivers/spi/spi-uniphier.c | 18 ++++--------------
drivers/spi/spi-zynq-qspi.c | 31 ++++++-------------------------
4 files changed, 26 insertions(+), 41 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback
2026-04-04 3:44 [PATCH 0/4] cleanups in spi Pei Xiao
@ 2026-04-04 3:44 ` Pei Xiao
2026-04-06 12:53 ` Mark Brown
2026-04-04 3:44 ` [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled() Pei Xiao
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Pei Xiao @ 2026-04-04 3:44 UTC (permalink / raw)
To: broonie, gch981213, linux-spi, linux-mediatek; +Cc: Pei Xiao
mtk_snand_probe() registers the on-host NAND ECC engine, but teardown was
missing from both probe unwind and remove-time cleanup. Add a devm cleanup
action after successful registration so
nand_ecc_unregister_on_host_hw_engine() runs automatically on probe
failures and during device removal.
Fixes: 764f1b748164 ("spi: add driver for MTK SPI NAND Flash Interface")
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
drivers/spi/spi-mtk-snfi.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index 437edbd658aa..3973b5f9a9ca 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -1303,6 +1303,13 @@ static const struct spi_controller_mem_caps mtk_snand_mem_caps = {
.ecc = true,
};
+static void mtk_unregister_ecc_engine(void *data)
+{
+ struct nand_ecc_engine *eng = data;
+
+ nand_ecc_unregister_on_host_hw_engine(eng);
+}
+
static irqreturn_t mtk_snand_irq(int irq, void *id)
{
struct mtk_snand *snf = id;
@@ -1443,6 +1450,13 @@ static int mtk_snand_probe(struct platform_device *pdev)
goto release_ecc;
}
+ ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
+ &ms->ecc_eng);
+ if (ret) {
+ dev_err(&pdev->dev, ret, "failed to add ECC unregister action\n");
+ goto release_ecc;
+ }
+
ctlr->num_chipselect = 1;
ctlr->mem_ops = &mtk_snand_mem_ops;
ctlr->mem_caps = &mtk_snand_mem_caps;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
2026-04-04 3:44 [PATCH 0/4] cleanups in spi Pei Xiao
2026-04-04 3:44 ` [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback Pei Xiao
@ 2026-04-04 3:44 ` Pei Xiao
2026-04-06 12:56 ` Mark Brown
2026-04-04 3:45 ` [PATCH 3/4] spi: zynq-qspi: " Pei Xiao
2026-04-04 3:45 ` [PATCH 4/4] spi: ch341: Correct vendor name Pei Xiao
3 siblings, 1 reply; 10+ messages in thread
From: Pei Xiao @ 2026-04-04 3:44 UTC (permalink / raw)
To: broonie, gch981213, linux-spi, linux-mediatek; +Cc: Pei Xiao
Replace devm_clk_get() followed by clk_prepare_enable() with
devm_clk_get_enabled() for the clock. This removes the need for
explicit clock enable and disable calls, as the managed API automatically
handles clock disabling on device removal or probe failure.
Remove the now-unnecessary clk_disable_unprepare() calls from the probe
error path and the remove callback. Adjust error labels accordingly.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
drivers/spi/spi-uniphier.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c
index 9e1d364a6198..1b815ee2ed1b 100644
--- a/drivers/spi/spi-uniphier.c
+++ b/drivers/spi/spi-uniphier.c
@@ -666,28 +666,24 @@ static int uniphier_spi_probe(struct platform_device *pdev)
}
priv->base_dma_addr = res->start;
- priv->clk = devm_clk_get(&pdev->dev, NULL);
+ priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(priv->clk);
goto out_host_put;
}
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- goto out_host_put;
-
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
ret = irq;
- goto out_disable_clk;
+ goto out_host_put;
}
ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
0, "uniphier-spi", priv);
if (ret) {
dev_err(&pdev->dev, "failed to request IRQ\n");
- goto out_disable_clk;
+ goto out_host_put;
}
init_completion(&priv->xfer_done);
@@ -716,7 +712,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
if (IS_ERR_OR_NULL(host->dma_tx)) {
if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
ret = -EPROBE_DEFER;
- goto out_disable_clk;
+ goto out_host_put;
}
host->dma_tx = NULL;
dma_tx_burst = INT_MAX;
@@ -766,9 +762,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
host->dma_tx = NULL;
}
-out_disable_clk:
- clk_disable_unprepare(priv->clk);
-
out_host_put:
spi_controller_put(host);
return ret;
@@ -777,14 +770,11 @@ static int uniphier_spi_probe(struct platform_device *pdev)
static void uniphier_spi_remove(struct platform_device *pdev)
{
struct spi_controller *host = platform_get_drvdata(pdev);
- struct uniphier_spi_priv *priv = spi_controller_get_devdata(host);
if (host->dma_tx)
dma_release_channel(host->dma_tx);
if (host->dma_rx)
dma_release_channel(host->dma_rx);
-
- clk_disable_unprepare(priv->clk);
}
static const struct of_device_id uniphier_spi_match[] = {
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled()
2026-04-04 3:44 [PATCH 0/4] cleanups in spi Pei Xiao
2026-04-04 3:44 ` [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback Pei Xiao
2026-04-04 3:44 ` [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled() Pei Xiao
@ 2026-04-04 3:45 ` Pei Xiao
2026-04-06 12:57 ` Mark Brown
2026-04-04 3:45 ` [PATCH 4/4] spi: ch341: Correct vendor name Pei Xiao
3 siblings, 1 reply; 10+ messages in thread
From: Pei Xiao @ 2026-04-04 3:45 UTC (permalink / raw)
To: broonie, gch981213, linux-spi, linux-mediatek; +Cc: Pei Xiao
Replace devm_clk_get() followed by clk_prepare_enable() with
devm_clk_get_enabled() for both "pclk" and "ref_clk". This removes
the need for explicit clock enable and disable calls, as the managed
API automatically disables the clocks on device removal or probe
failure.
Remove the now-unnecessary clk_disable_unprepare() calls from the
probe error paths and the remove callback. Simplify error handling
by jumping directly to the remove_ctlr label.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
drivers/spi/spi-zynq-qspi.c | 31 ++++++-------------------------
1 file changed, 6 insertions(+), 25 deletions(-)
diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c
index 5232483c4a3a..8c3975030d0a 100644
--- a/drivers/spi/spi-zynq-qspi.c
+++ b/drivers/spi/spi-zynq-qspi.c
@@ -661,7 +661,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
goto remove_ctlr;
}
- xqspi->pclk = devm_clk_get(&pdev->dev, "pclk");
+ xqspi->pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
if (IS_ERR(xqspi->pclk)) {
dev_err(&pdev->dev, "pclk clock not found.\n");
ret = PTR_ERR(xqspi->pclk);
@@ -670,36 +670,24 @@ static int zynq_qspi_probe(struct platform_device *pdev)
init_completion(&xqspi->data_completion);
- xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk");
+ xqspi->refclk = devm_clk_get_enabled(&pdev->dev, "ref_clk");
if (IS_ERR(xqspi->refclk)) {
dev_err(&pdev->dev, "ref_clk clock not found.\n");
ret = PTR_ERR(xqspi->refclk);
goto remove_ctlr;
}
- ret = clk_prepare_enable(xqspi->pclk);
- if (ret) {
- dev_err(&pdev->dev, "Unable to enable APB clock.\n");
- goto remove_ctlr;
- }
-
- ret = clk_prepare_enable(xqspi->refclk);
- if (ret) {
- dev_err(&pdev->dev, "Unable to enable device clock.\n");
- goto clk_dis_pclk;
- }
-
xqspi->irq = platform_get_irq(pdev, 0);
if (xqspi->irq < 0) {
ret = xqspi->irq;
- goto clk_dis_all;
+ goto remove_ctlr;
}
ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq,
0, pdev->name, xqspi);
if (ret != 0) {
ret = -ENXIO;
dev_err(&pdev->dev, "request_irq failed\n");
- goto clk_dis_all;
+ goto remove_ctlr;
}
ret = of_property_read_u32(np, "num-cs",
@@ -709,7 +697,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
} else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) {
ret = -EINVAL;
dev_err(&pdev->dev, "only 2 chip selects are available\n");
- goto clk_dis_all;
+ goto remove_ctlr;
} else {
ctlr->num_chipselect = num_cs;
}
@@ -728,15 +716,11 @@ static int zynq_qspi_probe(struct platform_device *pdev)
ret = devm_spi_register_controller(&pdev->dev, ctlr);
if (ret) {
dev_err(&pdev->dev, "devm_spi_register_controller failed\n");
- goto clk_dis_all;
+ goto remove_ctlr;
}
return ret;
-clk_dis_all:
- clk_disable_unprepare(xqspi->refclk);
-clk_dis_pclk:
- clk_disable_unprepare(xqspi->pclk);
remove_ctlr:
spi_controller_put(ctlr);
@@ -758,9 +742,6 @@ static void zynq_qspi_remove(struct platform_device *pdev)
struct zynq_qspi *xqspi = platform_get_drvdata(pdev);
zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0);
-
- clk_disable_unprepare(xqspi->refclk);
- clk_disable_unprepare(xqspi->pclk);
}
static const struct of_device_id zynq_qspi_of_match[] = {
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] spi: ch341: Correct vendor name
2026-04-04 3:44 [PATCH 0/4] cleanups in spi Pei Xiao
` (2 preceding siblings ...)
2026-04-04 3:45 ` [PATCH 3/4] spi: zynq-qspi: " Pei Xiao
@ 2026-04-04 3:45 ` Pei Xiao
3 siblings, 0 replies; 10+ messages in thread
From: Pei Xiao @ 2026-04-04 3:45 UTC (permalink / raw)
To: broonie, gch981213, linux-spi, linux-mediatek; +Cc: Pei Xiao
The usb2spi ch341a is manufactured by QinHeng Electronics, not QiHeng.
Update the driver description and the initial comment to reflect the
correct vendor name.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
drivers/spi/spi-ch341.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-ch341.c b/drivers/spi/spi-ch341.c
index 3eaa8f176f63..396c17274187 100644
--- a/drivers/spi/spi-ch341.c
+++ b/drivers/spi/spi-ch341.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
//
-// QiHeng Electronics ch341a USB-to-SPI adapter driver
+// QinHeng Electronics ch341a USB-to-SPI adapter driver
//
// Copyright (C) 2024 Johannes Thumshirn <jth@kernel.org>
//
@@ -250,5 +250,5 @@ static struct usb_driver ch341a_usb_driver = {
module_usb_driver(ch341a_usb_driver);
MODULE_AUTHOR("Johannes Thumshirn <jth@kernel.org>");
-MODULE_DESCRIPTION("QiHeng Electronics ch341 USB2SPI");
+MODULE_DESCRIPTION("QinHeng Electronics ch341 USB2SPI");
MODULE_LICENSE("GPL v2");
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback
2026-04-04 3:44 ` [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback Pei Xiao
@ 2026-04-06 12:53 ` Mark Brown
2026-04-07 7:26 ` Pei Xiao
0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2026-04-06 12:53 UTC (permalink / raw)
To: Pei Xiao; +Cc: gch981213, linux-spi, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 581 bytes --]
On Sat, Apr 04, 2026 at 11:44:58AM +0800, Pei Xiao wrote:
> + ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
> + &ms->ecc_eng);
> + if (ret) {
> + dev_err(&pdev->dev, ret, "failed to add ECC unregister action\n");
> + goto release_ecc;
> + }
This should either be dev_err(), in which case ret is not a format
string and this is buggy (I'm surprised it compiles without warnings...)
or it should be dev_err_probe() in which case the arguments are correct.
The latter is a little better, though it's unlikely to make a practical
difference here.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
2026-04-04 3:44 ` [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled() Pei Xiao
@ 2026-04-06 12:56 ` Mark Brown
2026-04-07 0:56 ` Pei Xiao
0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2026-04-06 12:56 UTC (permalink / raw)
To: Pei Xiao, Kunihiko Hayashi, Masami Hiramatsu
Cc: gch981213, linux-spi, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 3118 bytes --]
On Sat, Apr 04, 2026 at 11:44:59AM +0800, Pei Xiao wrote:
> Replace devm_clk_get() followed by clk_prepare_enable() with
> devm_clk_get_enabled() for the clock. This removes the need for
> explicit clock enable and disable calls, as the managed API automatically
> handles clock disabling on device removal or probe failure.
Copying in the maintainers for the driver, you should generally copy
maintainers when posting patches (and to avoid large CC lists it's often
better to send patches per driver unless the series is actually related,
this one isn't).
> Remove the now-unnecessary clk_disable_unprepare() calls from the probe
> error path and the remove callback. Adjust error labels accordingly.
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> drivers/spi/spi-uniphier.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c
> index 9e1d364a6198..1b815ee2ed1b 100644
> --- a/drivers/spi/spi-uniphier.c
> +++ b/drivers/spi/spi-uniphier.c
> @@ -666,28 +666,24 @@ static int uniphier_spi_probe(struct platform_device *pdev)
> }
> priv->base_dma_addr = res->start;
>
> - priv->clk = devm_clk_get(&pdev->dev, NULL);
> + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(priv->clk)) {
> dev_err(&pdev->dev, "failed to get clock\n");
> ret = PTR_ERR(priv->clk);
> goto out_host_put;
> }
>
> - ret = clk_prepare_enable(priv->clk);
> - if (ret)
> - goto out_host_put;
> -
> irq = platform_get_irq(pdev, 0);
> if (irq < 0) {
> ret = irq;
> - goto out_disable_clk;
> + goto out_host_put;
> }
>
> ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
> 0, "uniphier-spi", priv);
> if (ret) {
> dev_err(&pdev->dev, "failed to request IRQ\n");
> - goto out_disable_clk;
> + goto out_host_put;
> }
>
> init_completion(&priv->xfer_done);
> @@ -716,7 +712,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
> if (IS_ERR_OR_NULL(host->dma_tx)) {
> if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
> ret = -EPROBE_DEFER;
> - goto out_disable_clk;
> + goto out_host_put;
> }
> host->dma_tx = NULL;
> dma_tx_burst = INT_MAX;
> @@ -766,9 +762,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
> host->dma_tx = NULL;
> }
>
> -out_disable_clk:
> - clk_disable_unprepare(priv->clk);
> -
> out_host_put:
> spi_controller_put(host);
> return ret;
> @@ -777,14 +770,11 @@ static int uniphier_spi_probe(struct platform_device *pdev)
> static void uniphier_spi_remove(struct platform_device *pdev)
> {
> struct spi_controller *host = platform_get_drvdata(pdev);
> - struct uniphier_spi_priv *priv = spi_controller_get_devdata(host);
>
> if (host->dma_tx)
> dma_release_channel(host->dma_tx);
> if (host->dma_rx)
> dma_release_channel(host->dma_rx);
> -
> - clk_disable_unprepare(priv->clk);
> }
>
> static const struct of_device_id uniphier_spi_match[] = {
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] spi: zynq-qspi: Simplify clock handling with devm_clk_get_enabled()
2026-04-04 3:45 ` [PATCH 3/4] spi: zynq-qspi: " Pei Xiao
@ 2026-04-06 12:57 ` Mark Brown
0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2026-04-06 12:57 UTC (permalink / raw)
To: Pei Xiao, Michal Simek; +Cc: gch981213, linux-spi, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 3681 bytes --]
On Sat, Apr 04, 2026 at 11:45:00AM +0800, Pei Xiao wrote:
> Replace devm_clk_get() followed by clk_prepare_enable() with
> devm_clk_get_enabled() for both "pclk" and "ref_clk". This removes
> the need for explicit clock enable and disable calls, as the managed
> API automatically disables the clocks on device removal or probe
> failure.
Copying the driver maintainer.
> Remove the now-unnecessary clk_disable_unprepare() calls from the
> probe error paths and the remove callback. Simplify error handling
> by jumping directly to the remove_ctlr label.
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> drivers/spi/spi-zynq-qspi.c | 31 ++++++-------------------------
> 1 file changed, 6 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c
> index 5232483c4a3a..8c3975030d0a 100644
> --- a/drivers/spi/spi-zynq-qspi.c
> +++ b/drivers/spi/spi-zynq-qspi.c
> @@ -661,7 +661,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
> goto remove_ctlr;
> }
>
> - xqspi->pclk = devm_clk_get(&pdev->dev, "pclk");
> + xqspi->pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
> if (IS_ERR(xqspi->pclk)) {
> dev_err(&pdev->dev, "pclk clock not found.\n");
> ret = PTR_ERR(xqspi->pclk);
> @@ -670,36 +670,24 @@ static int zynq_qspi_probe(struct platform_device *pdev)
>
> init_completion(&xqspi->data_completion);
>
> - xqspi->refclk = devm_clk_get(&pdev->dev, "ref_clk");
> + xqspi->refclk = devm_clk_get_enabled(&pdev->dev, "ref_clk");
> if (IS_ERR(xqspi->refclk)) {
> dev_err(&pdev->dev, "ref_clk clock not found.\n");
> ret = PTR_ERR(xqspi->refclk);
> goto remove_ctlr;
> }
>
> - ret = clk_prepare_enable(xqspi->pclk);
> - if (ret) {
> - dev_err(&pdev->dev, "Unable to enable APB clock.\n");
> - goto remove_ctlr;
> - }
> -
> - ret = clk_prepare_enable(xqspi->refclk);
> - if (ret) {
> - dev_err(&pdev->dev, "Unable to enable device clock.\n");
> - goto clk_dis_pclk;
> - }
> -
> xqspi->irq = platform_get_irq(pdev, 0);
> if (xqspi->irq < 0) {
> ret = xqspi->irq;
> - goto clk_dis_all;
> + goto remove_ctlr;
> }
> ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq,
> 0, pdev->name, xqspi);
> if (ret != 0) {
> ret = -ENXIO;
> dev_err(&pdev->dev, "request_irq failed\n");
> - goto clk_dis_all;
> + goto remove_ctlr;
> }
>
> ret = of_property_read_u32(np, "num-cs",
> @@ -709,7 +697,7 @@ static int zynq_qspi_probe(struct platform_device *pdev)
> } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) {
> ret = -EINVAL;
> dev_err(&pdev->dev, "only 2 chip selects are available\n");
> - goto clk_dis_all;
> + goto remove_ctlr;
> } else {
> ctlr->num_chipselect = num_cs;
> }
> @@ -728,15 +716,11 @@ static int zynq_qspi_probe(struct platform_device *pdev)
> ret = devm_spi_register_controller(&pdev->dev, ctlr);
> if (ret) {
> dev_err(&pdev->dev, "devm_spi_register_controller failed\n");
> - goto clk_dis_all;
> + goto remove_ctlr;
> }
>
> return ret;
>
> -clk_dis_all:
> - clk_disable_unprepare(xqspi->refclk);
> -clk_dis_pclk:
> - clk_disable_unprepare(xqspi->pclk);
> remove_ctlr:
> spi_controller_put(ctlr);
>
> @@ -758,9 +742,6 @@ static void zynq_qspi_remove(struct platform_device *pdev)
> struct zynq_qspi *xqspi = platform_get_drvdata(pdev);
>
> zynq_qspi_write(xqspi, ZYNQ_QSPI_ENABLE_OFFSET, 0);
> -
> - clk_disable_unprepare(xqspi->refclk);
> - clk_disable_unprepare(xqspi->pclk);
> }
>
> static const struct of_device_id zynq_qspi_of_match[] = {
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled()
2026-04-06 12:56 ` Mark Brown
@ 2026-04-07 0:56 ` Pei Xiao
0 siblings, 0 replies; 10+ messages in thread
From: Pei Xiao @ 2026-04-07 0:56 UTC (permalink / raw)
To: Mark Brown, Kunihiko Hayashi, Masami Hiramatsu
Cc: gch981213, linux-spi, linux-mediatek
在 2026/4/6 20:56, Mark Brown 写道:
> On Sat, Apr 04, 2026 at 11:44:59AM +0800, Pei Xiao wrote:
>> Replace devm_clk_get() followed by clk_prepare_enable() with
>> devm_clk_get_enabled() for the clock. This removes the need for
>> explicit clock enable and disable calls, as the managed API automatically
>> handles clock disabling on device removal or probe failure.
>
> Copying in the maintainers for the driver, you should generally copy
> maintainers when posting patches (and to avoid large CC lists it's often
> better to send patches per driver unless the series is actually related,
> this one isn't).
>
Yes, I only sent it to you to avoid CC'ing too many people.
I will send these patches separately to the corresponding maintainers.
Thank you!
Pei.
>> Remove the now-unnecessary clk_disable_unprepare() calls from the probe
>> error path and the remove callback. Adjust error labels accordingly.
>>
>> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
>> ---
>> drivers/spi/spi-uniphier.c | 18 ++++--------------
>> 1 file changed, 4 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c
>> index 9e1d364a6198..1b815ee2ed1b 100644
>> --- a/drivers/spi/spi-uniphier.c
>> +++ b/drivers/spi/spi-uniphier.c
>> @@ -666,28 +666,24 @@ static int uniphier_spi_probe(struct platform_device *pdev)
>> }
>> priv->base_dma_addr = res->start;
>>
>> - priv->clk = devm_clk_get(&pdev->dev, NULL);
>> + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>> if (IS_ERR(priv->clk)) {
>> dev_err(&pdev->dev, "failed to get clock\n");
>> ret = PTR_ERR(priv->clk);
>> goto out_host_put;
>> }
>>
>> - ret = clk_prepare_enable(priv->clk);
>> - if (ret)
>> - goto out_host_put;
>> -
>> irq = platform_get_irq(pdev, 0);
>> if (irq < 0) {
>> ret = irq;
>> - goto out_disable_clk;
>> + goto out_host_put;
>> }
>>
>> ret = devm_request_irq(&pdev->dev, irq, uniphier_spi_handler,
>> 0, "uniphier-spi", priv);
>> if (ret) {
>> dev_err(&pdev->dev, "failed to request IRQ\n");
>> - goto out_disable_clk;
>> + goto out_host_put;
>> }
>>
>> init_completion(&priv->xfer_done);
>> @@ -716,7 +712,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)
>> if (IS_ERR_OR_NULL(host->dma_tx)) {
>> if (PTR_ERR(host->dma_tx) == -EPROBE_DEFER) {
>> ret = -EPROBE_DEFER;
>> - goto out_disable_clk;
>> + goto out_host_put;
>> }
>> host->dma_tx = NULL;
>> dma_tx_burst = INT_MAX;
>> @@ -766,9 +762,6 @@ static int uniphier_spi_probe(struct platform_device *pdev)
>> host->dma_tx = NULL;
>> }
>>
>> -out_disable_clk:
>> - clk_disable_unprepare(priv->clk);
>> -
>> out_host_put:
>> spi_controller_put(host);
>> return ret;
>> @@ -777,14 +770,11 @@ static int uniphier_spi_probe(struct platform_device *pdev)
>> static void uniphier_spi_remove(struct platform_device *pdev)
>> {
>> struct spi_controller *host = platform_get_drvdata(pdev);
>> - struct uniphier_spi_priv *priv = spi_controller_get_devdata(host);
>>
>> if (host->dma_tx)
>> dma_release_channel(host->dma_tx);
>> if (host->dma_rx)
>> dma_release_channel(host->dma_rx);
>> -
>> - clk_disable_unprepare(priv->clk);
>> }
>>
>> static const struct of_device_id uniphier_spi_match[] = {
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback
2026-04-06 12:53 ` Mark Brown
@ 2026-04-07 7:26 ` Pei Xiao
0 siblings, 0 replies; 10+ messages in thread
From: Pei Xiao @ 2026-04-07 7:26 UTC (permalink / raw)
To: Mark Brown; +Cc: gch981213, linux-spi, linux-mediatek
在 2026/4/6 20:53, Mark Brown 写道:
> On Sat, Apr 04, 2026 at 11:44:58AM +0800, Pei Xiao wrote:
>
>> + ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
>> + &ms->ecc_eng);
>> + if (ret) {
>> + dev_err(&pdev->dev, ret, "failed to add ECC unregister action\n");
>> + goto release_ecc;
>> + }
>
> This should either be dev_err(), in which case ret is not a format
> string and this is buggy (I'm surprised it compiles without warnings...)
> or it should be dev_err_probe() in which case the arguments are correct.
ok, thanks a lot, from a person make bug.
I will send v2.
Pei.
> The latter is a little better, though it's unlikely to make a practical
> difference here.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-04-07 7:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-04 3:44 [PATCH 0/4] cleanups in spi Pei Xiao
2026-04-04 3:44 ` [PATCH 1/4] spi: mtk-snfi: unregister ECC engine on probe failure and remove() callback Pei Xiao
2026-04-06 12:53 ` Mark Brown
2026-04-07 7:26 ` Pei Xiao
2026-04-04 3:44 ` [PATCH 2/4] spi: uniphier: Simplify clock handling with devm_clk_get_enabled() Pei Xiao
2026-04-06 12:56 ` Mark Brown
2026-04-07 0:56 ` Pei Xiao
2026-04-04 3:45 ` [PATCH 3/4] spi: zynq-qspi: " Pei Xiao
2026-04-06 12:57 ` Mark Brown
2026-04-04 3:45 ` [PATCH 4/4] spi: ch341: Correct vendor name Pei Xiao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox