[PATCH] spi: orion: handle clock failures on runtime resume

Luo Yifan luoyifan at cmss.chinamobile.com
Mon Nov 16 18:06:46 PST 2026


orion_spi_runtime_resume() ignores the return value of
clk_prepare_enable() for the AXI clock and returns the result of the
second call.  If the first clock fails, the function still enables the
second one and reports success, and if the second clock fails the AXI
clock is left enabled.

Check both calls and undo the first one when the second fails.

Signed-off-by: Luo Yifan <luoyifan at cmss.chinamobile.com>
---
 drivers/spi/spi-orion.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index b8882229c0..9c3c16449c 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -825,9 +825,19 @@ static int orion_spi_runtime_resume(struct device *dev)
 {
 	struct spi_controller *host = dev_get_drvdata(dev);
 	struct orion_spi *spi = spi_controller_get_devdata(host);
+	int ret;
+
+	ret = clk_prepare_enable(spi->axi_clk);
+	if (ret)
+		return ret;
 
-	clk_prepare_enable(spi->axi_clk);
-	return clk_prepare_enable(spi->clk);
+	ret = clk_prepare_enable(spi->clk);
+	if (ret) {
+		clk_disable_unprepare(spi->axi_clk);
+		return ret;
+	}
+
+	return 0;
 }
 
 static const struct dev_pm_ops orion_spi_pm_ops = {
-- 
2.24.4






More information about the linux-arm-kernel mailing list