ARM: add PROC_VTABLE macros
authorRussell King <rmk+kernel@armlinux.org.uk>
Fri, 20 Jul 2018 09:46:52 +0000 (10:46 +0100)
committerDouglas RAILLARD <douglas.raillard@arm.com>
Tue, 14 Aug 2018 15:32:13 +0000 (16:32 +0100)
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/include/asm/proc-fns.h
arch/arm/kernel/setup.c

index e25f4392e1b2868446de858701d408aaaee26eab..4fd67e9e6003756a27ebbe6153dde008e70fb6e5 100644 (file)
@@ -23,7 +23,7 @@ struct mm_struct;
 /*
  * Don't change this structure - ASM code relies on it.
  */
-extern struct processor {
+struct processor {
        /* MISC
         * get data abort address/flags
         */
@@ -79,9 +79,13 @@ extern struct processor {
        unsigned int suspend_size;
        void (*do_suspend)(void *);
        void (*do_resume)(void *);
-} processor;
+};
 
 #ifndef MULTI_CPU
+static inline void init_proc_vtable(const struct processor *p)
+{
+}
+
 extern void cpu_proc_init(void);
 extern void cpu_proc_fin(void);
 extern int cpu_do_idle(void);
@@ -98,17 +102,25 @@ extern void cpu_reset(unsigned long addr, bool hvc) __attribute__((noreturn));
 extern void cpu_do_suspend(void *);
 extern void cpu_do_resume(void *);
 #else
-#define cpu_proc_init                  processor._proc_init
-#define cpu_proc_fin                   processor._proc_fin
-#define cpu_reset                      processor.reset
-#define cpu_do_idle                    processor._do_idle
-#define cpu_dcache_clean_area          processor.dcache_clean_area
-#define cpu_set_pte_ext                        processor.set_pte_ext
-#define cpu_do_switch_mm               processor.switch_mm
+
+extern struct processor processor;
+#define PROC_VTABLE_FUNC(f)            processor.f
+static inline void init_proc_vtable(const struct processor *p)
+{
+       processor = *p;
+}
+
+#define cpu_proc_init                  PROC_VTABLE_FUNC(_proc_init)
+#define cpu_proc_fin                   PROC_VTABLE_FUNC(_proc_fin)
+#define cpu_reset                      PROC_VTABLE_FUNC(reset)
+#define cpu_do_idle                    PROC_VTABLE_FUNC(_do_idle)
+#define cpu_dcache_clean_area          PROC_VTABLE_FUNC(dcache_clean_area)
+#define cpu_set_pte_ext                        PROC_VTABLE_FUNC(set_pte_ext)
+#define cpu_do_switch_mm               PROC_VTABLE_FUNC(switch_mm)
 
 /* These three are private to arch/arm/kernel/suspend.c */
-#define cpu_do_suspend                 processor.do_suspend
-#define cpu_do_resume                  processor.do_resume
+#define cpu_do_suspend                 PROC_VTABLE_FUNC(do_suspend)
+#define cpu_do_resume                  PROC_VTABLE_FUNC(do_resume)
 #endif
 
 extern void cpu_resume(void);
index 35ca494c028cc841e1077bf59428b11d9d817fbb..161398b0242294f711d4f9c35f771e0dc345488b 100644 (file)
@@ -686,9 +686,7 @@ static void __init setup_processor(void)
        cpu_name = list->cpu_name;
        __cpu_architecture = __get_cpu_architecture();
 
-#ifdef MULTI_CPU
-       processor = *list->proc;
-#endif
+       init_proc_vtable(list->proc);
 #ifdef MULTI_TLB
        cpu_tlb = *list->tlb;
 #endif