Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1265123

[PATCH v2 1/8] phy: rockchip-usb: fix clock get-put mismatch

From Heiko Stuebner <heiko@sntech.de>
Newsgroups linux.kernel
Subject [PATCH v2 1/8] phy: rockchip-usb: fix clock get-put mismatch
Date 2015-11-08 17:10 +0100
Message-ID <qsAHx-2kS-31@gated-at.bofh.it> (permalink)
References <qsAHw-2kS-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently the phy driver only gets the optional clock reference but
never puts it again, neither during error handling nor on remove.
Fix that by moving the clk_put to a devm-action that gets called at
the right time when all other devm actions are done.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---
 drivers/phy/phy-rockchip-usb.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c
index 91d6f34..dfc056b 100644
--- a/drivers/phy/phy-rockchip-usb.c
+++ b/drivers/phy/phy-rockchip-usb.c
@@ -90,6 +90,14 @@ static const struct phy_ops ops = {
 	.owner		= THIS_MODULE,
 };
 
+static void rockchip_usb_phy_action(void *data)
+{
+	struct rockchip_usb_phy *rk_phy = data;
+
+	if (rk_phy->clk)
+		clk_put(rk_phy->clk);
+}
+
 static int rockchip_usb_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -124,6 +132,13 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 		if (IS_ERR(rk_phy->clk))
 			rk_phy->clk = NULL;
 
+		err = devm_add_action(dev, rockchip_usb_phy_action, rk_phy);
+		if (err) {
+			if (rk_phy->clk)
+				clk_put(rk_phy->clk);
+			return err;
+		}
+
 		rk_phy->phy = devm_phy_create(dev, child, &ops);
 		if (IS_ERR(rk_phy->phy)) {
 			dev_err(dev, "failed to create PHY\n");
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/8] phy: rockchip-usb: correct pll handling and usb-uart Heiko Stuebner <heiko@sntech.de> - 2015-11-08 17:10 +0100
  [PATCH v2 1/8] phy: rockchip-usb: fix clock get-put mismatch Heiko Stuebner <heiko@sntech.de> - 2015-11-08 17:10 +0100
  Re: [PATCH v2 0/8] phy: rockchip-usb: correct pll handling and usb-uart Doug Anderson <dianders@chromium.org> - 2015-11-09 22:20 +0100
    Re: [PATCH v2 0/8] phy: rockchip-usb: correct pll handling and usb-uart Heiko Stuebner <heiko@sntech.de> - 2015-11-09 22:30 +0100
      Re: [PATCH v2 0/8] phy: rockchip-usb: correct pll handling and usb-uart Doug Anderson <dianders@chromium.org> - 2015-11-09 22:40 +0100
        Re: [PATCH v2 0/8] phy: rockchip-usb: correct pll handling and usb-uart Heiko Stuebner <heiko@sntech.de> - 2015-11-09 22:50 +0100

csiph-web