From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King - ARM Linux Subject: Re: [PATCH v2 02/18] usb: host: xhci-plat: Add clocks support Date: Fri, 25 Apr 2014 15:20:49 +0100 Message-ID: <20140425142049.GR26756@n2100.arm.linux.org.uk> References: <1398434836-18908-1-git-send-email-gregory.clement@free-electrons.com> <1398434836-18908-3-git-send-email-gregory.clement@free-electrons.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1398434836-18908-3-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Gregory CLEMENT Cc: Mathias Nyman , Greg Kroah-Hartman , Felipe Balbi , linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Thomas Petazzoni , Lior Amsalem , Tawfik Bayouk , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Nadav Haklai , Rob Herring , Ezequiel Garcia , Grant Likely , linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: devicetree@vger.kernel.org On Fri, Apr 25, 2014 at 04:07:00PM +0200, Gregory CLEMENT wrote: > +#if defined(CONFIG_HAVE_CLK) > +static int try_enable_clk(struct platform_device *pdev) > +{ > + struct clk *clk = devm_clk_get(&pdev->dev, NULL); > + > + /* Not all platforms have a clk so it is not an error if the clock > + does not exists. */ > + if (!IS_ERR(clk)) > + if (clk_prepare_enable(clk)) > + return -ENODEV; > + return 0; > +} > + > +static int try_disable_clk(struct platform_device *pdev) > +{ > + struct clk *clk = devm_clk_get(&pdev->dev, NULL); > + > + /* Not all platforms have a clk so it is not an error if the clock > + does not exists. */ > + if (!IS_ERR(clk)) > + clk_disable_unprepare(clk); > + > + return 0; > +} OMG. You do realise that clk_get() ref-counts against the module which provided the clock, so this is akin to an explicit leaking module ref-counts. -- FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly improving, and getting towards what was expected from it. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html