lkml.org 
[lkml]   [2019]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 05/18] drivers: firmware: psci: Simplify state node parsing
    On Mon, May 13, 2019 at 09:22:47PM +0200, Ulf Hansson wrote:
    > Instead of iterating through all the state nodes in DT, to find out how
    > many states that needs to be allocated, let's use the number already known
    > by the cpuidle driver. In this way we can drop the iteration altogether.
    >
    > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    > Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    > ---
    >
    > Changes:
    > - None.
    >
    > ---
    > drivers/firmware/psci/psci.c | 25 ++++++++++++-------------
    > 1 file changed, 12 insertions(+), 13 deletions(-)
    >
    > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
    > index 88e90e0f06b9..9c2180bcee4c 100644
    > --- a/drivers/firmware/psci/psci.c
    > +++ b/drivers/firmware/psci/psci.c
    > @@ -306,26 +306,20 @@ static int psci_dt_parse_state_node(struct device_node *np, u32 *state)
    > static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv,
    > struct device_node *cpu_node, int cpu)
    > {
    > - int i, ret = 0, count = 0;
    > + int i, ret = 0, num_state_nodes = drv->state_count - 1;
    > u32 *psci_states;
    > struct device_node *state_node;
    >
    > - /* Count idle states */
    > - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states",
    > - count))) {
    > - count++;
    > - of_node_put(state_node);
    > - }
    > -
    > - if (!count)
    > - return -ENODEV;
    > -
    > - psci_states = kcalloc(count, sizeof(*psci_states), GFP_KERNEL);
    > + psci_states = kcalloc(num_state_nodes, sizeof(*psci_states),
    > + GFP_KERNEL);
    > if (!psci_states)
    > return -ENOMEM;
    >
    > - for (i = 0; i < count; i++) {
    > + for (i = 0; i < num_state_nodes; i++) {
    > state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i);

    Why not start using of_get_cpu_state_node here which was introduced in
    earlier patch as part of this simplification ?

    --
    Regards,
    Sudeep

    \
     
     \ /
      Last update: 2019-06-07 17:02    [W:4.346 / U:0.904 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site