From patchwork Wed Mar 13 08:36:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 160209 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14045752jad; Wed, 13 Mar 2019 01:37:09 -0700 (PDT) X-Received: by 2002:ac2:5638:: with SMTP id b24mr6784348lff.18.1552466229770; Wed, 13 Mar 2019 01:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552466229; cv=none; d=google.com; s=arc-20160816; b=VEJYipOvVhyW3WV6CZoujpyo71HphUS14dGJ2RKiLIogCRz10g3c6cYqTd+Uv1mK6Y Tn9rP/IM7cOZnC57hmvSOmKDcUzhuLbtpiZ1BPdiZztBk8SK9kk7PXCDEv7YHH/rTZ3Y fxzTL2TyMMWi8TfyXjttOmiPjrnbICJV4jBNZV8j+s+EF8tEB41daizwJINHwpGN4c3k Ug6Ysz2em1S33f/AEhcAUIYb/y+5XQbnIA3CFjj3CUrepPsUGqOp9Pe8b6BlXlvWe/fi DybKvocsdFXuc573r9cQgPqAujNLIBGkkpCxXD28g7If+Vc6w5/6w9L4n9ds7v6YENrO Xmzw== 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=fqLAcdPj/NLZOrfZZI3kgT4b9oSplDLhcdYfEWYk7f0=; b=c6Nww1Ppwo/2oE8zUVxVTlCPKXWu/I6WqItIVOVq0Z9X0u+qxUDwkqCDsGePxOxfL0 p+T0k+NXLYv2840EC17ri09p/nuNlrbLIrH9KE0aY/yKBsSbADtfuWgxYaUTRTzl/DBM 0tDXqtSHHlO+KBvKOcE9f/RmrqWU960AapgzheCvGphanECka8upYU9C+MMvS2vCe/uV LU5z1ULAFohtefPWGuERx0IDQoDAtMi9Dcvp0vuTUeyOIwz9qFoYzSyBO3WSe4r9YmVe uB0qn7nj6KqB42WnUdcIiXTVutCHPqrx/hdmz/vOEWMdWbBRQP6IjHBACmw4uHt4eDAD O+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PZKTNnD2; 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 q5sor2989799lfc.64.2019.03.13.01.37.09 for (Google Transport Security); Wed, 13 Mar 2019 01:37:09 -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=PZKTNnD2; 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=fqLAcdPj/NLZOrfZZI3kgT4b9oSplDLhcdYfEWYk7f0=; b=PZKTNnD2nwwHzJ7qoJoJQv4NDheskpbJ1YxcSM9eJF4owUl/WfZng6DstF/znQ8x8B pDEo/pJ61thVr5M/+qqLUAkj0+OBtXQmLuwrGxf8WSVHw+IiaOlDqV1fsXTjNCKgAnQb TJzEXazOl8YtWqn5cOuHlqSFQO2jQXIoQrLaXx9VcX1FNUp8cauGDy/4rLGCUvJ8sxZ0 yxM5fF/CvN6YRxRRiq8FvpO/JGQb9QX2B1LfzOKTw7H1qQlBUuh408M+G0j74Gxi+xsP Tj/lfMCSQb/y/txQziLhAwYHSbtcWmjdMsHdd5LP0Jn9TS5jwo4vy2Z9wpRpmN50a57J jIDw== 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=fqLAcdPj/NLZOrfZZI3kgT4b9oSplDLhcdYfEWYk7f0=; b=KwdM7pUKCZOetjD1707OuuqSNwpyWjuAPRLuDNomQ/IWrkjoyx1RLVjIn06u+EfcO3 DTxbvu9J0D2lodMRWQUBpJW2odoOnrDhkB1WLqNuJhDIghKb9TVl1rkU0VzVwGMwHhJg 7BhKS4M9D7LHel8vXkaPElarvq9RBL5NgqFF724qywObObySYpZUgQ0nayxB25HQsY20 XEg5KOTfeKP0MS6L3E9vL7DDj247tXR68m5QtiqTAqg5kOgtiINwymW/fj+NwvXdcodI 58AONuM4NAiMXClJ/2axtHqYb8dAx7xVLs6wL9YvhczUIGEIjP8LTNwnXXvHsWZbyKAO l6yg== X-Gm-Message-State: APjAAAXaRSPbIT5wmp7drYRqxyN7k+Uq1ZCDJ1wNKHbgf7antZHF/eqU XyO6DZwXADhSjLMIrAWaCgub5Uma X-Google-Smtp-Source: APXvYqw0YNNaw6inULtc2yUsTyMmfoNTgmT4UYRb7G0yq3HhG73gLEOmrT21PpBm2ilWoX4z2aWjGw== X-Received: by 2002:ac2:51a1:: with SMTP id f1mr1139636lfk.25.1552466229393; Wed, 13 Mar 2019 01:37:09 -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 a23sm1707716ljd.20.2019.03.13.01.37.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 01:37:08 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Lorenzo Pieralisi Cc: Sudeep Holla , Mark Rutland , 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 v2 3/5] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 13 Mar 2019 09:36:57 +0100 Message-Id: <20190313083659.7100-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190313083659.7100-1-ulf.hansson@linaro.org> References: <20190313083659.7100-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 Acked-by: Daniel Lezcano Acked-by: Mark Rutland Acked-by: Lorenzo Pieralisi --- 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;