From patchwork Wed Oct 3 14:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10624971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57DAA1515 for ; Wed, 3 Oct 2018 14:44:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4906528B44 for ; Wed, 3 Oct 2018 14:44:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AD1028BFF; Wed, 3 Oct 2018 14:44:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5E3E28B44 for ; Wed, 3 Oct 2018 14:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xtgdOB3X5VGaLdtpHxTFcMHR04K9mrSdm1FSgYt3Ft4=; b=RB0sda8eOR7qLjbjBJfD5mmpGa ME+mJWhhtQAN24+ieupQU74uNc4xfhonTijNeDX1AwrukmVCLqgkZJXBQxMOZRjSaXcyzfwhCCwY1 CygtAPYMpyTD+cbeYhK+8w/aWTCktZiX6hMgcY7fLEBhFdHmOQXUfYCwk7sQeoNQs+ICEdWoE4F3k gw5wmbziHd1oRVvZH5dpYB5Ss0HfGny9GGw6RnteMznBA+W31+DD4u016594Q8rkYMY7Ct50MygFw vO8w1zc+pTrtBxWLR6iaXg7m5Ki6PfkIuI2X/U7U9O3Zoc2PmzONQZtvg0Y+TAjoDTZDr0etVjAHc nOafBVqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7iOB-0001qx-4N; Wed, 03 Oct 2018 14:44:35 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7iIt-0006Ut-FF for linux-arm-kernel@lists.infradead.org; Wed, 03 Oct 2018 14:39:48 +0000 Received: by mail-lj1-x243.google.com with SMTP id 203-v6so5314275ljj.13 for ; Wed, 03 Oct 2018 07:38:56 -0700 (PDT) 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=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=desWZW6kZm9MoHxRhIgV19z7b6BH/QRJ2OPUabhMbRjAACBRrfdos4w49U1tyBVfGU btwLt77IkDaYsTQprkKZB1Jo6BKOJEBmqoiMiLWXNOB/lsM+gjDCj7a4GLIbRSb9OZ7Z h4CEgzpdwfkr4cOrcZUV5LUdctmd0wy/Ld3kM= 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=60U5bRPKDKJyHR17D5TYGPWZf08eZgljN5hkHwmsDUA=; b=A3VP+D48xi2kxwdrLZOBSoOiJPnqdWIZo8JoZXklDian/KNrwJtqQgKPyoRfvDU7BQ hnH61zVvZf4yNkGApUF8uxLfbsWKAEh5fAF0zB/MR3o2QasBwr7E2MwzTIKfrHW7y6cu w7DECDnbihSz7HornIZxRfGSVfwTqjy6WNFPnqnuqhX6E9ZIxvspW/0iLAoQtyJslPB8 D+bM8MweNqN8t3oXwcYiNM/6lTHTwW6hxt/TcFgz2zeSriu+O3kPNf17bUWIwGCRCoHW 1FLQIPGdUqYoigfgzC8pRXHrJ46HJEhuX2WZWWqcFdEfVfwY44NMd9jYAAYDXxWHPt2e PnBg== X-Gm-Message-State: ABuFfoicbabmLds7/TrcYsJOPfdQ5KuEzfvlOGdDylll+MQyScpUIbiT asrJIzgIHtWWnhnXAFgxwsgeLg== X-Google-Smtp-Source: ACcGV62eYUZ0f1Bynmiavxa68k4auoEEG8yZecIQWETDoD832ixenFDZHZdEHJxZcAlphUS5fEAo0Q== X-Received: by 2002:a2e:7f14:: with SMTP id a20-v6mr1338534ljd.148.1538577535185; Wed, 03 Oct 2018 07:38:55 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id 18-v6sm380867ljo.74.2018.10.03.07.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:54 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v9 09/11] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Wed, 3 Oct 2018 16:38:22 +0200 Message-Id: <20181003143824.13059-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-1-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_073907_581398_68A553E7 X-CRM114-Status: GOOD ( 17.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Geert Uytterhoeven , Kevin Hilman , Tony Lindgren , Viresh Kumar , linux-kernel@vger.kernel.org, Lina Iyer , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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/psci.c | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) 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;