From patchwork Thu Nov 14 14:22:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hardevsinh Palaniya X-Patchwork-Id: 13875161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10F70D68B28 for ; Thu, 14 Nov 2024 14:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=MIkk/ugghnBw6fYu2dCC8sqJ6JiQClGOjOXMCnI8Iuk=; b=4GVNEBtir3KwIsMdHCYJfXwvI5 5JjF4WGPJisBxrEeF3uQjkQZwiKvQ3Gw+s+8KbHf+2p4ISUe3lYGzFKj3/WbXkdFKnbLs1h9PNA3/ xv8uBQg3z+de4NVXiqMikfkSNSlpnfXxwXAtrfH4ftjmZTf9u3rxgNUtobzA38bQKVF23q4zjfcqh HIFhuutm0vCk3gqXDBbtU23Irpl56BIYNQ4/iwzySoCBTXzeN2KGmkjC7KVz0ocqFds/xLsJl19li U9i5EgEPXOM4JRmn4lKslWBc68rAsGRKs2eNMsypjE3Y5WD1AF971JtmWaDeolxItXngmLpi6r2vx xvFK9iiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tBana-0000000ACNs-2Nqr; Thu, 14 Nov 2024 14:26:18 +0000 Received: from mail-centralindiaazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c408::1] helo=PNYPR01CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tBalm-0000000AC8h-1K8k for linux-arm-kernel@lists.infradead.org; Thu, 14 Nov 2024 14:24:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6YWiusBt2ELW3LVrHXf2PM0hQGQKv24B9zi8S4diqvOF0LlkPBRK3WWQruO7I0Y1siSQycEmbOuLML4OyssvLfIG5G6rhJCBKo+Re87Ri+lAWhR5M2qUU4Q3ZeZ5fvD24ZLpRNJye8daxIq7J2vwF4betgQJPNxzS89sZt8Y0RqROZ8qGsx7bbmY8l1toZITXApjYy8ycvZ32WyYHKn817bDbKuF+ZT4r6cGwwQiZfxAVOU72lFh9pr9edppVANZJq12PFkDPTDdmmsDpAQN9OjEwnCFT+853Km7tbZXflpADWiGnWGMou+8LYvrqmDtPXfyfAnPXHI8G5RCNSbCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MIkk/ugghnBw6fYu2dCC8sqJ6JiQClGOjOXMCnI8Iuk=; b=U6SjJGQFjg0S0xtADK7K9eArsTBAm9lM1Pzc6sUMzfVUX9tB6zjgScKKFKfZIk7EFm0OD+F5V6ZZXeCz/8n170WVrdC2++9d5jVSljoS4kN0XsuTdjDGJGUFUovyhoRCJCwyFG9g+iZ6DOReSlQ95/ippcmuqHY5EzX433tf8qyBDVbjXV9WczCq3DuAj8BEBFRlCE7J+A0867wuOl193d4GE1KvNLUbme06flIWcVM0k/wJoEfbzyrvsRH1SHrnconembTZbpdkRDrPvVUg9yXmv9StPIlUXqygOvwEdr8v72CSqYO9ZV5uB2ToM363GLS4Gmph/jLs0FvFKpoSMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siliconsignals.io; dmarc=pass action=none header.from=siliconsignals.io; dkim=pass header.d=siliconsignals.io; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siliconsignals.io; Received: from PN0P287MB2843.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:204::8) by PN0P287MB1374.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:189::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Thu, 14 Nov 2024 14:24:00 +0000 Received: from PN0P287MB2843.INDP287.PROD.OUTLOOK.COM ([fe80::1134:92d7:1f68:2fac]) by PN0P287MB2843.INDP287.PROD.OUTLOOK.COM ([fe80::1134:92d7:1f68:2fac%3]) with mapi id 15.20.8158.017; Thu, 14 Nov 2024 14:24:00 +0000 From: Hardevsinh Palaniya To: will@kernel.org, broonie@kernel.org Cc: Hardevsinh Palaniya , Catalin Marinas , Oliver Upton , Marc Zyngier , Ard Biesheuvel , Mark Rutland , Joey Gouly , Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] arm64: Refactor conditional logic Date: Thu, 14 Nov 2024 19:52:30 +0530 Message-ID: <20241114142333.18210-1-hardevsinh.palaniya@siliconsignals.io> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: PN3PR01CA0080.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:9a::22) To PN0P287MB2843.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:204::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN0P287MB2843:EE_|PN0P287MB1374:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a4d9809-b38c-4119-cddf-08dd04b7fb49 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|38350700014; X-Microsoft-Antispam-Message-Info: jkWiBGgkLvEFtdwCnLpZQ1FhjdWJdETc3bZq+rQ1djJXW2HQXszRv3uzjT01jGpw3ooQdvh+a1C0uYZ0bRIi6vND+XY/820EvcAR7nG2YNK9F9Vx8hFg/S0pQ9xUTM9TuFtrFmN4PwU0TCB4eBM4gAx59oGWW1q6MRTwd7TL8oxM4ok1gMuiPW0Pcg+r1Gbe6a8mjeGM0l8v/cud2WLI1yS7hI2P9ZiGxolai/dPZg+8nsvpHoCOqhl86unvWzhnEzGmhty72Q5AGtoYX1iiI6R9GCA+9yabC7nqej+GlF1+sMrDLLXicjBj5GrMVSs0oJgrNHjkIfodfpP7+em+svhfRy+McJp6RrakBueOtVPB1BYZPTV13jRCrPAgmcs0Kavnv5WgmaGQ7iMCVA45yAeGXu1C76k/Kefe4V84m6AvIuWOde3M1Xrb0Fo0DKfhegoaWOjE4haLIX/1p75iAGnNERAzzeSckbTIIDJjqRKMe8gkpRkG0qck2iyBXT7IxwcFmKxqETtM4PhMc/1BFvkQKO9K1FGZ9yL0dAGvbHLrUBg5/RB9poidmawnmnPoa5EZtM+SgDr54kQ+RlqxYblY1huK62ejsxsyX4gdFCdGU86ydHYeBRW8ZEkBdn9GISXgIKQWXVkSoqW6gllV0DB6wEO2Y9K14dUfyshVHzczghkcfpDORJixPcvipoWzXP/iPuS8e94UrVq2N5iVcKenhG2AoERI/Zm8z2iZyAP5RYnB/L8RmbkwdxdsjKVhlVTfd7gmAODyZkypj0FxNJCOipYJuelGvomZGgYcUNmkT/OIi1Mb+jJ2CdlKN3FC3rSRYd4v4mhKMHZJWmbpKmxEIABYxCIcUnJHe9CGYLYfowPr0ZfBp0LvJYkGW35vrN92f2AK92Tra93LQJ34VYEWDP7SG0CKP1ZQpWN2NiMnm0xRIlaPDFZWPLswY7MK0wEZg1MuQY5QV35ioSvQHqTpfltgDFrOGLwYU4yQKUog5+ObHYEWI55W6eOxQl4KVRsXf2x3Bag55tEyqaFEMc6UhKg1J3BdCoGdlEOG1p0N2tQAXfJ5GxFXmsQGsMG21VdrEL7vGHtuS2FvrccAOtmSf/3NoCfjHwIOhu5a4cUJZlVD69BzNzst3Vf97H4OGoqxKUNL5sAHp+L2K7xpv4c/lWaU7D1F4PJ7IziCP5gdaWUbpupWREjQjzkzz4Tm/fyJqh6k+OCQdFpQgK+bzYSoXQBuXFfm1hKfNylDWq0q9pPxENFn0IC/1QsLBuVI6ZE2p2baJtlJHU1ObyGDE2/GDJm/ROB6KLIjO/q0A9BWQ0/lfMAUShY8AA9Shel4rqB3kATwxuncVplTDLZ+Qlf9Y8i5hVaHcBCrVXcYKE8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN0P287MB2843.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X3iPXOmHvxR2f429cVS2iiAGcHDBSGSpDOM0zAOJ2e7i/J2wVLlxm9vANajwMXIoB7bf5DwXPXIJ66LFOe09DASKYo+h33SjzeSnG8fWwit8J84ou4MbWZuKtG5dAYPHHesJaWlex8Sv6d0u1kExMH+pcGYjqNrMNAhKvSG95gtS33WB0eDUAYD5Ed2KVttG7uS5rnBwuldiTdeeaqX6SFwTwIqb7InnffeXi5eINcGvd5929rdEgvmJXo33m7F6ltSJlhEETTQEPqlEh/5HhiuLbVEoTPEV2IwYV/ln1uvNUQQqcaRD9ljlnaG/XpREQmS3XJnGFUoZmQ0oWVcQUa5AJUzQpFB2ZwHTu9hHBlQUoAzhrR6yq/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/T9SB6SO67EQPxqKIGFsXSoNB72LivQ1gERydhPBP1qxaAKkSdErQ2HXN/Iy6dNMAMyWHKi93Y3Ldp/r0DVtmKB0NC0GLvSrGu7gsDIH/YM6ULILwLIvsPLZkeFeURCnTSTAF/Dpy9Pqe24cg5vBUXEkcoGv19vpwPcjefh+Ht8Qn5fsEdZXRDEikestPpP2fgQLQHDyq4lngS X-OriginatorOrg: siliconsignals.io X-MS-Exchange-CrossTenant-Network-Message-Id: 8a4d9809-b38c-4119-cddf-08dd04b7fb49 X-MS-Exchange-CrossTenant-AuthSource: PN0P287MB2843.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 14:23:59.9564 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7ec5089e-a433-4bd1-a638-82ee62e21d37 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NgCmjB1svzW8Gn3zcSj5bd6isNIjJ57itBY2vK42Vk1wvcbm3HLQ9IsH0Aj8UoIHtYC1RN5lvvzszZH42RRvLIZvRuO1DuIFKJKZ5at1x1vC7j0Tz/MLkebLxyil73Uf X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN0P287MB1374 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241114_062426_364274_51A1C94E X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Unnecessarily checks ftr_ovr == tmp in an extra else if, which is not needed because that condition would already be true by default if the previous conditions are not satisfied. if (ftr_ovr != tmp) { } else if (ftr_new != tmp) { } else if (ftr_ovr == tmp) { Logic: The first and last conditions are inverses of each other, so the last condition must be true if the first two conditions are false. Additionally, all branches set the variable str, making the subsequent "if (str)" check redundant Reviewed-by: Mark Brown Signed-off-by: Hardevsinh Palaniya --- Changelog in V2: - remove str check Change in V3: - Add logic in commit msg - Add review tag --- arch/arm64/kernel/cpufeature.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 718728a85430..728709483fb7 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -989,17 +989,16 @@ static void init_cpu_ftr_reg(u32 sys_reg, u64 new) /* Override was valid */ ftr_new = tmp; str = "forced"; - } else if (ftr_ovr == tmp) { + } else { /* Override was the safe value */ str = "already set"; } - if (str) - pr_warn("%s[%d:%d]: %s to %llx\n", - reg->name, - ftrp->shift + ftrp->width - 1, - ftrp->shift, str, - tmp & (BIT(ftrp->width) - 1)); + pr_warn("%s[%d:%d]: %s to %llx\n", + reg->name, + ftrp->shift + ftrp->width - 1, + ftrp->shift, str, + tmp & (BIT(ftrp->width) - 1)); } else if ((ftr_mask & reg->override->val) == ftr_mask) { reg->override->val &= ~ftr_mask; pr_warn("%s[%d:%d]: impossible override, ignored\n",