#include <linux/clk-provider.h>
#include <linux/clk/clk-conf.h>
#include <linux/device.h>
#include <linux/printk.h>
static int __set_clk_parents(struct device_node *node, bool clk_supplier)
struct of_phandle_args clkspec;
int index, rc, num_parents;
num_parents = of_count_phandle_with_args(node, "assigned-clock-parents",
if (num_parents == -EINVAL)
pr_err("clk: invalid value of clock-parents property at %pOF\n",
for (index = 0; index < num_parents; index++) {
rc = of_parse_phandle_with_args(node, "assigned-clock-parents",
"#clock-cells", index, &clkspec);
if (clkspec.np == node && !clk_supplier)
pclk = of_clk_get_from_provider(&clkspec);
if (PTR_ERR(pclk) != -EPROBE_DEFER)
pr_warn("clk: couldn't get parent clock %d for %pOF\n",
rc = of_parse_phandle_with_args(node, "assigned-clocks",
"#clock-cells", index, &clkspec);
if (clkspec.np == node && !clk_supplier) {
clk = of_clk_get_from_provider(&clkspec);
if (PTR_ERR(clk) != -EPROBE_DEFER)
pr_warn("clk: couldn't get assigned clock %d for %pOF\n",
rc = clk_set_parent(clk, pclk);