summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorMasahiro Yamada2015-12-03 03:20:35 +0100
committerStephen Boyd2015-12-03 07:34:43 +0100
commit8da411cc1964c5d6a0a0f94c7bbf8693c9673a87 (patch)
tree1f4540d075f7d2ea2e07ddec09e43e6c78204399 /drivers/clk/clk.c
parentMerge branch 'clk-msm8996' into clk-next (diff)
downloadkernel-qcow2-linux-8da411cc1964c5d6a0a0f94c7bbf8693c9673a87.tar.gz
kernel-qcow2-linux-8da411cc1964c5d6a0a0f94c7bbf8693c9673a87.tar.xz
kernel-qcow2-linux-8da411cc1964c5d6a0a0f94c7bbf8693c9673a87.zip
clk: let of_clk_get_parent_name() fail for invalid clock-indices
Currently, of_clk_get_parent_name() returns a wrong parent clock name when "clock-indices" property exists and the target index is not found in the property. In this case, NULL should be returned. For example, oscillator { compatible = "myclocktype"; #clock-cells = <1>; clock-indices = <1>, <3>; clock-output-names = "clka", "clkb"; }; consumer { compatible = "myclockconsumer"; clocks = <&oscillator 0>, <&oscillator 1>; }; Currently, of_clk_get_parent_name(consumer_np, 0) returns "clka" (and of_clk_get_parent_name(consumer_np, 1) also returns "clka", this is correct). Because the "clock-indices" in the clock parent does not contain <0>, of_clk_get_parent_name(consumer_np, 0) should return NULL. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index a66efc9d8bfc..9352a13395c8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3079,6 +3079,9 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
}
count++;
}
+ /* We went off the end of 'clock-indices' without finding it */
+ if (prop && !vp)
+ return NULL;
if (of_property_read_string_index(clkspec.np, "clock-output-names",
index,