From patchwork Wed Apr 10 08:20:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162004 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5919912jan; Wed, 10 Apr 2019 01:20:45 -0700 (PDT) X-Received: by 2002:a2e:84ce:: with SMTP id q14mr21933365ljh.80.1554884445812; Wed, 10 Apr 2019 01:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554884445; cv=none; d=google.com; s=arc-20160816; b=PbC4g0b+kHbW1TysfJwnlu2HclKjqdw+Y/l8RyNuFv7AB5+V+nkKYMWMu37JgekLPn Sl09qRhMzZ5tWSjTeIz52VyYVsEYgRlPz3QGbnMT2xpaEOfDhZxBYrHcA0E3Fzr1AAF7 smm7hPdMQIMFtpYtR+oPcf4BdDCwt4J7vEzgZgOHTNOn9xGTNs4ybuJqzbVY9Bh79wy7 1uf0ia1z/XCYIGsS7xAF8O6L72GIwpOKUZSo8OMWB9a13fN1yyjA2zu7Pscxrvft4zdN hx7LpNEcE6YE8CKZlNlSGP+7ajYE1Fn9YPyDzjE83QPRnwCGA629zhLwUddYwsFaY82W KcLw== 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=eEFVmtXoAE0SnjV7SY385dOs7hLOZynm6DDAtKCQCv2z52MHuTFRtb0OxL/ZMm8uJY A917OI6FN6HFb9P8kEim6hL36+yORek579Fg9VmRM2Mgmoyq7W5NofV/me/7HTgNxHrq ZAvseP2kzsyN6piufnDu7alRVPwRvt1vyvGkpuuZfL/Ioed/+zAcOQcEgc1YmzgY+U7B 2Znojjy5C/j1Eczh4ILR7hikzbBm+15yJ+xOUbLV4QPhkvYIVaGMDuL/BEV+oZ0EhUbZ amZWAzjfBVspnGK7M7pR6ct0W4DuZPLiExI/WJRzl6aQtK4mtiYSa8U899Up9WAJqHzQ Plmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=meorCV0l; 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 x1sor22560947ljh.3.2019.04.10.01.20.45 for (Google Transport Security); Wed, 10 Apr 2019 01:20:45 -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=meorCV0l; 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=meorCV0lfQredAwU2T0Tv4bAokTPM0RaKKvcv1f4Zkgzrz6wBM9F78OxGC4F4ULvZS TTwysSVVXNlZwlKOotm9O5PzUO1jLSU+pssMiR+xaVT2oGb2AiVXeBPghZsGWtw4MuXv U0wreO5tHp85amwZGZ5njG5mI7n27mJ/wzmO/r4BoimQNrPBusfrLBnH6EOF4YoV77vY vCeUpdya3P60zDgoGV7/xBw/OnHFgCehptWFeHLPHkUzg0xR+QfMNXy9PAxYjwZMjqPK pVvBEqtd/cJJTKbyJNbloU3b4tgWs12BMmgYss6UWYwxchMYSxpim+dHHV1rRUeOrlpK c9+A== 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=Y0a8ItzyGrMwfI6UoIU6uPFCVQ9wYqsTiWRDDiMfTZD/Kfgbjh3FyE6V1XPT91RIkA Ab1pKs5CcH3EKhiMz3egP/lkhtHW0qPacytTdUdM+J4hH8k41vwYWhfEu/dnknbPBAY8 7GPHg+NXlN7ZQg8B8q7+YuSlrdn60IghKuo1vqnhSuhh3K58pbhq7n5x2hjRleLdO4/a tJ5uPPxI64kCTba5BSNlSrrTGKULoXfmf3h+uaTgbiE3TMyr95/1Laqeg7ItG4VzkWUh +QPm1G0M2bu56SJVwz5cLSgjKoA7izawbR3sI3enTrzlRoh7Ecg8gPzJgMsgvpO5X9qm tJdw== X-Gm-Message-State: APjAAAWV9BsPnsA5DVZGrlVmuBHfu+HMqtRcgTHbPbRwVHm6xOhBdN3i v2u1CySpYMmB7VZ7TKjlLXDRTIAj227uGQ== X-Google-Smtp-Source: APXvYqyzghyBIm1gYgowOZ/whO39XDQHXurGBpGYX892IX7polNLrEr5KpF1zI55BOJYcE+O19Fv6A== X-Received: by 2002:a2e:380c:: with SMTP id f12mr23568517lja.116.1554884445456; Wed, 10 Apr 2019 01:20:45 -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 q6sm3385189lfj.36.2019.04.10.01.20.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 01:20:44 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Sudeep Holla , Mark Rutland , Daniel Lezcano , Lina Iyer , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH v2 3/5] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 10 Apr 2019 10:20:23 +0200 Message-Id: <20190410082025.5989-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190410082025.5989-1-ulf.hansson@linaro.org> References: <20190410082025.5989-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;