Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Remove "weak" from get_c0_compare_int() declaration

Weak header file declarations are error-prone because they make every
definition weak, and the linker chooses one based on link order (see
10629d711ed7 ("PCI: Remove __weak annotation from pcibios_get_phb_of_node
decl")).

get_c0_compare_int() is defined in several files. Each definition is weak,
so I assume Kconfig prevents two or more from being included. The caller
contains default code used when get_c0_compare_int() isn't defined at all.

Add a weak get_c0_compare_int() definition with the default code and remove
the weak annotation from the declaration.

Then the platform implementations will be strong and will override the weak
default. If multiple platforms are ever configured in, we'll get a link
error instead of calling a random platform's implementation.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10686/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Bjorn Helgaas and committed by
Ralf Baechle
ec0b9d35 c60f9944

+8 -5
+1 -1
arch/mips/include/asm/time.h
··· 51 51 /* 52 52 * Initialize the calling CPU's compare interrupt as clockevent device 53 53 */ 54 - extern unsigned int __weak get_c0_compare_int(void); 54 + extern unsigned int get_c0_compare_int(void); 55 55 extern int r4k_clockevent_init(void); 56 56 57 57 static inline int mips_clockevent_init(void)
+7 -4
arch/mips/kernel/cevt-r4k.c
··· 174 174 return 1; 175 175 } 176 176 177 + unsigned int __weak get_c0_compare_int(void) 178 + { 179 + return MIPS_CPU_IRQ_BASE + cp0_compare_irq; 180 + } 181 + 177 182 int r4k_clockevent_init(void) 178 183 { 179 184 unsigned int cpu = smp_processor_id(); ··· 194 189 /* 195 190 * With vectored interrupts things are getting platform specific. 196 191 * get_c0_compare_int is a hook to allow a platform to return the 197 - * interrupt number of it's liking. 192 + * interrupt number of its liking. 198 193 */ 199 - irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq; 200 - if (get_c0_compare_int) 201 - irq = get_c0_compare_int(); 194 + irq = get_c0_compare_int(); 202 195 203 196 cd = &per_cpu(mips_clockevent_device, cpu); 204 197