linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/6] clk: Add functions to get optional clocks
@ 2018-11-16 14:59 Phil Edworthy
  2018-11-16 14:59 ` [PATCH v6 4/6] MIPS: AR7: Add clk_get_optional() function Phil Edworthy
  2018-11-16 14:59 ` [PATCH v6 5/6] MIPS: Loongson 2F: " Phil Edworthy
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Edworthy @ 2018-11-16 14:59 UTC (permalink / raw)
  To: Stephen Boyd, Michael Turquette, Andy Shevchenko, Russell King,
	Greg Ungerer, Geert Uytterhoeven, Ralf Baechle, Paul Burton,
	James Hogan, Jiaxun Yang, Huacai Chen, Guan Xuetao
  Cc: linux-clk, linux-kernel, linux-renesas-soc, Phil Edworthy,
	Uwe Kleine-König, linux-m68k, linux-mips, linux-arm-kernel

Quite a few drivers get an optional clock, e.g. a bus clock required to 
access peripheral's registers that is always enabled on some devices. This
series adds of_clk_get_by_name_optional(), clk_get_optional() and
devm_clk_get_optional() functions for this purpose.

The functions behave the same as of_clk_get_by_name(), clk_get() and
devm_clk_get() except that they will return NULL instead of -ENOENT. This
allows for simpler error handling in the callers.

*Note*
This changes the return values for of_clk_get_by_name() in some cases, see
[PATCH 1/6] clk: Add of_clk_get_by_name_optional() function.

v6:
 - Rework the __of_clk_get_by_name() logic so as to avoid duplicate tests.
 - Add doxygen style comment for devm_clk_get_optional() args
 - Add clk_get_optional() to archs that don't use the commom clk framework.

Phil Edworthy (6):
  clk: Add of_clk_get_by_name_optional() function
  clk: Add functions to get optional clocks
  m68k: coldfire: Add clk_get_optional() function
  MIPS: AR7: Add clk_get_optional() function
  MIPS: Loongson 2F: Add clk_get_optional() function
  arch/unicore32/kernel/clock.c: Add clk_get_optional() function

 arch/m68k/coldfire/clk.c               | 11 ++++
 arch/mips/ar7/clock.c                  | 11 ++++
 arch/mips/loongson64/lemote-2f/clock.c | 11 ++++
 arch/unicore32/kernel/clock.c          | 11 ++++
 drivers/clk/clk-devres.c               | 18 ++++-
 drivers/clk/clkdev.c                   | 91 ++++++++++++++++++++++----
 include/linux/clk.h                    | 38 +++++++++++
 7 files changed, 175 insertions(+), 16 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v6 4/6] MIPS: AR7: Add clk_get_optional() function
  2018-11-16 14:59 [PATCH v6 0/6] clk: Add functions to get optional clocks Phil Edworthy
@ 2018-11-16 14:59 ` Phil Edworthy
  2018-11-16 14:59 ` [PATCH v6 5/6] MIPS: Loongson 2F: " Phil Edworthy
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Edworthy @ 2018-11-16 14:59 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: linux-clk, linux-kernel, linux-renesas-soc, Phil Edworthy,
	Paul Burton, James Hogan, Geert Uytterhoeven, linux-mips

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 <phil.edworthy@renesas.com>
---
 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)
 {
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v6 5/6] MIPS: Loongson 2F: Add clk_get_optional() function
  2018-11-16 14:59 [PATCH v6 0/6] clk: Add functions to get optional clocks Phil Edworthy
  2018-11-16 14:59 ` [PATCH v6 4/6] MIPS: AR7: Add clk_get_optional() function Phil Edworthy
@ 2018-11-16 14:59 ` Phil Edworthy
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Edworthy @ 2018-11-16 14:59 UTC (permalink / raw)
  To: Jiaxun Yang, Huacai Chen
  Cc: linux-clk, linux-kernel, linux-renesas-soc, Phil Edworthy,
	Ralf Baechle, Paul Burton, James Hogan, linux-mips

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 <phil.edworthy@renesas.com>
---
 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;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-16 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 14:59 [PATCH v6 0/6] clk: Add functions to get optional clocks Phil Edworthy
2018-11-16 14:59 ` [PATCH v6 4/6] MIPS: AR7: Add clk_get_optional() function Phil Edworthy
2018-11-16 14:59 ` [PATCH v6 5/6] MIPS: Loongson 2F: " Phil Edworthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).