From patchwork Wed Jun 20 17:22:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139383 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050798lji; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) X-Received: by 2002:a19:eb07:: with SMTP id j7-v6mr11659451lfh.141.1529515382823; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515382; cv=none; d=google.com; s=arc-20160816; b=04GiIuB2wBeHfpWkjTY084X1jaVviE6ouCmuF4ZZCN9HT5S36HGg3bLId/ObN6ZhHv jeHBjbEaVsU3Wg83CkLbPRWqs6jKpmvGftDX9BLsLwp7f7GtzlvitNX3CLzTgZuqoZwT 6LuzsM9W98Tk682yF89QaF4WcaHfsA+bEH8hDPrYnHCnUH5jCjhOhC3AwTNHAhoErETc NV1l5f97OeS0rPRi0DByU8R0lpvZV3z36eGwYo7dn8DOKXJMkhF+5wfko4yiR6KaCGbG 3q3ObMC56iB0r1FEIAbpO+Tk2Q3R8tfrSvu0goxDx3N32gWLT8LyYKynlKPxzCTlCuQN fQTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=mHhI7zOfluSH2ipPaP4UEIhExor3AaylN6Mul7H/gUb3WNwvFJMJkJkgbudAU5ILIs 1lFQGU4JekTRCo0kzmsY0WBND/SqDscR7OPBzvw43gHw85ZXAHtiPjPpaIuopL27j2Kt M835Rc870Whyf5cyyXa8XnlwxER+Rswo+qa8G93RYM2sNgc3HvUXd+vBdFm+JKHqCgDg eAg6h78zoKcwB/AAefNTSot+Ig9t+ldugwkwAsPH/7zgQnlIfRzHMZK/r84idsrq5l55 X8inNMW4XSi34pyTbpJ0zYIyHsZ/qB9dEojePPvqXFnaVnsWcArkxd5Rmv59WbjuG2vY jSsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtRIJm7X; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r22-v6sor743835ljh.86.2018.06.20.10.23.02 for (Google Transport Security); Wed, 20 Jun 2018 10:23:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtRIJm7X; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=sExqsbxoxvPzDE9MztZQImiGSjvZ+E9iLQMa9QvMcHpAqXI1yUwYUvGXpgtE+I0BII F0V2js9A8+tAob0WkFgMmPi6pCIIPS3UjNWEzU0w3D4RlL9pD0v65lkqCwS+URb3b0nm pRDN/CTMvpsGx/gWE+PrRI7mHuhMvV2dAfwu7WmEzJKdIxbsy9T/48tP3EBZMGxDa57+ qFfFn+a6JP0+Y/U2FkS/7ovCyBx3wBfw/dCpMggMGedV7X8qlkt083tM2fzuQ3PoJC4l jphPr5SgN3yxdGUxEIDCqHiB/rP4BETEEJrwz94oGoFl3sh0dr3qyY46wzsDhQoF2MB/ t0/w== X-Gm-Message-State: APt69E0RePHBIRahEbbAQCwJu30qThuopTipHLcoSFAabqwrB/Knr8T+ +RzALW8fHu9XzhiQ8fUCAGV1HQHq X-Google-Smtp-Source: ADUXVKJiQlFWeGZEmlqwQkx047GLHSjmbFpCcwQ/EkZSuHGtcsYsECmjTNsT5vQg4C0qcFOJdXrHdA== X-Received: by 2002:a2e:4189:: with SMTP id d9-v6mr14339254ljf.36.1529515382622; Wed, 20 Jun 2018 10:23:02 -0700 (PDT) Return-Path: 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> 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(-) -- 2.17.1 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;