clk: let of_clk_get_parent_name() fail for invalid clock-indices
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 3 Dec 2015 02:20:35 +0000 (11:20 +0900)
committerStephen Boyd <sboyd@codeaurora.org>
Thu, 3 Dec 2015 06:34:43 +0000 (22:34 -0800)
commit8da411cc1964c5d6a0a0f94c7bbf8693c9673a87
tree1f4540d075f7d2ea2e07ddec09e43e6c78204399
parent0b9ddcc84eba3309a42fd73d293cc5df79e911b4
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>
drivers/clk/clk.c