Clocks obtained through of_clk_get_from_provider() show up as
"deviceless" in the consumer column of the clk_summary file in debugfs.
Add a new variant dev_clk_get_from_provider() that also takes a consumer
device, so callers can provide it, and consumer's name will be shown in
the clk_summary output.

Reimplement of_clk_get_from_provider() on top of
dev_clk_get_from_provider().

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
 drivers/clk/clk.c   | 11 +++++++----
 include/linux/clk.h | 10 ++++++++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 858f4d60ed2d97c4..195c7d80e4f2b579 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -5377,20 +5377,23 @@ of_clk_get_hw_from_clkspec(struct of_phandle_args 
*clkspec)
 }
 
 /**
- * of_clk_get_from_provider() - Lookup a clock from a clock provider
+ * dev_clk_get_from_provider() - Lookup a clock from a clock provider
+ * @dev: clk consumer device
  * @clkspec: pointer to a clock specifier data structure
  *
  * This function looks up a struct clk from the registered list of clock
  * providers, an input is a clock specifier data structure as returned
  * from the OF phandle parser.
  */
-struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec)
+struct clk *dev_clk_get_from_provider(struct device *dev,
+                                     struct of_phandle_args *clkspec)
 {
        struct clk_hw *hw = of_clk_get_hw_from_clkspec(clkspec);
+       const char *name = dev ? dev_name(dev) : NULL;
 
-       return clk_hw_create_clk(hw, NULL, __func__, NULL);
+       return clk_hw_create_clk(hw, name, __func__, NULL);
 }
-EXPORT_SYMBOL_GPL(of_clk_get_from_provider);
+EXPORT_SYMBOL_GPL(dev_clk_get_from_provider);
 
 struct clk_hw *of_clk_get_hw(struct device_node *np, int index,
                             const char *con_id)
diff --git a/include/linux/clk.h b/include/linux/clk.h
index db9cf184fd999b85..45c6eb09436036bb 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -1261,7 +1261,8 @@ static inline struct clk *clk_get_optional(struct device 
*dev, const char *id)
 #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_from_provider(struct of_phandle_args *clkspec);
+struct clk *dev_clk_get_from_provider(struct device *dev,
+                                     struct of_phandle_args *clkspec);
 #else
 static inline struct clk *of_clk_get(struct device_node *np, int index)
 {
@@ -1272,10 +1273,15 @@ static inline struct clk *of_clk_get_by_name(struct 
device_node *np,
 {
        return ERR_PTR(-ENOENT);
 }
-static inline struct clk *of_clk_get_from_provider(struct of_phandle_args 
*clkspec)
+static inline struct clk *dev_clk_get_from_provider(struct device *dev,
+                                                   struct of_phandle_args 
*clkspec)
 {
        return ERR_PTR(-ENOENT);
 }
 #endif
+static inline struct clk *of_clk_get_from_provider(struct of_phandle_args 
*clkspec)
+{
+       return dev_clk_get_from_provider(NULL, clkspec);
+}
 
 #endif
-- 
2.43.0

Reply via email to