From patchwork Wed Mar 14 16:58:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131682 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410573edg; Wed, 14 Mar 2018 09:59:26 -0700 (PDT) X-Received: by 2002:a19:730d:: with SMTP id o13-v6mr4101421lfc.88.1521046766557; Wed, 14 Mar 2018 09:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046766; cv=none; d=google.com; s=arc-20160816; b=XDNPETucd4+cCl5TBcDGja36k7/YWACbVMnmRsi4m5G3s+7ecCZvZaxUKOOu9E1TkM hXe/lgeD2xkM/qvkPkDAIl/snXqaU8Zkh9tcUHORogMQP9FmVEg3RGV3WBgj8u2xZqJO 1PdeiilYrau7LBglbPBQAKkigJN49zOb8UB4Dtm65Oy6Q0q782TknJzsz2MT4EFCRFuv 0kDMXM4xfXImvMdi82AXu6Bnjd1iRN++SjZBcUMd67Lf4h1SZ74GwYe9jeK9Wo/3t8S3 7/0qe11YXaqRYM7PCxpW+t7rKUhCzhqlqnHvsg9UPIH8f8c8LYl+M77VBZ1J2tKKnALK jF6A== 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=YxxZ5uPjaIBiIQcm2tWQDkG05gg7NoPlNRyW9/INWvg=; b=qHpCMlukfjxYOsiyPnC5Cr+n/OTRKipxf5BHQBLAJpgwiNeY8UUoB9VBIE4J9+loOz DoPoc19zy5y1ldxwfW5+z3HfZUvYPjtX9ZEzv2sOodk2oiqLG71w5SkyoMSh2F88cp1K EDOGyh7v1NEZxFfT7FaBrZJJ0nIMc/MN95acnmoeIb8bdio/TwkVg+iWyOSbltzLnTzS kPdGPYXdiX8rC/2j0XlK6UZPl+XwVzfffg6Z9Xsi9Qc0wQA29FYsx4URsDlidkmX3Rw1 bkPA0DEZ/y4368jVILL2mw7Sejngf5dWifrJ7DbdtUcwWMpgeuhpzOmI3qYs5x8w9ngZ JSGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UIRrkp+8; 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 u17sor827513ljd.86.2018.03.14.09.59.26 for (Google Transport Security); Wed, 14 Mar 2018 09:59:26 -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=UIRrkp+8; 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=YxxZ5uPjaIBiIQcm2tWQDkG05gg7NoPlNRyW9/INWvg=; b=UIRrkp+8HOIbkUOFVrfvey5G/oT66bKYzAmVV48EqoWjDPn6uP9Zvj7g+87JeUjo8D 5Fy23l09QIMDSH/C9iqsD58zwW/tBYm2wbZATlR8EmnXB0xwU1CBe68ZnX71kHPfidcS 2tPDQmbDX4635hJJx3q+10ksmJVRugbs8aUlk= 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=YxxZ5uPjaIBiIQcm2tWQDkG05gg7NoPlNRyW9/INWvg=; b=kZULAjoF4KSz6I5VgEW07AjaONX64tkjOBx/xM3662ZQo9l6rF3crTbOKXdMmibo2+ 1CBmgyVApRGB3q5PQ0/TTiYc/0kGK5cHb+vNxuh/iIBl+3ttxtqSEF5KSkraUwPS1qtg tfvh+GDnzHSZ0S86DZAb471mD78kg150ZizbL/iaabWK9qH9+F81zlYC0E4G+tp+mi/F 4AMSFqeM4/AkhIOj05pnUyhDCU5gL8yx0bjcMa58T6FcZZSDAoViuL4gjJkoAcUsiFVt F2fKP/38RVnBd6RiDeTu/D/HW/2D2k1oZc6WT0LEQYc5V/vtW4WX3UNAzBboiKxjCsAd wRQg== X-Gm-Message-State: AElRT7G+x1THf5Vh45o2wLdIfcJL0hMcUY9qMTDB57fkR2GxWdhE35Qf wapc3YQdhidSL/Vdu/L8PqeDYnOy X-Google-Smtp-Source: AG47ELvxftcoRlsbuDtI0b+Q1TXFVSCo/lhPm/MiUeSxIaDXUGghRYo55kXjgMklOA7HOuhc0RKVCw== X-Received: by 10.46.20.67 with SMTP id 3mr4029234lju.104.1521046766302; Wed, 14 Mar 2018 09:59:26 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:25 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 13/25] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 14 Mar 2018 17:58:23 +0100 Message-Id: <1521046715-30683-14-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index c80ec1d..9788bfc 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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;