Skip to contentSkip to conversation

x86, CPU, AMD: Fix a shadowed variable situation

PATCH New Borislav Petkov 2 participants 2 messages Jan 15, 2014 x86

lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/1 x86, CPU, AMD: Fix a shadowed variable situation

From: Borislav Petkov <[email protected]>

Having u32 and struct cpuinfo_x86 * by the same name is not very smart, although it was ok in this case due to the limited scope of u32 c and it being used only once in there.

Fix this.

---
 arch/x86/kernel/cpu/amd.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/amd.c +3 -7
index 6ac3a67ad471..d3153e281d72 100644
@@ -799,14 +799,10 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
 	}
 
 	/* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */
-	if (!((eax >> 16) & mask)) {
-		u32 a, b, c, d;
-
-		cpuid(0x80000005, &a, &b, &c, &d);
-		tlb_lld_2m[ENTRIES] = (a >> 16) & 0xff;
-	} else {
+	if (!((eax >> 16) & mask))
+		tlb_lld_2m[ENTRIES] = (cpuid_eax(0x80000005) >> 16) & 0xff;
+	else
 		tlb_lld_2m[ENTRIES] = (eax >> 16) & mask;
-	}
 
 	/* a 4M entry uses two 2M entries */
 	tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1;
Signature · 1 line
1.8.5.2.192.g7794a68
#1 lore raw

[tip:x86/cleanups] x86, cpu, amd: Fix a shadowed variable situation

x86, cpu, amd: Fix a shadowed variable situation
Commit-ID:  d139336700a5f3a560da235e4dfcd286773025d4
Gitweb:     http://git.kernel.org/tip/d139336700a5f3a560da235e4dfcd286773025d4
Author:     Borislav Petkov <[email protected]>
AuthorDate: Wed, 15 Jan 2014 12:52:15 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Wed, 15 Jan 2014 04:21:45 -0800

x86, cpu, amd: Fix a shadowed variable situation

Having u32 and struct cpuinfo_x86 * by the same name is not very smart, although it was ok in this case due to the limited scope of u32 c and it being used only once in there.

Fix this.

---
 arch/x86/kernel/cpu/amd.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/amd.c +3 -7
index 39bc78d..e5647ab 100644
@@ -789,14 +789,10 @@ static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
 	}
 
 	/* Handle DTLB 2M and 4M sizes, fall back to L1 if L2 is disabled */
-	if (!((eax >> 16) & mask)) {
-		u32 a, b, c, d;
-
-		cpuid(0x80000005, &a, &b, &c, &d);
-		tlb_lld_2m[ENTRIES] = (a >> 16) & 0xff;
-	} else {
+	if (!((eax >> 16) & mask))
+		tlb_lld_2m[ENTRIES] = (cpuid_eax(0x80000005) >> 16) & 0xff;
+	else
 		tlb_lld_2m[ENTRIES] = (eax >> 16) & mask;
-	}
 
 	/* a 4M entry uses two 2M entries */
 	tlb_lld_4m[ENTRIES] = tlb_lld_2m[ENTRIES] >> 1;