From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD512C04EBA for ; Mon, 19 Nov 2018 10:46:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8DD1020831 for ; Mon, 19 Nov 2018 10:46:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DD1020831 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbeKSVJ1 (ORCPT ); Mon, 19 Nov 2018 16:09:27 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:39051 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbeKSVJ1 (ORCPT ); Mon, 19 Nov 2018 16:09:27 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gOh48-0001lt-Hc; Mon, 19 Nov 2018 11:46:04 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gOh47-0006cI-D9; Mon, 19 Nov 2018 11:46:03 +0100 Date: Mon, 19 Nov 2018 11:46:03 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Phil Edworthy Cc: Stephen Boyd , Michael Turquette , Andy Shevchenko , Russell King , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , Geert Uytterhoeven , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v6 1/6] clk: Add of_clk_get_by_name_optional() function Message-ID: <20181119104603.qzuvpoha622l4xvy@pengutronix.de> References: <20181116145937.27660-1-phil.edworthy@renesas.com> <20181116145937.27660-2-phil.edworthy@renesas.com> <20181116160128.pkuya6rwqm4schdn@pengutronix.de> <20181116161122.hhvslbzdujxpk3up@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Phil, On Mon, Nov 19, 2018 at 10:41:42AM +0000, Phil Edworthy wrote: > On 16 November 2018 16:11 Uwe Kleine-König wrote: > > On Fri, Nov 16, 2018 at 05:01:28PM +0100, Uwe Kleine-König wrote: > > > Other than that I think the patch is fine > > > > Thinking again, I wonder why not just do: > > > > static inline struct clk *clk_get_optional(struct device *dev, const char *id) { > > struct clk *c = clk_get(dev, id); > > > > if (c == ERR_PTR(-ENOENT)) > > return NULL; > > else > > return c; > > } > > Unfortunately, underneath this __of_clk_get_by_name() returns -EINVAL > when looking for a named clock, and the "clock-names" OF property can't > be found or the name is not in that prop. This is because the index > returned by of_property_match_string() will be an error code and is then > currently always passed to __of_clk_get(). > > If, as you said, I split the patches into one that fixes the error code, and then > adds clk_get_optional() like above, it will make more sense. Sounds like a good plan. > btw, do we need to add of_clk_get_by_name_optional()? I only added it as a > counterpart to of_clk_get_by_name(), but it may not be needed. I don't need it. Given that it is easy to add when someone has a need, I'd say, skip it for now. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from metis.ext.pengutronix.de ([85.220.165.71]:47323 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbeKSVJ2 (ORCPT ); Mon, 19 Nov 2018 16:09:28 -0500 Date: Mon, 19 Nov 2018 11:46:03 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Phil Edworthy Cc: Stephen Boyd , Michael Turquette , Andy Shevchenko , Russell King , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , Geert Uytterhoeven , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v6 1/6] clk: Add of_clk_get_by_name_optional() function Message-ID: <20181119104603.qzuvpoha622l4xvy@pengutronix.de> References: <20181116145937.27660-1-phil.edworthy@renesas.com> <20181116145937.27660-2-phil.edworthy@renesas.com> <20181116160128.pkuya6rwqm4schdn@pengutronix.de> <20181116161122.hhvslbzdujxpk3up@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-renesas-soc-owner@vger.kernel.org List-ID: Hello Phil, On Mon, Nov 19, 2018 at 10:41:42AM +0000, Phil Edworthy wrote: > On 16 November 2018 16:11 Uwe Kleine-K�nig wrote: > > On Fri, Nov 16, 2018 at 05:01:28PM +0100, Uwe Kleine-K�nig wrote: > > > Other than that I think the patch is fine > > > > Thinking again, I wonder why not just do: > > > > static inline struct clk *clk_get_optional(struct device *dev, const char *id) { > > struct clk *c = clk_get(dev, id); > > > > if (c == ERR_PTR(-ENOENT)) > > return NULL; > > else > > return c; > > } > > Unfortunately, underneath this __of_clk_get_by_name() returns -EINVAL > when looking for a named clock, and the "clock-names" OF property can't > be found or the name is not in that prop. This is because the index > returned by of_property_match_string() will be an error code and is then > currently always passed to __of_clk_get(). > > If, as you said, I split the patches into one that fixes the error code, and then > adds clk_get_optional() like above, it will make more sense. Sounds like a good plan. > btw, do we need to add of_clk_get_by_name_optional()? I only added it as a > counterpart to of_clk_get_by_name(), but it may not be needed. I don't need it. Given that it is easy to add when someone has a need, I'd say, skip it for now. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K�nig | Industrial Linux Solutions | http://www.pengutronix.de/ | From mboxrd@z Thu Jan 1 00:00:00 1970 From: u.kleine-koenig@pengutronix.de (Uwe =?iso-8859-1?Q?Kleine-K=F6nig?=) Date: Mon, 19 Nov 2018 11:46:03 +0100 Subject: [PATCH v6 1/6] clk: Add of_clk_get_by_name_optional() function In-Reply-To: References: <20181116145937.27660-1-phil.edworthy@renesas.com> <20181116145937.27660-2-phil.edworthy@renesas.com> <20181116160128.pkuya6rwqm4schdn@pengutronix.de> <20181116161122.hhvslbzdujxpk3up@pengutronix.de> Message-ID: <20181119104603.qzuvpoha622l4xvy@pengutronix.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hello Phil, On Mon, Nov 19, 2018 at 10:41:42AM +0000, Phil Edworthy wrote: > On 16 November 2018 16:11 Uwe Kleine-K?nig wrote: > > On Fri, Nov 16, 2018 at 05:01:28PM +0100, Uwe Kleine-K?nig wrote: > > > Other than that I think the patch is fine > > > > Thinking again, I wonder why not just do: > > > > static inline struct clk *clk_get_optional(struct device *dev, const char *id) { > > struct clk *c = clk_get(dev, id); > > > > if (c == ERR_PTR(-ENOENT)) > > return NULL; > > else > > return c; > > } > > Unfortunately, underneath this __of_clk_get_by_name() returns -EINVAL > when looking for a named clock, and the "clock-names" OF property can't > be found or the name is not in that prop. This is because the index > returned by of_property_match_string() will be an error code and is then > currently always passed to __of_clk_get(). > > If, as you said, I split the patches into one that fixes the error code, and then > adds clk_get_optional() like above, it will make more sense. Sounds like a good plan. > btw, do we need to add of_clk_get_by_name_optional()? I only added it as a > counterpart to of_clk_get_by_name(), but it may not be needed. I don't need it. Given that it is easy to add when someone has a need, I'd say, skip it for now. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |