aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo A. R. Silva2018-02-13 13:22:08 -0600
committerGreg Kroah-Hartman2018-02-22 08:44:59 -0600
commitff891875c1a079c55cb5def525c2448c4cbed98c (patch)
tree7c337ae580cd3a2d9d1d1675726fa3870dff58d5
parentc63497edc3aa9b7e22dc2aa012d26ec4770b8f2d (diff)
downloadkernel-omap-ff891875c1a079c55cb5def525c2448c4cbed98c.tar.gz
kernel-omap-ff891875c1a079c55cb5def525c2448c4cbed98c.tar.xz
kernel-omap-ff891875c1a079c55cb5def525c2448c4cbed98c.zip
x86/cpu: Change type of x86_cache_size variable to unsigned int
commit 24dbc6000f4b9b0ef5a9daecb161f1907733765a upstream. Currently, x86_cache_size is of type int, which makes no sense as we will never have a valid cache size equal or less than 0. So instead of initializing this variable to -1, it can perfectly be initialized to 0 and use it as an unsigned variable instead. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Addresses-Coverity-ID: 1464429 Link: http://lkml.kernel.org/r/20180213192208.GA26414@embeddedor.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/microcode/intel.c2
-rw-r--r--arch/x86/kernel/cpu/proc.c4
4 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 86bccb4bd4dc..9e77cea2a8ef 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -113,7 +113,7 @@ struct cpuinfo_x86 {
113 char x86_vendor_id[16]; 113 char x86_vendor_id[16];
114 char x86_model_id[64]; 114 char x86_model_id[64];
115 /* in KB - valid for CPUS which support this call: */ 115 /* in KB - valid for CPUS which support this call: */
116 int x86_cache_size; 116 unsigned int x86_cache_size;
117 int x86_cache_alignment; /* In bytes */ 117 int x86_cache_alignment; /* In bytes */
118 /* Cache QoS architectural values: */ 118 /* Cache QoS architectural values: */
119 int x86_cache_max_rmid; /* max index */ 119 int x86_cache_max_rmid; /* max index */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f7f2ad3687ee..8eabbafff213 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -955,7 +955,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
955 int i; 955 int i;
956 956
957 c->loops_per_jiffy = loops_per_jiffy; 957 c->loops_per_jiffy = loops_per_jiffy;
958 c->x86_cache_size = -1; 958 c->x86_cache_size = 0;
959 c->x86_vendor = X86_VENDOR_UNKNOWN; 959 c->x86_vendor = X86_VENDOR_UNKNOWN;
960 c->x86_model = c->x86_mask = 0; /* So far unknown... */ 960 c->x86_model = c->x86_mask = 0; /* So far unknown... */
961 c->x86_vendor_id[0] = '\0'; /* Unset */ 961 c->x86_vendor_id[0] = '\0'; /* Unset */
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 2c76a1801393..2f38a99cdb98 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -1075,7 +1075,7 @@ static struct microcode_ops microcode_intel_ops = {
1075 1075
1076static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c) 1076static int __init calc_llc_size_per_core(struct cpuinfo_x86 *c)
1077{ 1077{
1078 u64 llc_size = c->x86_cache_size * 1024; 1078 u64 llc_size = c->x86_cache_size * 1024ULL;
1079 1079
1080 do_div(llc_size, c->x86_max_cores); 1080 do_div(llc_size, c->x86_max_cores);
1081 1081
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 18ca99f2798b..935225c0375f 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -87,8 +87,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
87 } 87 }
88 88
89 /* Cache size */ 89 /* Cache size */
90 if (c->x86_cache_size >= 0) 90 if (c->x86_cache_size)
91 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); 91 seq_printf(m, "cache size\t: %u KB\n", c->x86_cache_size);
92 92
93 show_cpuinfo_core(m, c, cpu); 93 show_cpuinfo_core(m, c, cpu);
94 show_cpuinfo_misc(m, c); 94 show_cpuinfo_misc(m, c);