Merge branch 'clk-parent-rewrite' (early part) into clk-next
authorStephen Boyd <sboyd@kernel.org>
Fri, 8 Mar 2019 18:35:01 +0000 (10:35 -0800)
committerStephen Boyd <sboyd@kernel.org>
Fri, 8 Mar 2019 18:35:01 +0000 (10:35 -0800)
* 'clk-parent-rewrite' (early part):
  clk: Move of_clk_*() APIs into clk.c from clkdev.c
  clk: Inform the core about consumer devices
  clk: Introduce of_clk_get_hw_from_clkspec()
  clk: core: clarify the check for runtime PM
  clk: Combine __clk_get() and __clk_create_clk()

1  2 
drivers/clk/clk.c
drivers/clk/clkdev.c

@@@ -4009,6 -4068,42 +4071,49 @@@ void devm_of_clk_del_provider(struct de
  }
  EXPORT_SYMBOL(devm_of_clk_del_provider);
  
++/*
++ * Beware the return values when np is valid, but no clock provider is found.
++ * If name == NULL, the function returns -ENOENT.
++ * If name != NULL, the function returns -EINVAL. This is because
++ * of_parse_phandle_with_args() is called even if of_property_match_string()
++ * returns an error.
++ */
+ static int of_parse_clkspec(const struct device_node *np, int index,
+                           const char *name, struct of_phandle_args *out_args)
+ {
+       int ret = -ENOENT;
+       /* Walk up the tree of devices looking for a clock property that matches */
+       while (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_parse_phandle_with_args() will
+                * return -EINVAL.
+                */
+               if (name)
+                       index = of_property_match_string(np, "clock-names", name);
+               ret = of_parse_phandle_with_args(np, "clocks", "#clock-cells",
+                                                index, out_args);
+               if (!ret)
+                       break;
+               if (name && index >= 0)
+                       break;
+               /*
+                * No matching clock found on this node.  If the parent node
+                * has a "clock-ranges" property, then we can try one of its
+                * clocks.
+                */
+               np = np->parent;
+               if (np && !of_get_property(np, "clock-ranges", NULL))
+                       break;
+               index = 0;
+       }
+       return ret;
+ }
  static struct clk_hw *
  __of_clk_get_hw_from_provider(struct of_clk_provider *provider,
                              struct of_phandle_args *clkspec)
Simple merge