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

x86/pci: Reducde #ifdeffery in PCI init code

Adding a function call before the first #ifdef in arch_pci_init() triggers
a 'mixed declarations and code' warning if PCI_DIRECT is enabled.

Use stub functions and move the #ifdeffery to the header file where it is
not in the way.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20200826112332.767707340@linutronix.de

+14 -7
+11
arch/x86/include/asm/pci_x86.h
··· 114 114 extern bool port_cf9_safe; 115 115 116 116 /* arch_initcall level */ 117 + #ifdef CONFIG_PCI_DIRECT 117 118 extern int pci_direct_probe(void); 118 119 extern void pci_direct_init(int type); 120 + #else 121 + static inline int pci_direct_probe(void) { return -1; } 122 + static inline void pci_direct_init(int type) { } 123 + #endif 124 + 125 + #ifdef CONFIG_PCI_BIOS 119 126 extern void pci_pcbios_init(void); 127 + #else 128 + static inline void pci_pcbios_init(void) { } 129 + #endif 130 + 120 131 extern void __init dmi_check_pciprobe(void); 121 132 extern void __init dmi_check_skip_isa_align(void); 122 133
+3 -7
arch/x86/pci/init.c
··· 8 8 in the right sequence from here. */ 9 9 static __init int pci_arch_init(void) 10 10 { 11 - #ifdef CONFIG_PCI_DIRECT 12 - int type = 0; 11 + int type; 13 12 14 13 type = pci_direct_probe(); 15 - #endif 16 14 17 15 if (!(pci_probe & PCI_PROBE_NOEARLY)) 18 16 pci_mmcfg_early_init(); ··· 18 20 if (x86_init.pci.arch_init && !x86_init.pci.arch_init()) 19 21 return 0; 20 22 21 - #ifdef CONFIG_PCI_BIOS 22 23 pci_pcbios_init(); 23 - #endif 24 + 24 25 /* 25 26 * don't check for raw_pci_ops here because we want pcbios as last 26 27 * fallback, yet it's needed to run first to set pcibios_last_bus 27 28 * in case legacy PCI probing is used. otherwise detecting peer busses 28 29 * fails. 29 30 */ 30 - #ifdef CONFIG_PCI_DIRECT 31 31 pci_direct_init(type); 32 - #endif 32 + 33 33 if (!raw_pci_ops && !raw_pci_ext_ops) 34 34 printk(KERN_ERR 35 35 "PCI: Fatal: No config space access function found\n");