From patchwork Thu Apr 12 11:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133253 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573757ljb; Thu, 12 Apr 2018 04:15:05 -0700 (PDT) X-Received: by 10.46.112.24 with SMTP id l24mr410290ljc.104.1523531705023; Thu, 12 Apr 2018 04:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531705; cv=none; d=google.com; s=arc-20160816; b=Z3a/Z9gspEx6PYJ7erGWDhaKAAOOlx4mG2ksg2SURlz/tjsnIUNQvyTv2VIaQF+LQ2 qe7oPb0VveLWfO1ogrclFTmKqWVOxNXpvqPwN9KjHAVo+keU8AVyRbH8KUSNXkb5mMLK Ag5ZtEz+Cem7IR1zw4Hwmikm8p+klKzkw9e+QBywTmQMD7zIK6DUMJvXW+vcij5kPCW1 lI40A/f7n21CDX3cNbDwGkngKcINXsayVIOWNWXntIwCBykdg0/rsk+XxlokU7QmXUld TMzYUqhzKgE0xdlHwLNo9P7nkumJCyQ79ALyr/+iOtup9SXIZMVrtK6lPlRCqUv8yRpp AMIg== 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=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=bB9l9VTzqsQBOvX4C5CLm3LHkrM4g15GBqo0+3/mjHvcq3TvItN1wwQfULCs3nvHQI 8LHHI+j8KdRw7Ic72KCTrTCOcpv+2EcLTNomNKBw6YkDhVY7M3Ab1h5wR9vS+efdnrya KYaEoFVbSfpq0HHfbvolvigj5yx/Zcvd+ciXb+nzNu2lJKHlvZl1hoP6E0B0zemEjl3Z 6W8FzqSKj7s5zdefi0IBac24/H9q34tOo5uXDFjE6FL8LX18+50cHPVijyR1hkr8a4ku wOvYRp2rwnePoA54uCXMvUwVsXV4u5okoZ66cImTaFxqxbdn/RA3NpqMoIuecVqvGz3A 0eww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cBjSjV5P; 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 y25sor872676ljc.105.2018.04.12.04.15.04 for (Google Transport Security); Thu, 12 Apr 2018 04:15:05 -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=cBjSjV5P; 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=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=cBjSjV5PFnD07h1O6LvsK2itl23RxL65cjFIgieNsawqWbvb7yi1AzU81SLXaNh7EY DBSYxG4mP28jav9kJtKAsJ/BAk7+Jlv8kbPNso5zCNfrnL8wfj+Qii5PBnXjOfYGpE3M jPP/wvA2v+RF9jhIYw844gNURAugVixGf8zf4= 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=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=BTOdvwLATyN/UdfZBI9hK7QbVHpcy8jR/GHRuEUyUWUUIKi2kcRnzw4TM4PzksA450 qW80GT9b/tQ2ujfki2IT8NZFvR66/fDieDp6tLuG/zEFgfbbdgaSVHZcQzD7w3+Ub5dF M+wtua6o9d0ZwUYXq80I0JnGicko5qmcgVP4ntxQpjHSgKnyVNMOE6p1TiuLEg0g7bzR UqAjzGvrWPUCP0gk6dCWBpnxpGHEB4RWRjg7BDy6y+7qb1DHzkbGf09VS5ggclNMTP+m Ro6yVaqeQVxfz11u6SMziuWhQ8kN+N95Y6doWSb8cX5q1wCN9bpVxwjdRT68oJ/oM5NH aj8Q== X-Gm-Message-State: ALQs6tCjWPYgpHyeQXawH16R4q1x098u4UWQrJxn7m6yOcC8unJI6qz3 q83SX7l6is2BPmRVHnbFsPqqh6lF X-Google-Smtp-Source: AIpwx4+j5+eSgEk0LXcdiOH0Et0QWH2XgEfLgDNuqtd4+zHQIzO4F1fLM5+KKgKgVKAZMAWW5H1tYQ== X-Received: by 10.46.158.19 with SMTP id e19mr391628ljk.47.1523531704817; Thu, 12 Apr 2018 04:15:04 -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 r29sm543187lje.72.2018.04.12.04.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:04 -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 v7 15/26] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 12 Apr 2018 13:14:20 +0200 Message-Id: <1523531671-27491-16-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-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.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index c80ec1d..9788bfc 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;