Skip to content

Commit 24a4967

Browse files
digetxWolfram Sang
authored andcommitted
i2c: tegra: Properly disable runtime PM on driver's probe error
One of the recent Tegra I2C commits made a change that resumes runtime PM during driver's probe, but it missed to put the RPM in a case of error. Note that it's not correct to use pm_runtime_status_suspended because it breaks RPM refcounting. Fixes: 8ebf15e ("i2c: tegra: Move suspend handling to NOIRQ phase") Cc: <[email protected]> # v5.4+ Tested-by: Thierry Reding <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 9f42de8 commit 24a4967

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

drivers/i2c/busses/i2c-tegra.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,22 +1608,26 @@ static int tegra_i2c_probe(struct platform_device *pdev)
16081608
}
16091609

16101610
pm_runtime_enable(&pdev->dev);
1611-
if (!pm_runtime_enabled(&pdev->dev))
1611+
if (!pm_runtime_enabled(&pdev->dev)) {
16121612
ret = tegra_i2c_runtime_resume(&pdev->dev);
1613-
else
1613+
if (ret < 0) {
1614+
dev_err(&pdev->dev, "runtime resume failed\n");
1615+
goto unprepare_div_clk;
1616+
}
1617+
} else {
16141618
ret = pm_runtime_get_sync(i2c_dev->dev);
1615-
1616-
if (ret < 0) {
1617-
dev_err(&pdev->dev, "runtime resume failed\n");
1618-
goto unprepare_div_clk;
1619+
if (ret < 0) {
1620+
dev_err(&pdev->dev, "runtime resume failed\n");
1621+
goto disable_rpm;
1622+
}
16191623
}
16201624

16211625
if (i2c_dev->is_multimaster_mode) {
16221626
ret = clk_enable(i2c_dev->div_clk);
16231627
if (ret < 0) {
16241628
dev_err(i2c_dev->dev, "div_clk enable failed %d\n",
16251629
ret);
1626-
goto disable_rpm;
1630+
goto put_rpm;
16271631
}
16281632
}
16291633

@@ -1671,11 +1675,16 @@ static int tegra_i2c_probe(struct platform_device *pdev)
16711675
if (i2c_dev->is_multimaster_mode)
16721676
clk_disable(i2c_dev->div_clk);
16731677

1674-
disable_rpm:
1675-
pm_runtime_disable(&pdev->dev);
1676-
if (!pm_runtime_status_suspended(&pdev->dev))
1678+
put_rpm:
1679+
if (pm_runtime_enabled(&pdev->dev))
1680+
pm_runtime_put_sync(&pdev->dev);
1681+
else
16771682
tegra_i2c_runtime_suspend(&pdev->dev);
16781683

1684+
disable_rpm:
1685+
if (pm_runtime_enabled(&pdev->dev))
1686+
pm_runtime_disable(&pdev->dev);
1687+
16791688
unprepare_div_clk:
16801689
clk_unprepare(i2c_dev->div_clk);
16811690

0 commit comments

Comments
 (0)