Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp287309ybi; Fri, 7 Jun 2019 08:04:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYGdjkVpUoRIT8wOOmG46YrvU3DCwlPW1a6YMCj4ynd5YUX2Si3scym034dzoUjvSQ3Koj X-Received: by 2002:a17:902:760a:: with SMTP id k10mr35668765pll.83.1559919897244; Fri, 07 Jun 2019 08:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559919897; cv=none; d=google.com; s=arc-20160816; b=XsrhZ9lTU/ghH/SWjgr1IxEL+4fkwFl5YfQYlcwPNFQRP2sf8TfGtGjBQWcRhyCfzm oralXzM6PsnRjXkq8fZXEe8bYHc0miantlSNH4sEwnNNcKVzhU57M0j54iI6l2WOGgWN BsQgGJzDSYCiijg+TWnr4keif66uJUOy0XngpgAq/r/1d0g0AUUP9Y2tYPvJZo5NhpzK j2vvbm4YrUvADtHifTdcOScdTXbjd2Xp2Qe7EK+m1ODrR7uGx564TZRQbTpT99opv5M1 pkQ+MgSJrpnw1XAq1d0oNRb1VJsZL47nQs8FxBIWQhOrJ+ZcGArX6Pah0u4ZbLTvptw+ lpwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Da8/bpzcffA7IaUWf6tIk64JAUiyX2Mj+OXwyqy6dls=; b=Vxs2rgB5dzJsmsxEXLtf2dgRePvYThCz5pk0oJ0h8/0cKC5/mltC2ogqCvQhAti6QQ SK/cg2xl9X4PDS4cVGQZMoLwVM1dksEgJ5FdbTL3sFDNXhvcRwOdnvuSQvhKSeryA8ep /Yw6p/wfhGXXHkVx9Di9FxOblMWDq48pxNb2I8E2CHf0/JcZUrEenJMfRAWVLh2/4muu kqG1fPoFOHx7JP+JEBAbpbyPl43enTe4aJ6YSod02obv1nRdcn2IbHj1FjxrjemMwLN5 rO4ycce/LvLy6WFHRNNiBpWEVjV585f7q3E8u5ODfY/MdUUVDTl0USy0vxJuN0nR3A/K Dc5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si1945528pgk.417.2019.06.07.08.04.37; Fri, 07 Jun 2019 08:04:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729813AbfFGPBu (ORCPT + 99 others); Fri, 7 Jun 2019 11:01:50 -0400 Received: from foss.arm.com ([217.140.110.172]:42000 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729262AbfFGPBt (ORCPT ); Fri, 7 Jun 2019 11:01:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D5FFD346; Fri, 7 Jun 2019 08:01:48 -0700 (PDT) Received: from e107155-lin (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 316D33F71A; Fri, 7 Jun 2019 08:01:46 -0700 (PDT) Date: Fri, 7 Jun 2019 16:01:44 +0100 From: Sudeep Holla To: Ulf Hansson Cc: Lorenzo Pieralisi , Mark Rutland , linux-arm-kernel@lists.infradead.org, "Rafael J . Wysocki" , Daniel Lezcano , "Raju P . L . S . S . S . N" , Amit Kucheria , Bjorn Andersson , Stephen Boyd , Niklas Cassel , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Souvik Chakravarty , Sudeep Holla , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/18] drivers: firmware: psci: Simplify state node parsing Message-ID: <20190607150144.GD15577@e107155-lin> References: <20190513192300.653-1-ulf.hansson@linaro.org> <20190513192300.653-6-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190513192300.653-6-ulf.hansson@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Acked-by: Daniel Lezcano > --- > > 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