Skip to content

Commit 22f4072

Browse files
Uwe Kleine-Königbroonie
authored andcommitted
spi: mt65xx: Properly handle failures in .remove()
Returning an error code in a platform driver's remove function is wrong most of the time and there is an effort to make the callback return void. To prepare this rework the function not to exit early. There wasn't a real problem because if pm runtime resume failed the only step missing was pm_runtime_disable() which isn't an issue. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230530081648.2199419-2-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ac9a786 commit 22f4072

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

drivers/spi/spi-mt65xx.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,15 +1275,21 @@ static int mtk_spi_remove(struct platform_device *pdev)
12751275
struct mtk_spi *mdata = spi_master_get_devdata(master);
12761276
int ret;
12771277

1278-
ret = pm_runtime_resume_and_get(&pdev->dev);
1279-
if (ret < 0)
1280-
return ret;
1281-
1282-
mtk_spi_reset(mdata);
1278+
ret = pm_runtime_get_sync(&pdev->dev);
1279+
if (ret < 0) {
1280+
dev_warn(&pdev->dev, "Failed to resume hardware (%pe)\n", ERR_PTR(ret));
1281+
} else {
1282+
/*
1283+
* If pm runtime resume failed, clks are disabled and
1284+
* unprepared. So don't access the hardware and skip clk
1285+
* unpreparing.
1286+
*/
1287+
mtk_spi_reset(mdata);
12831288

1284-
if (mdata->dev_comp->no_need_unprepare) {
1285-
clk_unprepare(mdata->spi_clk);
1286-
clk_unprepare(mdata->spi_hclk);
1289+
if (mdata->dev_comp->no_need_unprepare) {
1290+
clk_unprepare(mdata->spi_clk);
1291+
clk_unprepare(mdata->spi_hclk);
1292+
}
12871293
}
12881294

12891295
pm_runtime_put_noidle(&pdev->dev);

0 commit comments

Comments
 (0)