Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp538670imu; Tue, 20 Nov 2018 03:14:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXtC2KNfE6o5mgRRe0ydtknVGujhgL/uWgk9563KD4xmGjmJvQg6aHD7Q1yt5gCCmOJhWc X-Received: by 2002:a65:514c:: with SMTP id g12mr1474638pgq.169.1542712455621; Tue, 20 Nov 2018 03:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542712455; cv=none; d=google.com; s=arc-20160816; b=jZIXkaRLPm6XMKDTcjkgfiV0yJ67EZ3VF0AXsgTgkoFEUf/wBVH3galUt2mRCYGuOn 9WljkrxLIlFEIQescX7lXuAcFI7byLAN12WGc5TRYNGQRLETbpZX1bugDTbAPa+XftLN oexNK5le36TE1USF3EsFybXatPmIH2BnND1+1piVeXdbqpBaLaev5FLTa8voDoRY5MpY zxVdq4noZM1O4DAPW+cOPPHOPUYuwz28rnuQmBkh3LkWCRIblAKDDd60z0QbRLmtLFKz gBprqy2ecX1bEw8ftvwO6sAKSs24DvDSAyAm1KmEJS50PSTdYR/f/kGEL3X8KUYuhrPt cLfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=axX5h5105naGnyiHvllsAW1spKptfK5uTOJ4J4qbS5U=; b=J5eHeu1MMVpnsED+89426F/pZ61ax6vuNRjJAREn9Q2Hh6tMSA+JVDfZ3FTemEzghl YO86dCkrSGuyI+b5Q0NPrMZTP7/FMGt0NDhffvJRlIw+myI/s0ihHwZUWU4bdmMvNRdl V/GSZ+MV+G5clVB7Fhi69KRnuI1ZnpFfGSvx8Na557tV6QuTcTy4307ghbeXk3RykaHw tnIoJYhMUMpGP2CGAnnM/st+0ZV47UfaYrhwRPHoY1o+qguBGLmvtgA8yHaEns6+KRgb R10O+A54BiCzxwUmsRGbka1RBrnvMlWbj/xG/ZUAQeVCHxMEzSk2Q0Bexe5whTiwyaqo sfYA== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a28si47035377pgl.530.2018.11.20.03.14.00; Tue, 20 Nov 2018 03:14:15 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbeKTVlc (ORCPT + 99 others); Tue, 20 Nov 2018 16:41:32 -0500 Received: from mga12.intel.com ([192.55.52.136]:15322 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbeKTVlc (ORCPT ); Tue, 20 Nov 2018 16:41:32 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 03:12:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,256,1539673200"; d="scan'208";a="275426798" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by orsmga005.jf.intel.com with ESMTP; 20 Nov 2018 03:12:50 -0800 Received: from andy by smile with local (Exim 4.91) (envelope-from ) id 1gP3xY-0001Gy-Nw; Tue, 20 Nov 2018 13:12:48 +0200 Date: Tue, 20 Nov 2018 13:12:48 +0200 From: Andy Shevchenko To: Phil Edworthy Cc: Stephen Boyd , Michael Turquette , Russell King , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , Greg Ungerer , Geert Uytterhoeven , Ralf Baechle , Paul Burton , James Hogan , Jiaxun Yang , Huacai Chen , Guan Xuetao , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , "linux-m68k@lists.linux-m68k.org" , "linux-mips@linux-mips.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] clk: Add (devm_)clk_get_optional() functions Message-ID: <20181120111248.GW10650@smile.fi.intel.com> References: <20181119141259.11992-1-phil.edworthy@renesas.com> <20181120103832.GV10650@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 10:53:33AM +0000, Phil Edworthy wrote: > On 20 November 2018 10:39 Andy Shevchenko wrote: > > On Mon, Nov 19, 2018 at 02:12:59PM +0000, Phil Edworthy wrote: > > > 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. > > > - Instead of messing with the core functions, simply wrap them for the > > > _optional() versions. By putting clk_get_optional() inline in the header > > > file, we can get rid of the arch specific patches as well. > > Fine if it would have no surprises with error handling. > There shouldn't be any surprises. My earlier attempts at implementing this > were hampered by the fact that of_clk_get_by_name() can return -EINVAL > in some circumstances. By directly wrapping the (devm_)clk_get() functions > that problem goes away. Good! After my comments being addressed, Reviewed-by: Andy Shevchenko > > > + if (ERR_PTR(-ENOENT)) > Huh? That wasn't the code I sent... Yup, it's my wrong editing flow. Anyway, you got the idea. > > > + return NULL; > > > + else > > > + return clk; > > return clk == ERR_PTR(-ENOENT) ? NULL : clk; -- With Best Regards, Andy Shevchenko