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_fdc_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")).

The most elegant solution is to have a weak default implementation and
allow a strong function to override it. Then we don't have to test
whether a definition is present, and if there are ever multiple strong
definitions, we get a link error instead of calling a random definition.

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

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/10687/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Bjorn Helgaas and committed by
Ralf Baechle
770847ba ec0b9d35

+7 -4
+1 -1
arch/mips/include/asm/irq.h
··· 49 49 extern int cp0_perfcount_irq; 50 50 extern int cp0_fdc_irq; 51 51 52 - extern int __weak get_c0_fdc_int(void); 52 + extern int get_c0_fdc_int(void); 53 53 54 54 void arch_trigger_all_cpu_backtrace(bool); 55 55 #define arch_trigger_all_cpu_backtrace arch_trigger_all_cpu_backtrace
+6 -3
drivers/tty/mips_ejtag_fdc.c
··· 879 879 .chars_in_buffer = mips_ejtag_fdc_tty_chars_in_buffer, 880 880 }; 881 881 882 + int __weak get_c0_fdc_int(void) 883 + { 884 + return -1; 885 + } 886 + 882 887 static int mips_ejtag_fdc_tty_probe(struct mips_cdmm_device *dev) 883 888 { 884 889 int ret, nport; ··· 972 967 wake_up_process(priv->thread); 973 968 974 969 /* Look for an FDC IRQ */ 975 - priv->irq = -1; 976 - if (get_c0_fdc_int) 977 - priv->irq = get_c0_fdc_int(); 970 + priv->irq = get_c0_fdc_int(); 978 971 979 972 /* Try requesting the IRQ */ 980 973 if (priv->irq >= 0) {