summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2023-05-30 19:43:24 +0300
committerMark Brown <broonie@kernel.org>2023-05-30 19:43:24 +0300
commit0bbb363f86f2215571741bc945f6b9ec132ea1b8 (patch)
tree8c238f9ad054fdcb68a4838f401819b8ca78735f /drivers/spi
parent0178f1e5d9845a31024eddd37e93a182e2dbab5d (diff)
parent6f089e986778d3657247fdc2b38bd38de796732b (diff)
downloadlinux-0bbb363f86f2215571741bc945f6b9ec132ea1b8.tar.xz
spi: mt65xx: Convert to platform remove callback
Merge series from Uwe Kleine-König <u.kleine-koenig@pengutronix.de>: Hello, compared to (implicit) v1 sent in March with Message-Id: <20230309094704.2568531-1-u.kleine-koenig@pengutronix.de>, I reworked patch 1 on feedback by AngeloGioacchino Del Regno. Patches 2 and 3 got his Reviewed-by. Best regards Uwe Uwe Kleine-König (3): spi: mt65xx: Properly handle failures in .remove() spi: mt65xx: Convert to platform remove callback returning void spi: mt65xx: Don't disguise a "return 0" as "return ret" drivers/spi/spi-mt65xx.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) base-commit: ac9a78681b921877518763ba0e89202254349d1b -- 2.39.2
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-mt65xx.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 1501ee8459ff..ef64fc28f703 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -1270,27 +1270,31 @@ static int mtk_spi_probe(struct platform_device *pdev)
return 0;
}
-static int mtk_spi_remove(struct platform_device *pdev)
+static void mtk_spi_remove(struct platform_device *pdev)
{
struct spi_master *master = platform_get_drvdata(pdev);
struct mtk_spi *mdata = spi_master_get_devdata(master);
int ret;
- ret = pm_runtime_resume_and_get(&pdev->dev);
- if (ret < 0)
- return ret;
-
- mtk_spi_reset(mdata);
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret < 0) {
+ dev_warn(&pdev->dev, "Failed to resume hardware (%pe)\n", ERR_PTR(ret));
+ } else {
+ /*
+ * If pm runtime resume failed, clks are disabled and
+ * unprepared. So don't access the hardware and skip clk
+ * unpreparing.
+ */
+ mtk_spi_reset(mdata);
- if (mdata->dev_comp->no_need_unprepare) {
- clk_unprepare(mdata->spi_clk);
- clk_unprepare(mdata->spi_hclk);
+ if (mdata->dev_comp->no_need_unprepare) {
+ clk_unprepare(mdata->spi_clk);
+ clk_unprepare(mdata->spi_hclk);
+ }
}
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
-
- return 0;
}
#ifdef CONFIG_PM_SLEEP
@@ -1309,7 +1313,7 @@ static int mtk_spi_suspend(struct device *dev)
clk_disable_unprepare(mdata->spi_hclk);
}
- return ret;
+ return 0;
}
static int mtk_spi_resume(struct device *dev)
@@ -1410,7 +1414,7 @@ static struct platform_driver mtk_spi_driver = {
.of_match_table = mtk_spi_of_match,
},
.probe = mtk_spi_probe,
- .remove = mtk_spi_remove,
+ .remove_new = mtk_spi_remove,
};
module_platform_driver(mtk_spi_driver);