Skip to content

Commit

Permalink
phy: omap-usb2: Balance pm_runtime_enable() on probe failure and remove
Browse files Browse the repository at this point in the history
If probe fails then we need to call pm_runtime_disable() to balance
out the previous pm_runtime_enable() call. Else it will cause
unbalanced pm_runtime_enable() call in the succeding probe call.

This anomaly was observed when the call to devm_phy_create() failed
with -EPROBE_DEFER.

Balance out the pm_runtime_enable() call in .remove() as well.

Signed-off-by: Roger Quadros <[email protected]>
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Roger Quadros authored and gregkh committed Jul 12, 2014
1 parent e73b49f commit eb82a3d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/phy/phy-omap-usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,20 @@ static int omap_usb2_probe(struct platform_device *pdev)
otg->phy = &phy->phy;

platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev);

generic_phy = devm_phy_create(phy->dev, &ops, NULL);
if (IS_ERR(generic_phy))
return PTR_ERR(generic_phy);

phy_set_drvdata(generic_phy, phy);

pm_runtime_enable(phy->dev);
phy_provider = devm_of_phy_provider_register(phy->dev,
of_phy_simple_xlate);
if (IS_ERR(phy_provider))
if (IS_ERR(phy_provider)) {
pm_runtime_disable(phy->dev);
return PTR_ERR(phy_provider);
}

phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
if (IS_ERR(phy->wkupclk)) {
Expand Down Expand Up @@ -317,6 +319,7 @@ static int omap_usb2_remove(struct platform_device *pdev)
if (!IS_ERR(phy->optclk))
clk_unprepare(phy->optclk);
usb_remove_phy(&phy->phy);
pm_runtime_disable(phy->dev);

return 0;
}
Expand Down

0 comments on commit eb82a3d

Please sign in to comment.