• Masahiro Yamada's avatar
    clk: move core->parents allocation to clk_register() · 176d1169
    Masahiro Yamada authored
    Currently, __clk_core_init() allows failure of the kcalloc() for the
    core->parents.  So, clk_fetch_parent_index() and __clk_init_parent()
    also try to allocate core->parents in case it has not been allocated
    yet.  Scattering memory allocation here and there makes things
    complicated.
    
    Like other clk_core members, allocate core->parents in clk_register()
    and let it fail in case of memory shortage.  If we cannot allocate
    such a small piece of memory, the system is already insane.  There is
    no point to postpone the memory allocation.
    
    Also, allocate core->parents regardless of core->num_parents.  We want
    it even if core->num_parents == 1 because clk_fetch_parent_index()
    might be called against the clk_core with a single parent.
    
    If core->num_parents == 0, core->parents is set to ZERO_SIZE_PTR. It
    is harmless because no access happens to core->parents in such a case.
    Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    Reviewed-by: default avatarVladimir Zapolskiy <vz@mleia.com>
    Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
    176d1169
clk.c 77.9 KB