Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2762064imu; Thu, 29 Nov 2018 09:48:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzksuksIioQZWS1Gov+TFIAlvSbNoHEhkWyD/BwlOUg0smYkwr/EOEKIYiD4VEoz0Bi/GY X-Received: by 2002:a17:902:110a:: with SMTP id d10-v6mr2398837pla.85.1543513730851; Thu, 29 Nov 2018 09:48:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543513730; cv=none; d=google.com; s=arc-20160816; b=YtvjASmCvUDa/Y8/4dZG1JqPSITMYhqfvPChkb8aNnISJpDC10/tk1X5jBCRD/7Ge6 WWyFtLJyp5Bwuvkn4/klPf9RMH6DBSqDTGa6z5XMYI/lOygkMLoch1ARPOxpm3cZqPk2 mVprGjYrgP2B5Un4teIfLw8eZ+aMPEs76MMyt+R5n9p3NynjfRLn9E85NcKw0u9IwYSm OtPZ7JhQh+Foj+F/TDXFIghSFo9K9IKi7HpA//aAhtd0OSbLpPK2DSyupTA1yEx+bmwP NwyH5dfF23qMVyvN7EjyvEjpqdvRC2GwjCnwJ0JecgS+Z7qzRxmD5JAeznh0oTDh33Vi nCFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=XFV7/xa7cL1a5MNmxoRSoioCqU31/32z/9ZyFTbYyA2GCUz727PDclrn697Ir05o71 mg4p5chBrYk07DhcwUmFVTpD1qjQ1Qkkh8HFLAwnYOaFfakwIpiG8+jSa+HTUFQvYU01 WxK6e7eK2aJRdWX2sCNusQNufiFi9DrvRyxxNhYVS3qPWxVv7ebCPF4eXbVV0WWlv92A W1SWjXwVwYicpFmAA9L5OgUQCJU3Enq34IeS/a4DvF5OZqVpH8JQ8ZJGjheuSGPJ6UJA w7zsLkFnlt+0SY88fPi8QKrOc/alJaPwoBN3Zmb04V8AmXgwwaLESgiKnoQXXNm6OzwS zwQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQS7vsEO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si2591502pgt.222.2018.11.29.09.48.35; Thu, 29 Nov 2018 09:48:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQS7vsEO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730932AbeK3Exk (ORCPT + 99 others); Thu, 29 Nov 2018 23:53:40 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42613 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730870AbeK3Exi (ORCPT ); Thu, 29 Nov 2018 23:53:38 -0500 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so2520302lja.9 for ; Thu, 29 Nov 2018 09:47:28 -0800 (PST) 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=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=kQS7vsEOYPpXGlZNXuLMFtfkofiQuooHy+fccXroI9o/TGMZsJLjCqyJCmBDcW+Pfm SSZXA94pqanu/v4Q8btPoMk0uRoASTgNiYRzQx/qxsxxc91rzycdnQXVJ/jkbznAH+qz ETf/KoqgfbjIQG0Nb/a4vedWuXg17lj8fgw/s= 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=C0VjsI0UfpBTK8w+W8XunAgB9zCJk33hNRRNGzP35VQ=; b=RmJsr8WuG7QbGgd2vlW+CpeRWD/i5VYhnj2goffOlwuThFzuYoui67JDqNbwB1RzPe +mSbFrooD+GDRB1cpuHMAcp/L9kidww+XNizIKmujCd8/4vQcPuNiusuHPaNLTQLQ+UW RbeyH8mGbHPteQawnwtCw1VkToiPBEgQxbchwGHxyXJWuR0MrD/p1qO5HYbG/fNiXriM mIW9dboO1q7/vnXJ5NFWfa043lYcumVdA6DlgnDtPIIxaCH1nexPW+ODk0YrO3+sgOne yvD5f5+1ltMLZ+AGnwEpzMZ2WNbq7FjvolZOVOBsuVVpH1SRwbSoiFqSyKo8lBNNR4mj TCUQ== X-Gm-Message-State: AA+aEWY0Zr0uUM+yL5+q1lPGKIH2fvQCmj1TyTCKlrpjQLpigMielP5m m365KKpB7PI33JEzsM6xUCijnw== X-Received: by 2002:a2e:9a56:: with SMTP id k22-v6mr1711941ljj.17.1543513647571; Thu, 29 Nov 2018 09:47:27 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id j76-v6sm393983ljb.12.2018.11.29.09.47.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:47:26 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 11/27] drivers: firmware: psci: Split psci_dt_cpu_init_idle() Date: Thu, 29 Nov 2018 18:46:44 +0100 Message-Id: <20181129174700.16585-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129174700.16585-1-ulf.hansson@linaro.org> References: <20181129174700.16585-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's split the 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 --- Changes in v10: - None. --- 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 878c4dcf0118..d50b46a0528f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -270,10 +270,27 @@ 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 cpuidle_driver *drv, 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; @@ -292,29 +309,16 @@ static int psci_dt_cpu_init_idle(struct cpuidle_driver *drv, 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; -- 2.17.1