]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm64/cpufeature: Refactor conditional logic in init_cpu_ftr_reg()
authorHardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Fri, 15 Nov 2024 05:36:35 +0000 (11:06 +0530)
committerWill Deacon <will@kernel.org>
Tue, 10 Dec 2024 12:16:19 +0000 (12:16 +0000)
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 <broonie@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Link: https://lore.kernel.org/r/20241115053740.20523-1-hardevsinh.palaniya@siliconsignals.io
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/cpufeature.c

index 6ce71f444ed84f9056196bb21bbfac61c9687e30..7c5b53f179a42666d4326c441b23a5b4106b4347 100644 (file)
@@ -1004,17 +1004,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",