Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4098621imu; Fri, 30 Nov 2018 10:58:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/W8W6ChG7VMbpBlweCkTkG8eD7QjrG0mHjwNLjhUxS6eu3fEAvsCRh5eo1Ff2H3Ye5QXrkO X-Received: by 2002:a17:902:2bc5:: with SMTP id l63-v6mr6802302plb.241.1543604295425; Fri, 30 Nov 2018 10:58:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543604295; cv=none; d=google.com; s=arc-20160816; b=hnhnQ8ZFheHA+T07h8AsJk3167ezlySdiMwbi0XTL4a/TKTlr66CfeTNcxQQ0YA1Z9 muHnRWhVdRFryT04PxxNvWhwObeBXHGub9t7uVmzwF5qjOwwJRPYaxwIrHh2f596C0td V/XzGE92JHJhK8IS0o7Te4j0i2FJIwkizppCjsLBdY5En3aRH257alGDyZIepShKmLfo VeNGoH0NC4a3QgUCvJ0Q/XFRp2QqhxCMCUx2dJcL3Y6sd9KfrM9whCLDxgw5/VbgkUXH vyqYBPHTfLw2LdVaSYZuzHsK2QeL9I5ybZF7QRTcrJWJcQay8IxQdKVpbtk+IHKefhFS l8tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature; bh=EbKxi6nEComdY4RxGhOMHB5xw/mdqGAJF8jqZSbcx28=; b=Krdd9PmE5gbQqCjUb0swyu+ZaYjzGB83eI7WzOOoDHjx9k97cNsvHQoKL5oc3BSO6O oXvo5jjJjEcna1GBJLJLWMSv0kD3Yv+H9JWXpfZwF1ZEipJf3JI8G5th4Md/p/P2tJXn r6Pks9EjuBZQr0fTWIfc79NqLlZRkosTiVCtm6qhxe6EXzioE2g1AAsdIzQjcFFonSBz 3FLcJXTuJ4GduFptT7Mw4jbG9YhfrTgI0L0Uus8M/VdJg2qS/GY4Hv4eMwh3m6MUJxX+ GBpILYeApzGf5WK576EBH7D4C5MhG6lqRbaAkEWlJx8vZs4E32KpiHpmejw3euglQV7F rPLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tXUP6lLz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z19si6514687pfc.95.2018.11.30.10.58.01; Fri, 30 Nov 2018 10:58: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; dkim=pass header.i=@kernel.org header.s=default header.b=tXUP6lLz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbeLAGGD (ORCPT + 99 others); Sat, 1 Dec 2018 01:06:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:46746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbeLAGGD (ORCPT ); Sat, 1 Dec 2018 01:06:03 -0500 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51ABA20834; Fri, 30 Nov 2018 18:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543604149; bh=Yn3Kj8SjepGfVKMZ9qAYh+MpJuICHMTg+kf4tPrygn0=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=tXUP6lLzV2XfLkWPdc1GUCk8AHHsFkyadFUNgvBla2I/YUDWPkuJxLT2jxXgdIbhb IHyP4xRLjFVqw5AoihNXw1sBAUH7PRMjnVHT5tCNPpqdOw+H6eXKD098bS5IeSGK3D KI+pB+R0onnWJQLoe4Mp5xGAJqPiGko/CoZLaxMo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Phil Edworthy , Russell King - ARM Linux From: Stephen Boyd In-Reply-To: <20181130110446.GE30658@n2100.armlinux.org.uk> Cc: Michael Turquette , Andy Shevchenko , Geert Uytterhoeven , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" References: <20181120141445.21378-1-phil.edworthy@renesas.com> <154356894146.88331.4169293505438588293@swboyd.mtv.corp.google.com> <20181130110446.GE30658@n2100.armlinux.org.uk> Message-ID: <154360414857.88331.16753630865153792604@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v8] clk: Add (devm_)clk_get_optional() functions Date: Fri, 30 Nov 2018 10:55:48 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Russell King - ARM Linux (2018-11-30 03:04:46) > On Fri, Nov 30, 2018 at 10:25:37AM +0000, Phil Edworthy wrote: > > 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 clo= ck > > > > 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 with= out > > > > 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 op= tional > > > functions that indicate they rely on the functions they call to retur= n -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. Ok. I would still suggest a comment on of_clk_get_by_name() that indicates what types of return values happen in there. Otherwise it's obvious from the code after reading 3 or 4 functions deep (__of_clk_get_by_name -> __of_clk_get -> of_parse_phandle_with_args and __of_clk_get_from_provider) that this is what happens. > = > > > > +static inline struct clk *clk_get_optional(struct device *dev, con= st > > > > +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. It's static inline in a header file. That is an API function as far as I can tell.