From patchwork Fri Nov 16 14:59:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Edworthy X-Patchwork-Id: 10686421 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46F2117DE for ; Fri, 16 Nov 2018 15:00:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 349082BB97 for ; Fri, 16 Nov 2018 15:00:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28E3A2C634; Fri, 16 Nov 2018 15:00:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76B812BB97 for ; Fri, 16 Nov 2018 15:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728124AbeKQBMt (ORCPT ); Fri, 16 Nov 2018 20:12:49 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:26039 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728079AbeKQBMt (ORCPT ); Fri, 16 Nov 2018 20:12:49 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie5.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:03 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id B0E8FE3A6D; Sat, 17 Nov 2018 00:00:03 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.56,240,1539615600"; d="scan'208";a="297674437" Received: from unknown (HELO vbox.ree.adwin.renesas.com) ([10.226.37.67]) by relmlii2.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:00 +0900 From: Phil Edworthy To: Stephen Boyd , Michael Turquette , Andy Shevchenko , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Phil Edworthy , Geert Uytterhoeven , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 1/6] clk: Add of_clk_get_by_name_optional() function Date: Fri, 16 Nov 2018 14:59:32 +0000 Message-Id: <20181116145937.27660-2-phil.edworthy@renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116145937.27660-1-phil.edworthy@renesas.com> References: <20181116145937.27660-1-phil.edworthy@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Quite a few drivers get an optional clock, e.g. a clock required to access a peripheral's registers that is always enabled on some devices. This adds the of_clk_get_by_name_optional() function for this purpose. This function behaves the same as of_clk_get_by_name() except that it will return NULL instead of -ENOENT. This allows for simpler error handling in the callers. Signed-off-by: Phil Edworthy --- *Warning* This changes the return values for of_clk_get_by_name() in some cases. If the name arg is non-NULL, and the "clock-names" OF property can't be found or the name is not in that prop, the code used to return -EINVAL, but will now return -ENOENT. Note that before and after this patch, if name=NULL and no "clocks" OF property has been found, of_clk_get_by_name() returns -ENOENT. I believe the new behaviour is correct. I cannot find any callers to of_clk_get_by_name() that explicitly check for -EINVAL or -ENOENT, but there is the possibility that something will break at runtime with this change. v6: - Rework the __of_clk_get_by_name() logic so as to avoid duplicate tests. v5: - Simplified the code by handling all the error conditions on exit v4: - For optional named clocks of_property_match_string() will return -EINVAL if the "clock-names" property is missing, or -ENODATA if the specified clock name in the "clock-names" property is missing. If we then call __of_clk_get() with these errors as the index, we get clk = -EINVAL. This is then filtered later on so users don't see it. However, if the clock is not named, __of_clk_get() will return -ENOENT is the clock provide is not there. So for optional named clocks, use index to determine if the clock provider is there or not, and for unnamed clocks, simply check if __of_clk_get() returns -ENOENT. v3: - Fix check for clock not present. __of_clk_get() returns -EINVAL if it's not there. Cover case of when there is no clock name. - of_clk_get_by_name_optional() should return NULL if !np. - Add dummy version of of_clk_get_by_name_optional() for the !OF || !COMMON_CLK case. --- drivers/clk/clkdev.c | 76 ++++++++++++++++++++++++++++++++++++-------- include/linux/clk.h | 6 ++++ 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 9ab3db8b3988..0c655d1ba1d9 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -52,9 +52,19 @@ struct clk *of_clk_get(struct device_node *np, int index) } EXPORT_SYMBOL(of_clk_get); +/* + * This function tries to find a clock provider. + * If a name is provided, the function looks for a clock with that name in the + * OF node's "clock-names" property. If not found, the function will try the + * parent node and so on until a matching property is found or we reach the + * top of the tree. + * When no clock provider is found, if optional is true, the function will + * return NULL, otherwise return -ENOENT. + */ static struct clk *__of_clk_get_by_name(struct device_node *np, const char *dev_id, - const char *name) + const char *name, + bool optional) { struct clk *clk = ERR_PTR(-ENOENT); @@ -65,18 +75,33 @@ static struct clk *__of_clk_get_by_name(struct device_node *np, /* * For named clocks, first look up the name in the * "clock-names" property. If it cannot be found, then - * index will be an error code, and of_clk_get() will fail. + * index will be an error code. */ if (name) index = of_property_match_string(np, "clock-names", name); - clk = __of_clk_get(np, index, dev_id, name); - if (!IS_ERR(clk)) { - break; - } else if (name && index >= 0) { - if (PTR_ERR(clk) != -EPROBE_DEFER) - pr_err("ERROR: could not get clock %pOF:%s(%i)\n", - np, name ? name : "", index); - return clk; + + /* + * If we are looking for an unnamed clock, or we have found the + * named clock in the node, try to get the clock provider. + */ + if (index >= 0) { + clk = __of_clk_get(np, index, dev_id, name); + if (!IS_ERR(clk)) + return clk; + + /* + * If the node specifies the clock name, do not walk up + * the tree looking in parent nodes. + */ + if (name) { + /* Optional clock that's not there? */ + if (optional && PTR_ERR(clk) == -ENOENT) + clk = NULL; + else if (PTR_ERR(clk) != -EPROBE_DEFER) + pr_err("ERROR: could not get clock %pOF:%s(%i)\n", + np, name, index); + return clk; + } } /* @@ -89,6 +114,9 @@ static struct clk *__of_clk_get_by_name(struct device_node *np, break; } + if (optional && PTR_ERR(clk) == -ENOENT) + clk = NULL; + return clk; } @@ -106,15 +134,37 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name) if (!np) return ERR_PTR(-ENOENT); - return __of_clk_get_by_name(np, np->full_name, name); + return __of_clk_get_by_name(np, np->full_name, name, false); } EXPORT_SYMBOL(of_clk_get_by_name); +/** + * of_clk_get_by_name_optional() - Parse and lookup an optional clock referenced + * by a device node + * @np: pointer to clock consumer node + * @name: name of consumer's clock input, or NULL for the first clock reference + * + * This function parses the clocks and clock-names properties, and uses them to + * look up the struct clk from the registered list of clock providers. + * It behaves the same as of_clk_get_by_name(), except when np is NULL or no + * clock provider is found, when it then returns NULL. + */ +struct clk *of_clk_get_by_name_optional(struct device_node *np, + const char *name) +{ + if (!np) + return NULL; + + return __of_clk_get_by_name(np, np->full_name, name, true); +} +EXPORT_SYMBOL(of_clk_get_by_name_optional); + #else /* defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) */ static struct clk *__of_clk_get_by_name(struct device_node *np, const char *dev_id, - const char *name) + const char *name, + bool optional) { return ERR_PTR(-ENOENT); } @@ -197,7 +247,7 @@ struct clk *clk_get(struct device *dev, const char *con_id) struct clk *clk; if (dev && dev->of_node) { - clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id); + clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id, false); if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER) return clk; } diff --git a/include/linux/clk.h b/include/linux/clk.h index a7773b5c0b9f..84512b3ecf5c 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -865,6 +865,7 @@ static inline void clk_bulk_disable_unprepare(int num_clks, #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) struct clk *of_clk_get(struct device_node *np, int index); struct clk *of_clk_get_by_name(struct device_node *np, const char *name); +struct clk *of_clk_get_by_name_optional(struct device_node *np, const char *name); struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); #else static inline struct clk *of_clk_get(struct device_node *np, int index) @@ -876,6 +877,11 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np, { return ERR_PTR(-ENOENT); } +static inline struct clk *of_clk_get_by_name_optional(struct device_node *np, + const char *name) +{ + return NULL; +} static inline struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) { return ERR_PTR(-ENOENT); From patchwork Fri Nov 16 14:59:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Edworthy X-Patchwork-Id: 10686425 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C11717DE for ; Fri, 16 Nov 2018 15:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B08D2BB97 for ; Fri, 16 Nov 2018 15:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F10D2C617; Fri, 16 Nov 2018 15:00:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5A7C2BB97 for ; Fri, 16 Nov 2018 15:00:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbeKQBNB (ORCPT ); Fri, 16 Nov 2018 20:13:01 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:24899 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728079AbeKQBNA (ORCPT ); Fri, 16 Nov 2018 20:13:00 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie5.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:15 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id CBFB3E3B06; Sat, 17 Nov 2018 00:00:15 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.56,240,1539615600"; d="scan'208";a="297674531" Received: from unknown (HELO vbox.ree.adwin.renesas.com) ([10.226.37.67]) by relmlii2.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:12 +0900 From: Phil Edworthy To: Stephen Boyd , Michael Turquette , Andy Shevchenko , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Phil Edworthy , Geert Uytterhoeven , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 2/6] clk: Add (devm_)clk_get_optional() functions Date: Fri, 16 Nov 2018 14:59:33 +0000 Message-Id: <20181116145937.27660-3-phil.edworthy@renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116145937.27660-1-phil.edworthy@renesas.com> References: <20181116145937.27660-1-phil.edworthy@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Phil Edworthy --- v6: - Add doxygen style comment for devm_clk_get_optional() args v5: - No changes. v4: - No changes. v3: - No changes. --- drivers/clk/clk-devres.c | 18 ++++++++++++++++-- drivers/clk/clkdev.c | 17 +++++++++++++++-- include/linux/clk.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 12c87457eca1..be07536725a2 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -14,7 +14,7 @@ static void devm_clk_release(struct device *dev, void *res) clk_put(*(struct clk **)res); } -struct clk *devm_clk_get(struct device *dev, const char *id) +static struct clk *__devm_clk_get(struct device *dev, const char *id, bool optional) { struct clk **ptr, *clk; @@ -22,7 +22,10 @@ struct clk *devm_clk_get(struct device *dev, const char *id) if (!ptr) return ERR_PTR(-ENOMEM); - clk = clk_get(dev, id); + if (!optional) + clk = clk_get(dev, id); + else + clk = clk_get_optional(dev, id); if (!IS_ERR(clk)) { *ptr = clk; devres_add(dev, ptr); @@ -32,8 +35,19 @@ struct clk *devm_clk_get(struct device *dev, const char *id) return clk; } + +struct clk *devm_clk_get(struct device *dev, const char *id) +{ + return __devm_clk_get(dev, id, false); +} EXPORT_SYMBOL(devm_clk_get); +struct clk *devm_clk_get_optional(struct device *dev, const char *id) +{ + return __devm_clk_get(dev, id, true); +} +EXPORT_SYMBOL(devm_clk_get_optional); + struct clk_bulk_devres { struct clk_bulk_data *clks; int num_clks; diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 0c655d1ba1d9..ebf3afef4371 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -241,21 +241,34 @@ struct clk *clk_get_sys(const char *dev_id, const char *con_id) } EXPORT_SYMBOL(clk_get_sys); -struct clk *clk_get(struct device *dev, const char *con_id) +static struct clk *internal_clk_get(struct device *dev, const char *con_id, + bool optional) { const char *dev_id = dev ? dev_name(dev) : NULL; struct clk *clk; if (dev && dev->of_node) { - clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id, false); + clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id, + optional); if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER) return clk; } return clk_get_sys(dev_id, con_id); } + +struct clk *clk_get(struct device *dev, const char *con_id) +{ + return internal_clk_get(dev, con_id, false); +} EXPORT_SYMBOL(clk_get); +struct clk *clk_get_optional(struct device *dev, const char *con_id) +{ + return internal_clk_get(dev, con_id, true); +} +EXPORT_SYMBOL(clk_get_optional); + void clk_put(struct clk *clk) { __clk_put(clk); diff --git a/include/linux/clk.h b/include/linux/clk.h index 84512b3ecf5c..58bebc32133e 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -290,6 +290,16 @@ static inline void clk_bulk_unprepare(int num_clks, struct clk_bulk_data *clks) */ struct clk *clk_get(struct device *dev, const char *id); +/** + * clk_get_optional - lookup and obtain a reference to optional clock producer. + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Behaves the same as clk_get except where there is no clock producer. In this + * case, instead of returning -ENOENT, the function returns NULL. + */ +struct clk *clk_get_optional(struct device *dev, const char *id); + /** * clk_bulk_get - lookup and obtain a number of references to clock producer. * @dev: device for clock "consumer" @@ -383,6 +393,17 @@ int __must_check devm_clk_bulk_get_all(struct device *dev, */ struct clk *devm_clk_get(struct device *dev, const char *id); +/** + * devm_clk_get_optional - lookup and obtain a managed reference to an optional + * clock producer. + * @dev: device for clock "consumer" + * @id: clock consumer ID + * + * Behaves the same as devm_clk_get except where there is no clock producer. In + * this case, instead of returning -ENOENT, the function returns NULL. + */ +struct clk *devm_clk_get_optional(struct device *dev, const char *id); + /** * devm_get_clk_from_child - lookup and obtain a managed reference to a * clock producer from child node. @@ -701,6 +722,11 @@ static inline struct clk *clk_get(struct device *dev, const char *id) return NULL; } +static inline struct clk *clk_get_optional(struct device *dev, const char *id) +{ + return NULL; +} + static inline int __must_check clk_bulk_get(struct device *dev, int num_clks, struct clk_bulk_data *clks) { @@ -718,6 +744,12 @@ static inline struct clk *devm_clk_get(struct device *dev, const char *id) return NULL; } +static inline struct clk *devm_clk_get_optional(struct device *dev, + const char *id) +{ + return NULL; +} + static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clks, struct clk_bulk_data *clks) { From patchwork Fri Nov 16 14:59:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Edworthy X-Patchwork-Id: 10686429 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EE9417DE for ; Fri, 16 Nov 2018 15:00:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EABB2BB97 for ; Fri, 16 Nov 2018 15:00:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42BF32C617; Fri, 16 Nov 2018 15:00:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F20532BB97 for ; Fri, 16 Nov 2018 15:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728079AbeKQBNM (ORCPT ); Fri, 16 Nov 2018 20:13:12 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:41782 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389987AbeKQBNM (ORCPT ); Fri, 16 Nov 2018 20:13:12 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie5.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:27 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id A37C8E3B33; Sat, 17 Nov 2018 00:00:27 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.56,240,1539615600"; d="scan'208";a="297674557" Received: from unknown (HELO vbox.ree.adwin.renesas.com) ([10.226.37.67]) by relmlii2.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:25 +0900 From: Phil Edworthy To: Greg Ungerer , Geert Uytterhoeven Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Phil Edworthy , linux-m68k@lists.linux-m68k.org Subject: [PATCH v6 3/6] m68k: coldfire: Add clk_get_optional() function Date: Fri, 16 Nov 2018 14:59:34 +0000 Message-Id: <20181116145937.27660-4-phil.edworthy@renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116145937.27660-1-phil.edworthy@renesas.com> References: <20181116145937.27660-1-phil.edworthy@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clk_get_optional() returns NULL if not found instead of -ENOENT, otherwise the behaviour is the same as clk_get(). Signed-off-by: Phil Edworthy Acked-by: Greg Ungerer --- arch/m68k/coldfire/clk.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c index 7bc666e482eb..b221cabc7f54 100644 --- a/arch/m68k/coldfire/clk.c +++ b/arch/m68k/coldfire/clk.c @@ -87,6 +87,17 @@ struct clk *clk_get(struct device *dev, const char *id) } EXPORT_SYMBOL(clk_get); +struct clk *clk_get_optional(struct device *dev, const char *id) +{ + struct clk *clk = clk_get(dev, id); + + if (clk == ERR_PTR(-ENOENT)) + clk = NULL; + + return clk; +} +EXPORT_SYMBOL(clk_get_optional); + int clk_enable(struct clk *clk) { unsigned long flags; From patchwork Fri Nov 16 14:59:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Edworthy X-Patchwork-Id: 10686431 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FF8514BD for ; Fri, 16 Nov 2018 15:00:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FAD22C3B9 for ; Fri, 16 Nov 2018 15:00:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6282C2C623; Fri, 16 Nov 2018 15:00:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D6DA2C3B9 for ; Fri, 16 Nov 2018 15:00:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389942AbeKQBNX (ORCPT ); Fri, 16 Nov 2018 20:13:23 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:60899 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389903AbeKQBNX (ORCPT ); Fri, 16 Nov 2018 20:13:23 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie6.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:38 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id C70ECE3B5E; Sat, 17 Nov 2018 00:00:38 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.56,240,1539615600"; d="scan'208";a="297674585" Received: from unknown (HELO vbox.ree.adwin.renesas.com) ([10.226.37.67]) by relmlii2.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:36 +0900 From: Phil Edworthy To: Ralf Baechle Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Phil Edworthy , Paul Burton , James Hogan , Geert Uytterhoeven , linux-mips@linux-mips.org Subject: [PATCH v6 4/6] MIPS: AR7: Add clk_get_optional() function Date: Fri, 16 Nov 2018 14:59:35 +0000 Message-Id: <20181116145937.27660-5-phil.edworthy@renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116145937.27660-1-phil.edworthy@renesas.com> References: <20181116145937.27660-1-phil.edworthy@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clk_get_optional() returns NULL if not found instead of -ENOENT, otherwise the behaviour is the same as clk_get(). Signed-off-by: Phil Edworthy --- arch/mips/ar7/clock.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/mips/ar7/clock.c b/arch/mips/ar7/clock.c index 6b64fd96dba8..b13f763948b1 100644 --- a/arch/mips/ar7/clock.c +++ b/arch/mips/ar7/clock.c @@ -454,6 +454,17 @@ struct clk *clk_get(struct device *dev, const char *id) } EXPORT_SYMBOL(clk_get); +struct clk *clk_get_optional(struct device *dev, const char *id) +{ + struct clk *clk = clk_get(dev, id); + + if (clk == ERR_PTR(-ENOENT)) + clk = NULL; + + return clk; +} +EXPORT_SYMBOL(clk_get_optional); + void clk_put(struct clk *clk) { } From patchwork Fri Nov 16 14:59:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Edworthy X-Patchwork-Id: 10686435 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43C9917DE for ; Fri, 16 Nov 2018 15:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 325A62BB97 for ; Fri, 16 Nov 2018 15:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2666A2C617; Fri, 16 Nov 2018 15:00:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 181AE2BB97 for ; Fri, 16 Nov 2018 15:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390035AbeKQBNe (ORCPT ); Fri, 16 Nov 2018 20:13:34 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:23377 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728425AbeKQBNe (ORCPT ); Fri, 16 Nov 2018 20:13:34 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie6.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:50 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 11E52E3B81; Sat, 17 Nov 2018 00:00:50 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.56,240,1539615600"; d="scan'208";a="297674602" Received: from unknown (HELO vbox.ree.adwin.renesas.com) ([10.226.37.67]) by relmlii2.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:47 +0900 From: Phil Edworthy To: Jiaxun Yang , Huacai Chen Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Phil Edworthy , Ralf Baechle , Paul Burton , James Hogan , linux-mips@linux-mips.org Subject: [PATCH v6 5/6] MIPS: Loongson 2F: Add clk_get_optional() function Date: Fri, 16 Nov 2018 14:59:36 +0000 Message-Id: <20181116145937.27660-6-phil.edworthy@renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116145937.27660-1-phil.edworthy@renesas.com> References: <20181116145937.27660-1-phil.edworthy@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clk_get_optional() returns NULL if not found instead of -ENOENT, otherwise the behaviour is the same as clk_get(). Signed-off-by: Phil Edworthy --- arch/mips/loongson64/lemote-2f/clock.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/mips/loongson64/lemote-2f/clock.c b/arch/mips/loongson64/lemote-2f/clock.c index 8281334df9c8..abbade58b635 100644 --- a/arch/mips/loongson64/lemote-2f/clock.c +++ b/arch/mips/loongson64/lemote-2f/clock.c @@ -53,6 +53,17 @@ struct clk *clk_get(struct device *dev, const char *id) } EXPORT_SYMBOL(clk_get); +struct clk *clk_get_optional(struct device *dev, const char *id) +{ + struct clk *clk = clk_get(dev, id); + + if (clk == ERR_PTR(-ENOENT)) + clk = NULL; + + return clk; +} +EXPORT_SYMBOL(clk_get_optional); + static void propagate_rate(struct clk *clk) { struct clk *clkp; From patchwork Fri Nov 16 14:59:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Edworthy X-Patchwork-Id: 10686437 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA8B717DE for ; Fri, 16 Nov 2018 15:01:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9FA32C3B9 for ; Fri, 16 Nov 2018 15:01:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB9512BB97; Fri, 16 Nov 2018 15:01:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 840812BB97 for ; Fri, 16 Nov 2018 15:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390034AbeKQBNq (ORCPT ); Fri, 16 Nov 2018 20:13:46 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:40271 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728425AbeKQBNp (ORCPT ); Fri, 16 Nov 2018 20:13:45 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie6.idc.renesas.com with ESMTP; 17 Nov 2018 00:01:01 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 3C3DF100374; Sat, 17 Nov 2018 00:01:01 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.56,240,1539615600"; d="scan'208";a="297674605" Received: from unknown (HELO vbox.ree.adwin.renesas.com) ([10.226.37.67]) by relmlii2.idc.renesas.com with ESMTP; 17 Nov 2018 00:00:59 +0900 From: Phil Edworthy Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Phil Edworthy , Guan Xuetao Subject: [PATCH v6 6/6] arch/unicore32/kernel/clock.c: Add clk_get_optional() function Date: Fri, 16 Nov 2018 14:59:37 +0000 Message-Id: <20181116145937.27660-7-phil.edworthy@renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181116145937.27660-1-phil.edworthy@renesas.com> References: <20181116145937.27660-1-phil.edworthy@renesas.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clk_get_optional() returns NULL if not found instead of -ENOENT, otherwise the behaviour is the same as clk_get(). Signed-off-by: Phil Edworthy --- arch/unicore32/kernel/clock.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/unicore32/kernel/clock.c b/arch/unicore32/kernel/clock.c index b1ca775f6f6e..03def0b43192 100644 --- a/arch/unicore32/kernel/clock.c +++ b/arch/unicore32/kernel/clock.c @@ -74,6 +74,17 @@ struct clk *clk_get(struct device *dev, const char *id) } EXPORT_SYMBOL(clk_get); +struct clk *clk_get_optional(struct device *dev, const char *id) +{ + struct clk *clk = clk_get(dev, id); + + if (clk == ERR_PTR(-ENOENT)) + clk = NULL; + + return clk; +} +EXPORT_SYMBOL(clk_get_optional); + void clk_put(struct clk *clk) { }