i2c: xiic: Make sure to disable clock on .remove()

If for whatever reasons pm_runtime_resume_and_get() failed, .remove() is
exited early, the clock isn't freed and runtime PM state isn't reset.

The right thing to do however is to free all resources that don't need
HW access after a problem with runtime PM. Also issue a warning in that
case and return 0 to suppress a less helpful warning by the driver core.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
Uwe Kleine-König 2022-10-19 22:28:08 +02:00 коммит произвёл Wolfram Sang
Родитель 3256412fc5
Коммит 810199f731
1 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -858,11 +858,14 @@ static int xiic_i2c_remove(struct platform_device *pdev)
/* remove adapter & data */
i2c_del_adapter(&i2c->adap);
ret = pm_runtime_resume_and_get(i2c->dev);
if (ret < 0)
return ret;
ret = pm_runtime_get_sync(i2c->dev);
if (ret < 0)
dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n",
ERR_PTR(ret));
else
xiic_deinit(i2c);
pm_runtime_put_sync(i2c->dev);
clk_disable_unprepare(i2c->clk);
pm_runtime_disable(&pdev->dev);