Commit e52163df authored by Hardevsinh Palaniya's avatar Hardevsinh Palaniya Committed by Will Deacon
Browse files

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: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: default avatarHardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Link: https://lore.kernel.org/r/20241115053740.20523-1-hardevsinh.palaniya@siliconsignals.io


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 264a593d
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -1004,12 +1004,11 @@ 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,