x86: cpu: use printk_once
PATCH 1/1 x86: cpu: use printk_once
From: Davidlohr Bueso <[email protected]>
Use printk_once() instead of extra variables.
Signed-off-by Davidlohr Bueso <[email protected]>
--- arch/x86/kernel/cpu/common.c | 12 +++++------- arch/x86/kernel/cpu/topology.c | 12 +++--------- 2 files changed, 8 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/common.c +5 -7
@@ -457,7 +457,6 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)#ifdef CONFIG_X86_HT u32 eax, ebx, ecx, edx;int index_msb, core_bits; -static bool printed;if (!cpu_has (c,X86_FEATURE_HT ))return ;
@@ -493,12 +492,11 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) ((1 << core_bits) -1 ); out: -if (!printed && (c->x86_max_cores * smp_num_siblings) >1 ) { -printk (KERN_INFO "CPU: Physical Processor ID: %d\n" , - c->phys_proc_id); -printk (KERN_INFO "CPU: Processor Core ID: %d\n" , - c->cpu_core_id); - printed =1 ; +if ((c->x86_max_cores * smp_num_siblings) >1 ) { +printk_once (KERN_INFO "CPU: Physical Processor ID: %d\n" , + c->phys_proc_id); +printk_once (KERN_INFO "CPU: Processor Core ID: %d\n" , + c->cpu_core_id); }#endif }
arch/x86/kernel/cpu/topology.c +3 -9
@@ -32,7 +32,6 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)unsigned int eax, ebx, ecx, edx, sub_index;unsigned int ht_mask_width, core_plus_mask_width;unsigned int core_select_mask, core_level_siblings; -static bool printed;if (c->cpuid_level <0xb )return ;
@@ -86,14 +85,9 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) c->x86_max_cores = (core_level_siblings / smp_num_siblings); -if (!printed) { -printk (KERN_INFO "CPU: Physical Processor ID: %d\n" , - c->phys_proc_id); -if (c->x86_max_cores >1 ) -printk (KERN_INFO "CPU: Processor Core ID: %d\n" , - c->cpu_core_id); - printed =1 ; - } +printk_once (KERN_INFO "CPU: Physical Processor ID: %d\n" , c->phys_proc_id); +if (c->x86_max_cores >1 ) +printk_once (KERN_INFO "CPU: Processor Core ID: %d\n" , c->cpu_core_id);return ;#endif }
Signature · 1 line
1.7.4.1
Quoted 1 line · Davidlohr Bueso
Use
printk_once()instead of extra variables.
This is _very_ slightly larger.
The only thing I'd change is to use true instead of 1; Well, I might use pr_info too...
arch/x86/kernel/cpu/common.c
Quoted 1 line
arch/x86/kernel/cpu/common.c +0
-0
[]
Quoted 56 lines
arch/x86/kernel/cpu/common.c +5
-7@@ -457,7 +457,6 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)#ifdef CONFIG_X86_HT u32 eax, ebx, ecx, edx;int index_msb, core_bits; -static bool printed;if (!cpu_has (c,X86_FEATURE_HT ))return ;@@ -493,12 +492,11 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c) ((1 << core_bits) -1 ); out: -if (!printed && (c->x86_max_cores * smp_num_siblings) >1 ) { -printk (KERN_INFO "CPU: Physical Processor ID: %d\n" , - c->phys_proc_id); -printk (KERN_INFO "CPU: Processor Core ID: %d\n" , - c->cpu_core_id); - printed =1 ; +if ((c->x86_max_cores * smp_num_siblings) >1 ) { +printk_once (KERN_INFO "CPU: Physical Processor ID: %d\n" , + c->phys_proc_id); +printk_once (KERN_INFO "CPU: Processor Core ID: %d\n" , + c->cpu_core_id); }#endif }arch/x86/kernel/cpu/topology.c +3
-9@@ -32,7 +32,6 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)unsigned int eax, ebx, ecx, edx, sub_index;unsigned int ht_mask_width, core_plus_mask_width;unsigned int core_select_mask, core_level_siblings; -static bool printed;if (c->cpuid_level <0xb )return ;@@ -86,14 +85,9 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) c->x86_max_cores = (core_level_siblings / smp_num_siblings); -if (!printed) { -printk (KERN_INFO "CPU: Physical Processor ID: %d\n" , - c->phys_proc_id); -if (c->x86_max_cores >1 ) -printk (KERN_INFO "CPU: Processor Core ID: %d\n" , - c->cpu_core_id); - printed =1 ; - } +printk_once (KERN_INFO "CPU: Physical Processor ID: %d\n" , c->phys_proc_id); +if (c->x86_max_cores >1 ) +printk_once (KERN_INFO "CPU: Processor Core ID: %d\n" , c->cpu_core_id);return ;#endif }