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: 8ebf15e9c869 ("i2c: tegra: Move suspend handling to NOIRQ phase")
Cc: <stable@vger.kernel.org> # v5.4+
Tested-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by Dmitry Osipenko and committed by Wolfram Sang 24a49678 9f42de8d

Changed files
+19 -10
drivers
i2c
busses
+19 -10
drivers/i2c/busses/i2c-tegra.c
··· 1608 1608 } 1609 1609 1610 1610 pm_runtime_enable(&pdev->dev); 1611 - if (!pm_runtime_enabled(&pdev->dev)) 1611 + if (!pm_runtime_enabled(&pdev->dev)) { 1612 1612 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 { 1614 1618 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 + } 1619 1623 } 1620 1624 1621 1625 if (i2c_dev->is_multimaster_mode) { ··· 1627 1623 if (ret < 0) { 1628 1624 dev_err(i2c_dev->dev, "div_clk enable failed %d\n", 1629 1625 ret); 1630 - goto disable_rpm; 1626 + goto put_rpm; 1631 1627 } 1632 1628 } 1633 1629 ··· 1675 1671 if (i2c_dev->is_multimaster_mode) 1676 1672 clk_disable(i2c_dev->div_clk); 1677 1673 1678 - disable_rpm: 1679 - pm_runtime_disable(&pdev->dev); 1680 - if (!pm_runtime_status_suspended(&pdev->dev)) 1674 + put_rpm: 1675 + if (pm_runtime_enabled(&pdev->dev)) 1676 + pm_runtime_put_sync(&pdev->dev); 1677 + else 1681 1678 tegra_i2c_runtime_suspend(&pdev->dev); 1679 + 1680 + disable_rpm: 1681 + if (pm_runtime_enabled(&pdev->dev)) 1682 + pm_runtime_disable(&pdev->dev); 1682 1683 1683 1684 unprepare_div_clk: 1684 1685 clk_unprepare(i2c_dev->div_clk);