From 3e2fd1ed0365d947c484cface37c5a3ea4e7ec3e Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Sun, 25 Feb 2024 04:22:51 +0100
Subject: [PATCH 244/463] spi fixes

---
 drivers/spi/spi-rockchip.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 65c14dddbdb99..5d0eb30c68c36 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -767,7 +767,7 @@ static int rockchip_spi_enable_clocks(struct rockchip_spi *rs, bool en)
 		clk_disable_unprepare(rs->apb_pclk);
 	}
 
-	rs->clk_enabled = en;
+	rs->clk_enabled = !!en;
 	return 0;
 }
 
@@ -814,6 +814,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
 		return PTR_ERR(rs->spiclk);
 	}
 
+	rs->clk_enabled = true;
 	spi_enable_chip(rs, false);
 
 	ret = platform_get_irq(pdev, 0);
@@ -922,7 +923,9 @@ static int rockchip_spi_probe(struct platform_device *pdev)
 	pm_runtime_set_autosuspend_delay(&pdev->dev, ROCKCHIP_AUTOSUSPEND_TIMEOUT);
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_set_active(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);
+	if (ret < 0)
+		goto err_pm_disable;
 
 	ret = devm_spi_register_controller(&pdev->dev, ctlr);
 	if (ret < 0) {
@@ -933,8 +936,6 @@ static int rockchip_spi_probe(struct platform_device *pdev)
 	return 0;
 
 err_pm_disable:
-	pm_runtime_dont_use_autosuspend(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
 	if (ctlr->dma_rx)
 		dma_release_channel(ctlr->dma_rx);
 err_free_dma_tx:
@@ -949,12 +950,6 @@ static void rockchip_spi_remove(struct platform_device *pdev)
 	struct spi_controller *ctlr = spi_controller_get(platform_get_drvdata(pdev));
 	struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
 
-	pm_runtime_get_sync(&pdev->dev);
-	//pm_runtime_dont_use_autosuspend(&pdev->dev);
-	pm_runtime_put_noidle(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
-
 	if (ctlr->dma_tx)
 		dma_release_channel(ctlr->dma_tx);
 	if (ctlr->dma_rx)
-- 
2.46.0

