From patchwork Thu Apr 12 11:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10338407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 347AF603B5 for ; Thu, 12 Apr 2018 11:31:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22C59287DE for ; Thu, 12 Apr 2018 11:31:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17513287E2; Thu, 12 Apr 2018 11:31:07 +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 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 A7B5E287DE for ; Thu, 12 Apr 2018 11:31:03 +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=59HhxEVGU9Gb4sAUt2+l5Gy3gjrEvu1s2Nop9xdUDLE=; b=QFtQgOHgarjzik3qWODDdlUUEb 9oxXNaZgBx73VEXxcmeZdWqTRS6p25RE9gHfd5Mgfm8+UaG66jbITLUkdpMCxic9WYLqr7ZNjnVNl TNbkchhp5hbuplB5Zt1nYS1UazSjuawDVagKFuaTwvsYfLQXzlhHZKKxaTu8F4m7/ZABdpB9Achkb VesWCYyoKc3qB9bUfa1fKCsMkgpOvfx1vvUsVudT/xzLRY226p3z19evTU3IiINLyKaMfOfvjKeSf ajNCi2UTJtVQOAtjLgnWFzexyMKvKnBXk/pNrNs4YhemRIHyuRRiqnDbIUsnqRUtn30g0VM4CKfLm as/jM0yA==; 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 1f6aRK-0001dd-Ow; Thu, 12 Apr 2018 11:30:54 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6aCE-0005ig-0g for linux-arm-kernel@lists.infradead.org; Thu, 12 Apr 2018 11:15:24 +0000 Received: by mail-lf0-x243.google.com with SMTP id b189-v6so7137904lfe.2 for ; Thu, 12 Apr 2018 04:15:06 -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=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=cBjSjV5PFnD07h1O6LvsK2itl23RxL65cjFIgieNsawqWbvb7yi1AzU81SLXaNh7EY DBSYxG4mP28jav9kJtKAsJ/BAk7+Jlv8kbPNso5zCNfrnL8wfj+Qii5PBnXjOfYGpE3M jPP/wvA2v+RF9jhIYw844gNURAugVixGf8zf4= 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=UAxfvOZVLs+uiO996nUO+MUMq3F8v5WP14P/MYRhXP8=; b=N0L7w25vxeRo23fsc6+KtosmtkxwFtTGQyaWrVPnbertOoHfRkHUsCv5nXnp/+cI44 bTK1BgvES6rwNusoEWsSEtt7UYMFClmeF31WkofSBX21WXsrK7IIszPdkSS8d3qha8Y/ aFsAZ4pWhX22bhpNl/04r/JYxADzi1CuhN/snBl36Igtiy2c2Qyn0wFGK3TBC2kTBYp+ 7dZTI1rMPe4es69jX8S5LmIEOEy8AV2ZIrh+MUIov9SIOCUqfdJR+cr8sLl05sCncwFJ HmA04ucVkIFRF/FTs+Mix0971bK6ZY7LqerXRB248Kx9O7miB6W6EkPflcT01iWB40+0 1X+Q== X-Gm-Message-State: ALQs6tB5cs3MU1emSjqzgWmojO3hMq1NOorw0m8Vde6SGDQRRZRrUbX6 3gmCHQat2GMkzyLloXqlo9BZ4w== X-Google-Smtp-Source: AIpwx4+j5+eSgEk0LXcdiOH0Et0QWH2XgEfLgDNuqtd4+zHQIzO4F1fLM5+KKgKgVKAZMAWW5H1tYQ== X-Received: by 10.46.158.19 with SMTP id e19mr391628ljk.47.1523531704817; Thu, 12 Apr 2018 04:15:04 -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 r29sm543187lje.72.2018.04.12.04.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:04 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Subject: [PATCH v7 15/26] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 12 Apr 2018 13:14:20 +0200 Message-Id: <1523531671-27491-16-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180412_041518_100542_B03D3106 X-CRM114-Status: GOOD ( 17.99 ) 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 , Juri Lelli , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , linux-arm-msm@vger.kernel.org, Daniel Lezcano , linux-kernel@vger.kernel.org, Lina Iyer , Rob Herring , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Lina Iyer 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 c80ec1d..9788bfc 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;