From patchwork Tue Apr 19 12:30:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 66092 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1820924qge; Tue, 19 Apr 2016 05:31:05 -0700 (PDT) X-Received: by 10.66.251.10 with SMTP id zg10mr3657054pac.1.1461069065079; Tue, 19 Apr 2016 05:31:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si2406357pat.152.2016.04.19.05.31.04; Tue, 19 Apr 2016 05:31:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753907AbcDSMai (ORCPT + 5 others); Tue, 19 Apr 2016 08:30:38 -0400 Received: from foss.arm.com ([217.140.101.70]:39495 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752984AbcDSMah (ORCPT ); Tue, 19 Apr 2016 08:30:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 24B5542D; Tue, 19 Apr 2016 05:29:15 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.207.150]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B70563F25F; Tue, 19 Apr 2016 05:30:29 -0700 (PDT) From: Sudeep Holla To: "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Lorenzo Pieralisi , Al Stone , Prashanth Prakash , Ashwin Chaugule , Mark Rutland Subject: [PATCH v4 3/5] drivers: psci: refactor psci_cpu_init_idle in preparation for ACPI LPI support Date: Tue, 19 Apr 2016 13:30:11 +0100 Message-Id: <1461069013-13292-4-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461069013-13292-1-git-send-email-sudeep.holla@arm.com> References: <1461069013-13292-1-git-send-email-sudeep.holla@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Inorder to accomodate bot DT and ACPI LPI support in psci_cpu_init_idle, move the device tree specific into psci_dt_cpu_init_idle. Cc: Mark Rutland Cc: Lorenzo Pieralisi Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Sudeep Holla --- drivers/firmware/psci.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 11bfee8b79a9..af6c5c839568 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -250,11 +250,11 @@ 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_cpu_init_idle(struct device_node *cpu_node, int cpu) +static int psci_dt_cpu_init_idle(unsigned int cpu) { int i, ret, count = 0; u32 *psci_states; - struct device_node *state_node; + struct device_node *state_node, *cpu_node; /* * If the PSCI cpu_suspend function hook has not been initialized @@ -263,6 +263,10 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) if (!psci_ops.cpu_suspend) return -EOPNOTSUPP; + cpu_node = of_get_cpu_node(cpu, NULL); + if (!cpu_node) + return -ENODEV; + /* Count idle states */ while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", count))) { @@ -303,27 +307,18 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) } /* Idle states parsed correctly, initialize per-cpu pointer */ per_cpu(psci_power_state, cpu) = psci_states; + of_node_put(cpu_node); return 0; free_mem: + of_node_put(cpu_node); kfree(psci_states); return ret; } int psci_cpu_init_idle(unsigned int cpu) { - struct device_node *cpu_node; - int ret; - - cpu_node = of_get_cpu_node(cpu, NULL); - if (!cpu_node) - return -ENODEV; - - ret = psci_dt_cpu_init_idle(cpu_node, cpu); - - of_node_put(cpu_node); - - return ret; + return psci_dt_cpu_init_idle(cpu); } static int psci_suspend_finisher(unsigned long index)