From: Stephen Boyd Date: Fri, 8 Mar 2019 18:35:01 +0000 (-0800) Subject: Merge branch 'clk-parent-rewrite' (early part) into clk-next X-Git-Tag: v5.15~6774^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5dc7e84268f53f08251abe1d388a019f55ddb077;p=platform%2Fkernel%2Flinux-starfive.git Merge branch 'clk-parent-rewrite' (early part) into clk-next * '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() --- 5dc7e84268f53f08251abe1d388a019f55ddb077 diff --cc drivers/clk/clk.c index af3882f04080,937b8d092d17..14cbf239d9b2 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.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)