Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1034985imm; Wed, 20 Jun 2018 10:27:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKwmoeExKt+be0uopFGDbFZMPs+sz+9gHHvQMLZlxl8J54Kwoe635JpxZRgCgrZZ0JZd20Y X-Received: by 2002:a65:49cb:: with SMTP id t11-v6mr19413060pgs.218.1529515659128; Wed, 20 Jun 2018 10:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515659; cv=none; d=google.com; s=arc-20160816; b=b57wLMcoWH8+lLp12S4fywVUcJ1mRXSOkS+EQZ5gY58JNFY10OgxYtH/fwqBn/9NB0 KEVAbPT6xoKRg841moMmQI7/18HX9NCx6S34vHALOtJrnGRAtwzKerMJeDuu/RTy8kZM kQ1MkWuwXDeknaNpsejfXTuIQ0nGDPXRr5DA3kSrVv9nnYX4DKuOzvYlNxs2wcPqUtkh J+p59jHfRot3/RULffhjcVh9nyGxxOu72Fx/mjx2XF4TD7MQDtvE4t/cL2Yv6wVxb/mc EYo2RdkJJL5Kt/6n5zd9hHsuvFLIR9ZsR8kZZWwG4oklPhb+AazW8fbhvpaegXFCiExf 4yrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=cAi6Z/HBIB3i0ZZ3G0IFFn47/sKLp6vcEyYdh31VyA84p2Nam/w8swD1UzXVK6egx0 +l+4j4vs54MXVIff3BpUA3njaSImWzwiJt2KosJ1JvrMub2ZCsLlQ/WXjh1Qv7FnxTaD hS03M7JwxrItEB9TcAs4AQW5qO0ro07ytjbXRLHDVD6PGmqpHDXSGNwETC3y/JKqiyBQ bQ/25SdoVh2abDarqivij8e/0Wo/EEHRnxWPXUOWPZIcTYC//aaIgHoHWuwMdHNUNWXa kU+w0LxcHqg0TkXf18J+PUjL92WtKU154MAFmWy4PSyMMmUY5dEEmu4rzcaFt+ZbB0o4 NA1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtRIJm7X; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q86-v6si2812744pfg.298.2018.06.20.10.27.25; Wed, 20 Jun 2018 10:27:39 -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; dkim=pass header.i=@linaro.org header.s=google header.b=dtRIJm7X; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932963AbeFTR0F (ORCPT + 99 others); Wed, 20 Jun 2018 13:26:05 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44035 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932241AbeFTRXE (ORCPT ); Wed, 20 Jun 2018 13:23:04 -0400 Received: by mail-lf0-f67.google.com with SMTP id p23-v6so445615lfh.11 for ; Wed, 20 Jun 2018 10:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=dtRIJm7XAWzuKjmeXnomgst7smQtEINE2MpLcO8A+M7VRbs5PKoD4FG61Lh2IkAMGu Tl6hNssPK8su+rIU+OItVIdBlHViX+vq23nrBPUju9JY1EuKaQV59i1i4uCo2uGXeVtm rfcKxJUrFLXrQedrqSEs/RaJza5ZkM8wxyA/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=KSECzsgWlJ42C+NCFH+E1u3wcXCJx/eg2jsF8uZpVKzERSYXrvvKA5fCbf+Ly4kcdC wJB9TItWvW1P9XfxMpESI2rWxaX12mhocBhXFqxa2OQajqkQGee05Xtcno7yX9YITvA+ JnnZZizsmxV/JcmcJCpIAcbQ5P8Nns85iOsQPIiA7KMTrEgPvXa9SyYnyS7uME4t5haH R9SaLYDxUVV9K4NrY97FxJvzfc6hiLcd9TAUWbLUk2qaP5F5JNESjXs/wboBCTVusn5U 7R7KWLmhA5isib3avQmPQN/eXH+n9/PvWrXGo9DMrX9FooES79b5wqCjqPymvkwk4rD2 71SA== X-Gm-Message-State: APt69E3TNLYeNcbIVdg17xQENVZtOnQe4PNIonyGYpovJpm9uujAYn5y 3CFvcNF4PEnd469WEYIq1aCU+g== X-Received: by 2002:a2e:4189:: with SMTP id d9-v6mr14339254ljf.36.1529515382622; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b2-v6sm514441lji.85.2018.06.20.10.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:01 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 15/26] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 20 Jun 2018 19:22:15 +0200 Message-Id: <20180620172226.15012-16-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's split psci_dt_cpu_init_idle() function into two functions, as to allow following changes to re-use some of the code. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index c80ec1d03274..9788bfc1cf8b 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -270,9 +270,26 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +static int psci_dt_parse_state_node(struct device_node *np, u32 *state) +{ + int err = of_property_read_u32(np, "arm,psci-suspend-param", state); + + if (err) { + pr_warn("%pOF missing arm,psci-suspend-param property\n", np); + return err; + } + + if (!psci_power_state_is_valid(*state)) { + pr_warn("Invalid PSCI power state %#x\n", *state); + return -EINVAL; + } + + return 0; +} + static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) { - int i, ret, count = 0; + int i, ret = 0, count = 0; u32 *psci_states; struct device_node *state_node; @@ -291,29 +308,16 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) return -ENOMEM; for (i = 0; i < count; i++) { - u32 state; - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + ret = psci_dt_parse_state_node(state_node, &psci_states[i]); + of_node_put(state_node); - ret = of_property_read_u32(state_node, - "arm,psci-suspend-param", - &state); - if (ret) { - pr_warn(" * %pOF missing arm,psci-suspend-param property\n", - state_node); - of_node_put(state_node); + if (ret) goto free_mem; - } - of_node_put(state_node); - pr_debug("psci-power-state %#x index %d\n", state, i); - if (!psci_power_state_is_valid(state)) { - pr_warn("Invalid PSCI power state %#x\n", state); - ret = -EINVAL; - goto free_mem; - } - psci_states[i] = state; + pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); } + /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; return 0; -- 2.17.1