Unverified Commit 22f40727 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Mark Brown
Browse files

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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230530081648.2199419-2-u.kleine-koenig@pengutronix.de


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent ac9a7868
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -1275,16 +1275,22 @@ static int mtk_spi_remove(struct platform_device *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;

	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);
		}
	}

	pm_runtime_put_noidle(&pdev->dev);
	pm_runtime_disable(&pdev->dev);