pd->num_clks = of_count_phandle_with_args(node, "clocks",
"#clock-cells");
-
- pd->clks = devm_kcalloc(pmu->dev, pd->num_clks, sizeof(*pd->clks),
- GFP_KERNEL);
- if (!pd->clks)
- return -ENOMEM;
+ if (pd->num_clks > 0) {
+ pd->clks = devm_kcalloc(pmu->dev, pd->num_clks,
+ sizeof(*pd->clks), GFP_KERNEL);
+ if (!pd->clks)
+ return -ENOMEM;
+ } else {
+ dev_dbg(pmu->dev, "%s: doesn't have clocks: %d\n",
+ node->name, pd->num_clks);
+ pd->num_clks = 0;
+ }
for (i = 0; i < pd->num_clks; i++) {
pd->clks[i].clk = of_clk_get(node, i);