From patchwork Thu Nov 29 17:46:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 152436 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2672279ljp; Thu, 29 Nov 2018 09:47:27 -0800 (PST) X-Received: by 2002:a19:6719:: with SMTP id b25mr1539870lfc.38.1543513647866; Thu, 29 Nov 2018 09:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513647; cv=none; d=google.com; s=arc-20160816; b=TmolVBE0/oYa4mTxRV6kA41Q+e85j5guRnZHjVZm8rXyaeInWDW1OYWKrjiK/mEChb iYelZEpwPiB/czbMSVtjCcPj5iunW5geYrG29NwcfuBBl+6a6llngABWhaY4+omD5b0C 6vUo/N97SBOsm5i4AtIRlEb34Cxya5jFsnKIkd2YBPWM0nIgB0+LhwChKS6TJfnnVIq4 bZ1BMyiwkjP6zEkctgF7FAudahEnfuZsOyqueYbgHaNiAFJyk+Rgovs/ajRs4EX2ofyn e2EvutqBmTglwUqZRu/3jG5TpYGQQyUlav4X1s1ujLRWtMkycR4FZGRtCm5eaofzHFXK G9kg== 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=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=eU7eLUQKbU+M4GUc8/SIm7z91o3mBcGMY3sW3fi6jsiOs4LexNmBOzaYq/xJJcj7us VaqH2b4Iqcu1agQRpS/W/qetjhF72IXR3dgKjR0+4lUMoUndyq3miEn6zlCAsvAZNig9 vnw/9zy8O04v671WdiWFFu/akc/pOY0pN4eMPgyG6YlU56LpBBeXen4lh6ur9Eq9YGXx JrM51cVYRQCYTHPFSyJx8lr4GpoFdqweA+rkDOBK1Q7bIIfJYwwVQuDAHpmdNZN+dOMO 6YjZfwIRVFpMRodksawMPF5b43/7B0VkR1bJqIKjyWF/nQwAoDTlKpBWKFLkiGMQEWPV PCUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQS7vsEO; 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 x22-v6sor1412535ljh.16.2018.11.29.09.47.27 for (Google Transport Security); Thu, 29 Nov 2018 09:47:27 -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=kQS7vsEO; 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=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=kQS7vsEOYPpXGlZNXuLMFtfkofiQuooHy+fccXroI9o/TGMZsJLjCqyJCmBDcW+Pfm SSZXA94pqanu/v4Q8btPoMk0uRoASTgNiYRzQx/qxsxxc91rzycdnQXVJ/jkbznAH+qz ETf/KoqgfbjIQG0Nb/a4vedWuXg17lj8fgw/s= 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=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=nk0UUV09v2/kHCJnXSdyoMRtzls8TYqzHUv0anxo1zaxPy66Kif5sH/AfywRLIhJXm pwBMJmPtJVYeGjB8WMkH5e94Ao/kF/oh1ecxgOJPcznzfubu2Uf8mKUibIpJ6+i2Fq5x TZUS0i0kgvEF3cZBBplLX1ZVLpYAquA1Lo6Hb1DJe0ZHNFPtCwUoWzxsmCOygY4r/iwd CeOPN25P3b/fd0j/EgHzkceE354N55v4SOxM9g29rEyNgSRzFvlA3Snbqcjh8K1OTCqY Cjena5BKWpIDIHGueWDAhIwwtQ1xuX3aqR9A5Ue666f1YXpiAmMIX+axian/pz8o8GTI xryA== X-Gm-Message-State: AA+aEWabdPMoBDF8cjFvBfYtbZVqUxmbFkywOd1pPJca7fH98MfmZVd3 mYOWNoKl1tg+ub4TuRRQREJpsr29 X-Google-Smtp-Source: AFSGD/UXa2P2II/wtioQeASL+BRwTSaq76NVJ+o2O/6qKa9KM8ADvkUD6yNQjs/D3EcYdG3tnACO/Q== X-Received: by 2002:a2e:9a56:: with SMTP id k22-v6mr1711941ljj.17.1543513647571; Thu, 29 Nov 2018 09:47:27 -0800 (PST) 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 j76-v6sm393983ljb.12.2018.11.29.09.47.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:26 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , 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 v10 11/27] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 29 Nov 2018 18:46:44 +0100 Message-Id: <20181129174700.16585-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> Let's split the 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 --- Changes in v10: - None. --- 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 878c4dcf0118..d50b46a0528f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -270,10 +270,27 @@ 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 cpuidle_driver *drv, 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; @@ -292,29 +309,16 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, 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;