Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752307AbaDYPuh (ORCPT ); Fri, 25 Apr 2014 11:50:37 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:33267 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752160AbaDYPue (ORCPT ); Fri, 25 Apr 2014 11:50:34 -0400 Date: Fri, 25 Apr 2014 17:47:46 +0200 From: Andrew Lunn To: Gregory CLEMENT Cc: Mathias Nyman , Greg Kroah-Hartman , Felipe Balbi , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Thomas Petazzoni , Ezequiel Garcia , linux-arm-kernel@lists.infradead.org, Lior Amsalem , Tawfik Bayouk , Nadav Haklai , Grant Likely , Rob Herring , devicetree@vger.kernel.org Subject: Re: [PATCH v2 02/18] usb: host: xhci-plat: Add clocks support Message-ID: <20140425154746.GB12472@lunn.ch> 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 Content-Disposition: inline In-Reply-To: <1398434836-18908-3-git-send-email-gregory.clement@free-electrons.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 25, 2014 at 04:07:00PM +0200, Gregory CLEMENT wrote: > Some platform (such as the Armada 38x ones) can gate the clock of > their USB controller. This patch add the support for the clock, by > enabling them during probe and disabling them on remove. > > As not all platforms have clock support then enabling and disabling > the clocks have been placed in separate functions. Then if the clocks > are not supported we still can use the same calls, and there is no > > Signed-off-by: Gregory CLEMENT > --- > drivers/usb/host/xhci-plat.c | 52 ++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 50 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > index f5351af4b2c5..bb5d563f729c 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -11,6 +11,7 @@ > * version 2 as published by the Free Software Foundation. > */ > > +#include > #include > #include > #include > @@ -85,6 +86,42 @@ static const struct hc_driver xhci_plat_xhci_driver = { > .bus_resume = xhci_bus_resume, > }; > > +#if defined(CONFIG_HAVE_CLK) Hi Gregory You probably don't need to do this conditional on CONFIG_HAVE_CLK. There are stub functions in clk.h for when CONFIG_HAVE_CLK is not defined. So the compiler knows devm_clk_get() will return NULL, it can evaluate IS_ERR is false, clk_prepare() returns 0 and so the whole function collapses to "return 0;" > +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; Is ENODEV the correct error code? It would probably be better to return the return value of clk_prepare_enable() > + return 0; > +} -- 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/