Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3936972pxk; Tue, 8 Sep 2020 06:37:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO+3/+H9QXUgQycxNztbHBttXMFGKdKo/U27D6vM1/Yjox1mT+cC4lDnTxjAKLddmliw3s X-Received: by 2002:a17:906:4755:: with SMTP id j21mr26576597ejs.228.1599572275294; Tue, 08 Sep 2020 06:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599572275; cv=none; d=google.com; s=arc-20160816; b=cvvm2q4iYlSinHJIs9Bv5RZk4gLCETwTmGIn4Y4Bo0JPUNBX5i6ZdjdwtMFtw+eJ9k MEInGxWx2Nouj8mF7mRQSTtc75Uyzw6U7zyVbNWJKg58HT7u75IY/gbJmLnNQlOUs632 cInauFO7sfOhtdpd3kdo1c2LKLtZJHkHS0a+RLE1J4w9I77Hu2OhlndP+6JQiTwmzCLj W8PSWtlrELdXW6BSW5mJ0nyyK93pLmkL4HQQOxZStaXrDYLm0GcldR1cRaJulM5R752W W8pvFHH6oCrLiHcwqnLPxf9TfGDwOV2mJaqF0POjg08t7CSqbMm7lTDuPGH2jTRncyVK HvOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=GDEII7KeaW90nOeGnoV+45WlwIykR0xDFlSIbOxHc+s=; b=HjcaHVfDvgPQ44cg2oMZ11j/FgbQQQRq64YuykExcVrrj4KITndVXjIuezBuca7/FB jCnZ2G6TFx53+xl1Q4PNb0+1eXAXHyV93ju443Otk+ePLm7BVspxKdHeSsd1Yjcwxii8 B+i+b1/bVaE3RXhx5ZzsifY0TOQBdzxcJWA3bYcpzWlOvk2XKD0Scl1sNvu77pcTofNv y67EjA+sPHyHptregGWFPbIK9NDno6p98uGmtfASbnwYxDK4z0Ouf7rRQi3gkY1O1ff8 7JkZhnEDbmpgBzIZ7PbnNYN1Gj0xR3+Fkqo1e5ldt0uacR9VmiR2vURuAh1lhZJld7f7 ja8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si11654858eji.321.2020.09.08.06.37.32; Tue, 08 Sep 2020 06:37:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730114AbgIHN2k (ORCPT + 99 others); Tue, 8 Sep 2020 09:28:40 -0400 Received: from ZXSHCAS1.zhaoxin.com ([203.148.12.81]:17809 "EHLO ZXSHCAS1.zhaoxin.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729799AbgIHLOX (ORCPT ); Tue, 8 Sep 2020 07:14:23 -0400 X-Greylist: delayed 906 seconds by postgrey-1.27 at vger.kernel.org; Tue, 08 Sep 2020 07:14:23 EDT Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS1.zhaoxin.com (10.28.252.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 8 Sep 2020 18:58:43 +0800 Received: from tony-HX002EA.zhaoxin.com (10.32.56.38) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 8 Sep 2020 18:58:42 +0800 From: Tony W Wang-oc To: , , , , , , , , CC: , , , , Subject: [PATCH v1 1/2] x86/cpu: replace two-condition switch-case with if statement Date: Tue, 8 Sep 2020 18:57:45 +0800 Message-ID: <1599562666-31351-2-git-send-email-TonyWWang-oc@zhaoxin.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599562666-31351-1-git-send-email-TonyWWang-oc@zhaoxin.com> References: <1599562666-31351-1-git-send-email-TonyWWang-oc@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.32.56.38] X-ClientProxiedBy: ZXSHCAS1.zhaoxin.com (10.28.252.161) To zxbjmbx1.zhaoxin.com (10.29.252.163) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use if-case instead two-condition switch-case. Signed-off-by: Tony W Wang-oc --- arch/x86/kernel/cpu/centaur.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index c5cf336..5f811586 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -90,18 +90,14 @@ enum { static void early_init_centaur(struct cpuinfo_x86 *c) { - switch (c->x86) { #ifdef CONFIG_X86_32 - case 5: - /* Emulate MTRRs using Centaur's MCR. */ + /* Emulate MTRRs using Centaur's MCR. */ + if (c->x86 == 5) set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR); - break; #endif - case 6: - if (c->x86_model >= 0xf) - set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); - break; - } + if (c->x86 == 6 && c->x86_model >= 0xf) + set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); + #ifdef CONFIG_X86_64 set_cpu_cap(c, X86_FEATURE_SYSENTER32); #endif @@ -145,9 +141,8 @@ static void init_centaur(struct cpuinfo_x86 *c) set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON); } - switch (c->x86) { #ifdef CONFIG_X86_32 - case 5: + if (c->x86 == 5) { switch (c->x86_model) { case 4: name = "C6"; @@ -207,12 +202,10 @@ static void init_centaur(struct cpuinfo_x86 *c) c->x86_cache_size = (cc>>24)+(dd>>24); } sprintf(c->x86_model_id, "WinChip %s", name); - break; + } #endif - case 6: + if (c->x86 == 6) init_c3(c); - break; - } #ifdef CONFIG_X86_64 set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); #endif -- 2.7.4