Skip to content

Commit

Permalink
ARM: 7029/1: Make cpu_architecture into a global variable
Browse files Browse the repository at this point in the history
The CPU architecture really should not be changing at runtime, so
make it a global variable instead of a function.

The cpu_architecture() function declared in <asm/system.h> remains
the correct way to read this variable from C code.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Reviewed-by: Jon Medhurst <tixy@yxit.co.uk>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Dave Martin authored and Russell King committed Oct 17, 2011
1 parent 40c6d8a commit 2ecccf9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion arch/arm/include/asm/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

#ifndef __ASSEMBLY__

#include <linux/compiler.h>
#include <linux/linkage.h>
#include <linux/irqflags.h>

Expand Down Expand Up @@ -104,7 +105,7 @@ struct mm_struct;
extern void show_pte(struct mm_struct *mm, unsigned long addr);
extern void __show_regs(struct pt_regs *);

extern int cpu_architecture(void);
extern int __pure cpu_architecture(void);
extern void cpu_init(void);

void arm_machine_restart(char mode, const char *cmd);
Expand Down
20 changes: 19 additions & 1 deletion arch/arm/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/memblock.h>
#include <linux/bug.h>
#include <linux/compiler.h>

#include <asm/unified.h>
#include <asm/cpu.h>
Expand All @@ -42,6 +44,7 @@
#include <asm/cacheflush.h>
#include <asm/cachetype.h>
#include <asm/tlbflush.h>
#include <asm/system.h>

#include <asm/prom.h>
#include <asm/mach/arch.h>
Expand Down Expand Up @@ -115,6 +118,13 @@ struct outer_cache_fns outer_cache __read_mostly;
EXPORT_SYMBOL(outer_cache);
#endif

/*
* Cached cpu_architecture() result for use by assembler code.
* C code should use the cpu_architecture() function instead of accessing this
* variable directly.
*/
int __cpu_architecture __read_mostly = CPU_ARCH_UNKNOWN;

struct stack {
u32 irq[3];
u32 abt[3];
Expand Down Expand Up @@ -210,7 +220,7 @@ static const char *proc_arch[] = {
"?(17)",
};

int cpu_architecture(void)
static int __get_cpu_architecture(void)
{
int cpu_arch;

Expand Down Expand Up @@ -243,6 +253,13 @@ int cpu_architecture(void)
return cpu_arch;
}

int __pure cpu_architecture(void)
{
BUG_ON(__cpu_architecture == CPU_ARCH_UNKNOWN);

return __cpu_architecture;
}

static int cpu_has_aliasing_icache(unsigned int arch)
{
int aliasing_icache;
Expand Down Expand Up @@ -414,6 +431,7 @@ static void __init setup_processor(void)
}

cpu_name = list->cpu_name;
__cpu_architecture = __get_cpu_architecture();

#ifdef MULTI_CPU
processor = *list->proc;
Expand Down

0 comments on commit 2ecccf9

Please sign in to comment.