Restrict definitions of a couple of static functions
PATCH 1/1 Restrict definitions of a couple of static functions
The call sites of the static functions free_cache_attributes() and detect_cache_attributes() in arch/x86/kernel/cpu/intel_cacheinfo.c are placed under #ifdef CONFIG_SYSFS/#endif, but their definitions are not. This may produce the following warning:
arch/x86/kernel/cpu/intel_cacheinfo.c:542: warning:
'free_cache_attributes' defined but not used arch/x86/kernel/cpu/intel_cacheinfo.c:573: warning:
'detect_cache_attributes' defined but not used
This patch fixes the warning by restricting the definitions of the two functions to the case when CONFIG_SYSFS is enabled.
--- arch/x86/kernel/cpu/intel_cacheinfo.c | 64 ++++++++++++++++---------------- 1 files changed, 32 insertions(+), 32 deletions(-)
arch/x86/kernel/cpu/intel_cacheinfo.c +32 -32
@@ -538,17 +538,6 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) {}static void __cpuinit cache_remove_shared_cpu_map (unsigned int cpu,int index) {}#endif -static void __cpuinit free_cache_attributes (unsigned int cpu) -{ -int i; - -for (i =0 ; i < num_cache_leaves; i++) -cache_remove_shared_cpu_map (cpu, i); - -kfree (per_cpu (cpuid4_info, cpu)); -per_cpu (cpuid4_info, cpu) =NULL ; -} -static void __cpuinit get_cpu_leaves (void *_retval) {int j, *retval = _retval, cpu =smp_processor_id ();
@@ -569,27 +558,6 @@ static void __cpuinit get_cpu_leaves(void *_retval) } } -static int __cpuinit detect_cache_attributes (unsigned int cpu) -{ -int retval; - -if (num_cache_leaves ==0 ) -return -ENOENT ; - -per_cpu (cpuid4_info, cpu) =kzalloc ( -sizeof (struct _cpuid4_info ) * num_cache_leaves,GFP_KERNEL ); -if (per_cpu (cpuid4_info, cpu) ==NULL ) -return -ENOMEM ; - -smp_call_function_single (cpu, get_cpu_leaves, &retval, true); -if (retval) { -kfree (per_cpu (cpuid4_info, cpu)); -per_cpu (cpuid4_info, cpu) =NULL ; - } - -return retval; -} -#ifdef CONFIG_SYSFS #include <linux/kobject.h>
@@ -840,6 +808,38 @@ static struct kobj_type ktype_percpu_entry = { .sysfs_ops = &sysfs_ops, }; +static void __cpuinit free_cache_attributes (unsigned int cpu) +{ +int i; + +for (i =0 ; i < num_cache_leaves; i++) +cache_remove_shared_cpu_map (cpu, i); + +kfree (per_cpu (cpuid4_info, cpu)); +per_cpu (cpuid4_info, cpu) =NULL ; +} + +static int __cpuinit detect_cache_attributes (unsigned int cpu) +{ +int retval; + +if (num_cache_leaves ==0 ) +return -ENOENT ; + +per_cpu (cpuid4_info, cpu) =kzalloc ( +sizeof (struct _cpuid4_info ) * num_cache_leaves,GFP_KERNEL ); +if (per_cpu (cpuid4_info, cpu) ==NULL ) +return -ENOMEM ; + +smp_call_function_single (cpu, get_cpu_leaves, &retval, true); +if (retval) { +kfree (per_cpu (cpuid4_info, cpu)); +per_cpu (cpuid4_info, cpu) =NULL ; + } + +return retval; +} +static void __cpuinit cpuid4_cache_sysfs_exit (unsigned int cpu) {kfree (per_cpu (cache_kobject, cpu));
Signature · 1 line
1.5.6.3
Quoted 10 lines · Dmitri Vorobiev
The call sites of the static functions
free_cache_attributes()anddetect_cache_attributes()inarch/x86/kernel/cpu/intel_cacheinfo.care placed under #ifdef CONFIG_SYSFS/#endif, but their definitions are not. This may produce the following warning:
arch/x86/kernel/cpu/intel_cacheinfo.c:542: warning:
'free_cache_attributes' defined but not usedarch/x86/kernel/cpu/intel_cacheinfo.c:573: warning:
'detect_cache_attributes' defined but not used
Quoted 7 lines
This patch fixes the warning by restricting the definitions of the two functions to the case when
CONFIG_SYSFSis enabled.Signed-off-by Dmitri Vorobiev <[email protected]>--- arch/x86/kernel/cpu/intel_cacheinfo.c | 64 ++++++++++++++++---------------- 1 files changed, 32 insertions(+), 32 deletions(-)
does not apply to the latest x86 tree anymore:
http://people.redhat.com/mingo/tip.git/README
2 out of 3 hunks FAILED -- rejects in file arch/x86/kernel/cpu/intel_cacheinfo.c
Ingo