From patchwork Wed Oct 3 14:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 148064 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557729lji; Wed, 3 Oct 2018 07:38:55 -0700 (PDT) X-Received: by 2002:a19:1603:: with SMTP id m3-v6mr1243539lfi.82.1538577535418; Wed, 03 Oct 2018 07:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577535; cv=none; d=google.com; s=arc-20160816; b=GNk7G0u4DsWExtn8pU4VZjj0EH7CLpOoopmGHDV4qKOrteH8EY1/5DNn9vT8WAi4dk zuLVcg+L1XY4+nUtIU6ewtn29G9pCrihwEmT17vYMlXlfsqOR+nkYbvtGNv6pfTcgOno L5m1j7RIfjbGVcBOmB5gqsnBZATZfKDCL4G9bhPd7kvBsfEhdrvYPmL95yewEljzZJfd Mxob8H7J5YmNnFGPu6kzovrOLVpL4HLM6FP8Iupwk+5GpfRmB5fL07QV4c4ZxK+CqEBe jqKcKRv5kRmo0Iwua5orPnVmMBzEJJP90utowT9jJWH7jK9//zN9NdanxJvqWsbG5fNm GZOg== 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; bh=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=ilJjP97X0gS/Im0JHmI+JrwslO8hmMGD+Og0mc9ptaYEH3uVGkLPH4xugvGkbKBPDR CVkbfuyyTgHK/mqtlNsarQukOaVmHuY/CLuLIs47nJ9JHAqmXrwvq4SSkq5G67P54iwP eleNZTK3XnQrBY3FBpfQaiSM3ZYhgCIaOG2lzyoRJ7QFwiUeMtt8i7GdFRruhMvT/2bm eqRwCGmo4lJt6PWMFsgd/bzFvIuM5yumNvMvDEqTgGkWdSjgmXaSuce2oidanEYflQTg IwSYLWFVJtGybdgkL7+blCcXMK9uNQAGsCVOl6uAVkdSGpBzNAv1UAOqUNNP8p017u9q 37Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=desWZW6k; 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 a12-v6sor981889ljj.10.2018.10.03.07.38.55 for (Google Transport Security); Wed, 03 Oct 2018 07:38:55 -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=desWZW6k; 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=desWZW6kZm9MoHxRhIgV19z7b6BH/QRJ2OPUabhMbRjAACBRrfdos4w49U1tyBVfGU btwLt77IkDaYsTQprkKZB1Jo6BKOJEBmqoiMiLWXNOB/lsM+gjDCj7a4GLIbRSb9OZ7Z h4CEgzpdwfkr4cOrcZUV5LUdctmd0wy/Ld3kM= 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=tQkUrIjxNN/5EmFuFc1GPDUM7oKUnYJ68l8z7NUCc4s7EemBXos3NKurF8zxRflW9f 9jpxHwnGoso/jzZ+U1d2PZqAZYASbEL80bkIa4A1fQ8se6+B0EbZJMgeqDRBqAzjIBvj cA6t7rvyS1hL0Nrsd8mCzMPbg43ZxyqZJ+VGzN8gWJN4Ls6uPnpoNwSl+7f5cY4dOQok H9EzgO2k8BFkGxfEGiOm9FYmKCMT85WWR0pDuQ7p61AI6bP5diE1+wAjve3isaoKZeSs ZiUchrbfNprE+eY9nM+5IXZhkvIk569iJ55Mdq0KTps9QSZjfFGog/C8IhGxn1JdEKUq NEjA== X-Gm-Message-State: ABuFfoiCN6IKgGnmSan86ZTLVSnu7Z4DmZkGAmb7hQeGBVKTYqX2zBEu SWyRdLRqn9Gmkt2W3XIHMtJ2tTnI X-Google-Smtp-Source: ACcGV62eYUZ0f1Bynmiavxa68k4auoEEG8yZecIQWETDoD832ixenFDZHZdEHJxZcAlphUS5fEAo0Q== X-Received: by 2002:a2e:7f14:: with SMTP id a20-v6mr1338534ljd.148.1538577535185; Wed, 03 Oct 2018 07:38:55 -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 18-v6sm380867ljo.74.2018.10.03.07.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:54 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 09/11] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 3 Oct 2018 16:38:22 +0200 Message-Id: <20181003143824.13059-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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;