Skip to contentSkip to conversation

phy: stih41x-usb: Fixup stih41x_usb_phy_power_on failure path

PATCH New Axel Lin 2 participants 2 messages Mar 17, 2015 Generic PHY framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 phy: stih41x-usb: Fixup stih41x_usb_phy_power_on failure path

If stih41x_usb_phy_power_on() fails, we need to call clk_disable_unprepare() before return error. This is to ensure we have balanced clk_enable/disable calls.

---
 drivers/phy/phy-stih41x-usb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/phy/phy-stih41x-usb.c +6 -2
index a603801..c093b47 100644
@@ -87,8 +87,12 @@ static int stih41x_usb_phy_power_on(struct phy *phy)
 		return ret;
 	}
 
-	return regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,
-			phy_dev->cfg->oscok, phy_dev->cfg->oscok);
+	ret = regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,
+				 phy_dev->cfg->oscok, phy_dev->cfg->oscok);
+	if (ret)
+		clk_disable_unprepare(phy_dev->clk);
+
+	return ret;
 }
 
 static int stih41x_usb_phy_power_off(struct phy *phy)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 phy: stih41x-usb: Fixup stih41x_usb_phy_power_on failure path

Hi Axel

Quoted 18 lines · Axel Lin

If stih41x_usb_phy_power_on() fails, we need to call clk_disable_unprepare() before return error. This is to ensure we have balanced clk_enable/disable calls.

---
  drivers/phy/phy-stih41x-usb.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
drivers/phy/phy-stih41x-usb.c +0 -1
index a603801..c093b47 100644
@@ -87,8 +87,12 @@ static int stih41x_usb_phy_power_on(struct phy *phy)
  		return ret;
  	}
 
-	return regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,

drivers/phy/phy-stih41x-usb.c static int stih41x_usb_phy_power_on(struct phy *phy) · line 98

Quoted 10 lines
drivers/phy/phy-stih41x-usb.c +6 -1
-			phy_dev->cfg->oscok, phy_dev->cfg->oscok);
+	ret = regmap_update_bits(phy_dev->regmap, phy_dev->cfg->syscfg,
+				 phy_dev->cfg->oscok, phy_dev->cfg->oscok);
+	if (ret)
+		clk_disable_unprepare(phy_dev->clk);
+
+	return ret;
  }
 
  static int stih41x_usb_phy_power_off(struct phy *phy)

Thanks