Skip to content

Commit e52163d

Browse files
hardevsinh-1willdeacon
authored andcommitted
arm64/cpufeature: Refactor conditional logic in init_cpu_ftr_reg()
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 <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Signed-off-by: Hardevsinh Palaniya <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 264a593 commit e52163d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,17 +1004,16 @@ static void init_cpu_ftr_reg(u32 sys_reg, u64 new)
10041004
/* Override was valid */
10051005
ftr_new = tmp;
10061006
str = "forced";
1007-
} else if (ftr_ovr == tmp) {
1007+
} else {
10081008
/* Override was the safe value */
10091009
str = "already set";
10101010
}
10111011

1012-
if (str)
1013-
pr_warn("%s[%d:%d]: %s to %llx\n",
1014-
reg->name,
1015-
ftrp->shift + ftrp->width - 1,
1016-
ftrp->shift, str,
1017-
tmp & (BIT(ftrp->width) - 1));
1012+
pr_warn("%s[%d:%d]: %s to %llx\n",
1013+
reg->name,
1014+
ftrp->shift + ftrp->width - 1,
1015+
ftrp->shift, str,
1016+
tmp & (BIT(ftrp->width) - 1));
10181017
} else if ((ftr_mask & reg->override->val) == ftr_mask) {
10191018
reg->override->val &= ~ftr_mask;
10201019
pr_warn("%s[%d:%d]: impossible override, ignored\n",

0 commit comments

Comments
 (0)