From patchwork Thu Feb 28 13:59:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159372 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp671330jad; Thu, 28 Feb 2019 05:59:30 -0800 (PST) X-Received: by 2002:a2e:968c:: with SMTP id q12mr4947783lji.95.1551362370336; Thu, 28 Feb 2019 05:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551362370; cv=none; d=google.com; s=arc-20160816; b=N1J4NTkfAZm8oJq6+FaPAEmp0o1nE+OhE5gugugckJ0HFDLMB1g2bsXNgA/m63bV21 iyQxnk9ucehWnRly4rhWjY5JacaRGi3g5xG5HnSS+DFB9zb7Ldh4hAOckQQ/OwWAMkdh IXaNp4IzH78fivC2dHwTGfQg/l02siFisk19EQHKRID0UA8f1U+BROqBwRk1ZHovPbzV fQtg1srZxEbAcNg+OEnbO1CgRQEuID70Kgnif1IZ9o3FfVnprvQeAMnJZxnOR3cOHp6d 684usiXUe9UWfJGga0o1O3FlTLMm++KqhgtKqKnmQ5E9cHbxc98DuagVX9tLwgS4kW2c FcUw== 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=XTL5kvu2ODR6s8WzbGt1Q9EGWFN00ZZECyFc5WKOL08=; b=gTkprByiPs1ZoxlntMZsCcvDqbWkEyJFJtChJ0iW3shMiQMN9AnCvdGTbYkPH32wQh JNgxhd3m4uvDBNPSvX9IUvwMTwm/Qe5hnqhAa4F0l4kcLdjyKLR3fQ2Ns5W0Ro4L1Kpr K1UBV66m/EaUnwiZhEbCujhOVK9mGzSItRGFQ4jNsYli3FPmTvhMHSCfhZdtTcpbFqPI iUOA7dtFXToU9ahfLqKgRD79SkVYn9Aye3kR2WVrulp1eGgXIKYe2Akd3/wekeYvq6xW oCS2kfomrZweGWfUmDT4DPPkRz3EXUBdw/a0+F1zsA/XQSiT3/N2hBq91Lt2f6WbZ8fr dWVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v5dc9YJ2; 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 y89sor3610354lje.18.2019.02.28.05.59.30 for (Google Transport Security); Thu, 28 Feb 2019 05:59:30 -0800 (PST) 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=v5dc9YJ2; 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=XTL5kvu2ODR6s8WzbGt1Q9EGWFN00ZZECyFc5WKOL08=; b=v5dc9YJ2CfLXA88Ddg4mdr8OXTZWdV8R70YevFWUfu2VAN9Rybotd5gA5nzXDb6gT7 ZLoVqbpcCW68+/GbRxNIeO0Q/qO9KbPtG3wwIVHw/xiMXN3fm+eI9683YYbfZGfdwZ94 4KxI094X2myvVe84L6FSjJSGiwzf8aSQCuFCQKcOGtknhZ3BKbkNK30++qMcxYHYsXIJ LvLezvV4gropCpiWw7dRzW/ni27ZK0rip3bjrOw/g83OAkknUrab1jGopnDuHV+iRGIe tbP7xRud7elrzW1PRRsugDFX0ZmQhUqrwFq7W4Q95XsIG4QbZ4S9fS7eKK63VCw3QULE 0t/g== 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=XTL5kvu2ODR6s8WzbGt1Q9EGWFN00ZZECyFc5WKOL08=; b=ImfLsQ/hHGjp+YXHxoR/juKD5wA8PjDZUoZ4vHz7MD2ggGgw/rkRB78d6xA2VOAc0M 8rBhnaMUh8N7o9Ulix9TIt30anFZ1fDUOJ/+KyMxJSqv0P7C5OmFLc76kq8Sr+yFhGuI PqhnIWueau4CVKVY/KFGKdBrPK23at8ByfxbCkR4oEMEKRd+e7N/608wRf0c16J2GcJY VeOYcWsdBa1l2KglKI05vNs3h91hRAb/0/6GJ7BQKFuVxeFivMJHzMc2kpYIPrHCZwwO NU3hkrPv5w8uKeD5wUYsclpccEMAhQ7u+BwwTHbgbNbr6JwPj0jJX6ql99QHHRK7E1FW jhSQ== X-Gm-Message-State: AHQUAuYmZByWw3Z5ZcmbzoBSR5kcVRR4GvCfCeOEEzen7QGUZQMkE8z0 bvZv+glIOK2hxaXdYiMulGteBFw0 X-Google-Smtp-Source: AHgI3IY2ox/XeGe6KsY5KJUJU6v/IZ2wfliDAnc848cYmdj8zrb5B2R5Xl4tkL4goYIX7vfo9L+BDw== X-Received: by 2002:a2e:21d2:: with SMTP id h79mr4411563lji.39.1551362369923; Thu, 28 Feb 2019 05:59:29 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v20sm4090265ljv.83.2019.02.28.05.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 05:59:29 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland Cc: Daniel Lezcano , Lina Iyer , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 28 Feb 2019 14:59:15 +0100 Message-Id: <20190228135919.3747-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228135919.3747-1-ulf.hansson@linaro.org> References: <20190228135919.3747-1-ulf.hansson@linaro.org> Let's split the psci_dt_cpu_init_idle() function into two functions. This makes the code clearer and provides better re-usability. 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 Acked-by: Mark Rutland 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;