diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b775c88ac36d..fb74dc1f7520 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2986,9 +2986,21 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) } EXPORT_SYMBOL_GPL(of_clk_get_from_provider); -int of_clk_get_parent_count(struct device_node *np) +/** + * of_clk_get_parent_count() - Count the number of clocks a device node has + * @np: device node to count + * + * Returns: The number of clocks that are possible parents of this node + */ +unsigned int of_clk_get_parent_count(struct device_node *np) { - return of_count_phandle_with_args(np, "clocks", "#clock-cells"); + int count; + + count = of_count_phandle_with_args(np, "clocks", "#clock-cells"); + if (count < 0) + return 0; + + return count; } EXPORT_SYMBOL_GPL(of_clk_get_parent_count); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index fce7f027f8a7..da95258127aa 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -716,7 +716,7 @@ void of_clk_del_provider(struct device_node *np); struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data); struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); -int of_clk_get_parent_count(struct device_node *np); +unsigned int of_clk_get_parent_count(struct device_node *np); int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned int size); const char *of_clk_get_parent_name(struct device_node *np, int index);