Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3599945imu; Fri, 30 Nov 2018 03:05:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ww8xjgu1VSf7T2u0z7MRf8Jpw93F9tc9RmZsufyPrznItuyjs6OyOKlqM5/zNj7AmjQVYa X-Received: by 2002:a63:fe0a:: with SMTP id p10mr4389304pgh.265.1543575958831; Fri, 30 Nov 2018 03:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543575958; cv=none; d=google.com; s=arc-20160816; b=yzaSS6gqmyfu1WJ8s3GFhrXna/k94R4XA7wkcDLBnwJZbMk8KZNm9k+fI+2KegmKHV s6pPfgu9RxQspDYBlWxcLLPy4hHBkSMbRGIzIA86jb4jFb1AU3yfmqPW8b0pkFNrG72r 9u2tR6xKLTToLvBjFxj9SldbX/fORHsxkjguKzv+7DCeFjnbGsXUVd+e2nQ8tHF48U8q Y8z7h9NWkEFklVomT9O9VfTCsOB5542/95GIPHKkAWkio4VNFO7cqnfQgfXtE1qcQ+16 V2Cmg8m9bqISU+nxHbv816vCtuFSh2HJncYhEWU9TOcVMa/9J84Odc3Ol5pq3dM6Cn4Q eUQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uOiN9MPB6iVNWvNXV6KDBzuuE1bjGxDpYd42lwminN8=; b=KtfAiHHypfzP0MKmgLWPGmlSKcwzYz96bPe4fK3JXoTI2wNBI0B/WJtIsNXk6Fz7xS FujLTHAYF59vMrBtNZe0iSQ8qnqI7ykpYhxwm2jtxipBNPvDll7yIsDTeA201rLxsmwN O8b8nHi+l8Zzovv+tqyNgQbLWaRg944F81qWmNfKiTDSwDQQcZwJ9NU1idOVXJcAOc5G WdkfL+AQ7haweJjWJaP1bLYh5WdpgFbCx2IAPrb9Jt0+W17o/lAJIbFpdPw7XIczptD3 XkOuTS/DP0Jn4ZqLAyefTzsnlX8lrLBL3/GeSNwAPs1n2CuCkYibxPA3awwz2qD6nMr6 Va0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b="msZOa6/Q"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si5207544plg.29.2018.11.30.03.05.39; Fri, 30 Nov 2018 03:05:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b="msZOa6/Q"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726801AbeK3WN7 (ORCPT + 99 others); Fri, 30 Nov 2018 17:13:59 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:53072 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbeK3WN7 (ORCPT ); Fri, 30 Nov 2018 17:13:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uOiN9MPB6iVNWvNXV6KDBzuuE1bjGxDpYd42lwminN8=; b=msZOa6/Q5pOX2EOwznkvvnHnR A20/gy//c4Q766EJzTW1GV7+Rh3b0LvQMQf/yogdZwQn84///LNe/PZ3ZZRS0OgEGe9YytZWhXBiI bYf9HKDe+6czICbRuiku1p9393Ro2n/8xk0ndUQr416OzkaiYwMWniXQ2kWydVU1EY62s=; Received: from n2100.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:41092) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gSgbM-0007y7-Ou; Fri, 30 Nov 2018 11:04:52 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gSgbI-0005Q6-BF; Fri, 30 Nov 2018 11:04:48 +0000 Date: Fri, 30 Nov 2018 11:04:46 +0000 From: Russell King - ARM Linux To: Phil Edworthy Cc: Stephen Boyd , Michael Turquette , Andy Shevchenko , Geert Uytterhoeven , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v8] clk: Add (devm_)clk_get_optional() functions Message-ID: <20181130110446.GE30658@n2100.armlinux.org.uk> References: <20181120141445.21378-1-phil.edworthy@renesas.com> <154356894146.88331.4169293505438588293@swboyd.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 10:25:37AM +0000, Phil Edworthy wrote: > Hi Stephen, > > On 30 November 2018 09:09 Stephen Boyd wrote: > > Quoting Phil Edworthy (2018-11-20 06:14:45) > > > This adds clk_get_optional() and devm_clk_get_optional() functions to > > > get optional clocks. > > > They behave the same as (devm_)clk_get except where there is no clock > > > producer. In this case, instead of returning -ENOENT, the function > > > returns NULL. This makes error checking simpler and allows > > > clk_prepare_enable, etc to be called on the returned reference without > > > additional checks. > > > > Ok. I guess that works by virtue of how -ENOENT is returned by various > > functions that are called deeper in the clk_get() path? I'm cautiously > > optimistic. So cautious, we should probably add a comment to these optional > > functions that indicate they rely on the functions they call to return -ENOENT > > under the various conditions that make a clk optional. > Yes, it does indeed rely on how clk_get() is implemented. > Specifically, that if __of_clk_get_by_name() returns -EINVAL, the error is > superseded by clk_get_sys() returning -ENOENT. > As you say, a comment may help here. Each time the question of the optional clk_get() stuff comes up, we go around the same discussions time and time again. So far, each time has ended up flopping. Yes, clk_get() can only ever return -ENOENT if it falls back to the non-DT methods, because it assumes that the clk tables are complete (it can do nothing else.) I don't think it needs a comment because it's obvious from the code and also from the implementation point of view. > > > +static inline struct clk *clk_get_optional(struct device *dev, const > > > +char *id) > > > > Any kernel doc for this function? > I took my cue from the surrounding functions, let me know if I have to add it. I don't see you need to - this is an internal function by way of the "static inline" you have before it. It's not an API function. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up