[PATCH] phy: phy-twl4030-usb: Fix PM disable depth imbalance in twl4030_usb_probe

Zhang Shurong zhang_shurong at foxmail.com
Thu Oct 5 00:21:09 PDT 2023


The pm_runtime_enable function increases the power disable depth,
which means that we must perform a matching decrement on the error
handling path to maintain balance within the given context.
Additionally, we need to address the same issue for pm_runtime_get_sync.
We fix this by invoking pm_runtime_disable and pm_runtime_put_sync
when error returns.

Fixes: 96be39ab34b7 ("usb: phy: twl4030-usb: Fix regressions to runtime PM on omaps")
Fixes: 58a66dba1bea ("phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload")
Signed-off-by: Zhang Shurong <zhang_shurong at foxmail.com>
---
 drivers/phy/ti/phy-twl4030-usb.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c
index 6b265992d988..537562645009 100644
--- a/drivers/phy/ti/phy-twl4030-usb.c
+++ b/drivers/phy/ti/phy-twl4030-usb.c
@@ -773,19 +773,25 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 	if (status < 0) {
 		dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
 			twl->irq, status);
-		return status;
+		err = status;
+		goto err_put_rpm;
 	}
 
 	if (pdata)
 		err = phy_create_lookup(phy, "usb", "musb-hdrc.0");
 	if (err)
-		return err;
+		goto err_put_rpm;
 
 	pm_runtime_mark_last_busy(&pdev->dev);
 	pm_runtime_put_autosuspend(twl->dev);
 
 	dev_info(&pdev->dev, "Initialized TWL4030 USB module\n");
 	return 0;
+
+err_put_rpm:
+	pm_runtime_put_sync(twl->dev);
+	pm_runtime_disable(twl->dev);
+	return err;
 }
 
 static void twl4030_usb_remove(struct platform_device *pdev)
-- 
2.30.2




More information about the linux-phy mailing list