]> git.baikalelectronics.ru Git - kernel.git/commit
PM / domains: Fix up domain-idle-states OF parsing
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 23 Jan 2018 20:43:08 +0000 (21:43 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 7 Feb 2018 11:02:01 +0000 (12:02 +0100)
commit87192a0481dd4bbfd2eea3dabd43baa2e4c9d7d0
tree2fb763468bf084673a35b23fc00dc5e0d9f1b206
parent73415bb256f934e32fc36b7dbbc15a08f681dc92
PM / domains: Fix up domain-idle-states OF parsing

Commit 8faab72421d2 (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: 8faab72421d2 (PM / Domains: Ignore domain-idle-states that are not compatible)
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Lina Iyer <ilina@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c