From patchwork Tue May 3 06:57:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shreyas B. Prabhu" X-Patchwork-Id: 617826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qzX6l13W8z9sDk for ; Tue, 3 May 2016 16:57:35 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3qzX6l0K6jzDqbG for ; Tue, 3 May 2016 16:57:35 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3qzX6V0pBnzDqB9 for ; Tue, 3 May 2016 16:57:21 +1000 (AEST) Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 May 2016 00:57:20 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 3 May 2016 00:57:18 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: shreyas@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org;mikey@neuling.org Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id A759119D8042; Tue, 3 May 2016 00:57:01 -0600 (MDT) Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u436vHlj40501422; Tue, 3 May 2016 06:57:17 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D182AE03B; Tue, 3 May 2016 02:57:17 -0400 (EDT) Received: from adminib-ovr2cdm.in.ibm.com (unknown [9.124.35.60]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 20BE2AE034; Tue, 3 May 2016 02:57:15 -0400 (EDT) From: "Shreyas B. Prabhu" To: stewart@linux.vnet.ibm.com Date: Tue, 3 May 2016 12:27:04 +0530 Message-Id: <1462258628-6827-2-git-send-email-shreyas@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1462258628-6827-1-git-send-email-shreyas@linux.vnet.ibm.com> References: <1462258628-6827-1-git-send-email-shreyas@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16050306-8236-0000-0000-00002FCB51A3 Subject: [Skiboot] [PATCH v2 1/5] slw: Simplify if-condition while adding idle states to device tree X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: skiboot@lists.ozlabs.org, mikey@neuling.org MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" if-condition in add_cpu_idle_state_properties which checks if a given idle state is supported is bloated with multiple '&' and '||' operations. Simplify by adding a mask variable and setting the relevant bits. This patch does not change any functionality. Signed-off-by: Shreyas B. Prabhu Acked-by: Michael Neuling --- hw/slw.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/slw.c b/hw/slw.c index b67097c97ddd..231fefcd0b58 100644 --- a/hw/slw.c +++ b/hw/slw.c @@ -500,6 +500,8 @@ void add_cpu_idle_state_properties(void) bool can_sleep = true, can_winkle = true; u8 i; + u32 supported_states_mask; + /* Buffers to hold idle state properties */ char *name_buf, *alloced_name_buf; u32 *latency_ns_buf; @@ -589,12 +591,21 @@ void add_cpu_idle_state_properties(void) name_buf_len = 0; num_supported_idle_states = 0; + /* + * Create a mask with the flags of all supported idle states + * set. Use this to only add supported idle states to the + * device-tree + */ + supported_states_mask = OPAL_PM_NAP_ENABLED; + if (can_sleep) + supported_states_mask |= OPAL_PM_SLEEP_ENABLED | + OPAL_PM_SLEEP_ENABLED_ER1; + if (can_winkle) + supported_states_mask |= OPAL_PM_WINKLE_ENABLED; + for (i = 0; i < nr_states; i++) { /* For each state, check if it is one of the supported states. */ - if( (states[i].flags & OPAL_PM_NAP_ENABLED) || - ((states[i].flags & OPAL_PM_SLEEP_ENABLED) && can_sleep) || - ((states[i].flags & OPAL_PM_SLEEP_ENABLED_ER1) && can_sleep) || - ((states[i].flags & OPAL_PM_WINKLE_ENABLED) && can_winkle) ) { + if (states[i].flags & supported_states_mask) { /* * If a state is supported add each of its property * to its corresponding property buffer.