• Ulf Hansson's avatar
    PM / domains: Fix up domain-idle-states OF parsing · a3381e3a
    Ulf Hansson authored
    Commit b539cc82 (PM / Domains: Ignore domain-idle-states that are
    not compatible), made it possible to ignore non-compatible
    domain-idle-states OF nodes. However, in case that happens while doing
    the OF parsing, the number of elements in the allocated array would
    exceed the numbers actually needed, thus wasting memory.
    
    Fix this by pre-iterating the genpd OF node and counting the number of
    compatible domain-idle-states nodes, before doing the allocation. While
    doing this, it makes sense to rework the code a bit to avoid open coding,
    of parts responsible for the OF node iteration.
    
    Let's also take the opportunity to clarify the function header for
    of_genpd_parse_idle_states(), about what is being returned in case of
    errors.
    
    Fixes: b539cc82 (PM / Domains: Ignore domain-idle-states that are not compatible)
    Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
    Reviewed-by: default avatarLina Iyer <ilina@codeaurora.org>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    a3381e3a
domain.c 66.9 KB