clk: simplify clk_core_get_parent_by_index()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 28 Dec 2015 10:23:01 +0000 (19:23 +0900)
committerStephen Boyd <sboyd@codeaurora.org>
Tue, 2 Feb 2016 01:01:50 +0000 (17:01 -0800)
Drop the "if (!core->parents)" case and refactor the function a bit
because core->parents is always allocated.  (Strictly speaking, it is
ZERO_SIZE_PTR if core->num_parents == 0, but such a case is omitted
by the if-conditional above.)

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/clk.c

index a92feedda592bff71240780ec43d7cb2c9382b50..c2e993db0cfde208ba0cc84eac3498ca065e0828 100644 (file)
@@ -350,13 +350,12 @@ static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core,
 {
        if (!core || index >= core->num_parents)
                return NULL;
-       else if (!core->parents)
-               return clk_core_lookup(core->parent_names[index]);
-       else if (!core->parents[index])
-               return core->parents[index] =
-                       clk_core_lookup(core->parent_names[index]);
-       else
-               return core->parents[index];
+
+       if (!core->parents[index])
+               core->parents[index] =
+                               clk_core_lookup(core->parent_names[index]);
+
+       return core->parents[index];
 }
 
 struct clk_hw *