From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753587AbbKMG3f (ORCPT ); Fri, 13 Nov 2015 01:29:35 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:47948 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751032AbbKMG3e (ORCPT ); Fri, 13 Nov 2015 01:29:34 -0500 Subject: Re: [PATCH 1/8] phy: rockchip-usb: fix clock get-put mismatch To: Heiko Stuebner , , References: <1446673454-9529-1-git-send-email-heiko@sntech.de> <1446673454-9529-2-git-send-email-heiko@sntech.de> CC: , , , , , From: Kishon Vijay Abraham I Message-ID: <56458323.6040506@ti.com> Date: Fri, 13 Nov 2015 11:58:51 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446673454-9529-2-git-send-email-heiko@sntech.de> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thursday 05 November 2015 03:14 AM, Heiko Stuebner wrote: > 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 > --- > 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); If devm_add_action is added before clk_get this check wouldn't be required at all. Thanks Kishon