diff options
| author | Krzysztof Wilczyński <kwilczynski@kernel.org> | 2026-05-08 04:35:29 +0000 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2026-06-23 15:19:08 -0500 |
| commit | 4eee7eef239c61d11a2fdd03691d60c5cd91940d (patch) | |
| tree | 5cdbd3065e4127373dbffd2104e1f9f475e69e0d | |
| parent | 2c31a9675f50a61c9ceed6dab2545be7aa896d1a (diff) | |
PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope
Currently, pci_sysfs_init() and sysfs_initialized compile unconditionally,
even on platforms where static attribute groups handle all resource file
creation.
Place them behind a new HAVE_PCI_SYSFS_INIT macro, especially as the
late_initcall is only needed when:
- HAVE_PCI_LEGACY is set, to iterate buses and create legacy I/O and
memory files.
- Neither HAVE_PCI_MMAP nor ARCH_GENERIC_PCI_MMAP_RESOURCE is set, to
iterate devices and create resource files via the __weak
pci_create_resource_files() stub override (this is how the Alpha
architecture handles this currently).
On most systems both conditions are false and the entire late_initcall
compiles away.
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Link: https://patch.msgid.link/20260508043543.217179-11-kwilczynski@kernel.org
| -rw-r--r-- | drivers/pci/pci-sysfs.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 102147500596..0ba4fbf40cdc 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -37,7 +37,14 @@ #define ARCH_PCI_DEV_GROUPS #endif +#if defined(HAVE_PCI_LEGACY) || \ + !defined(HAVE_PCI_MMAP) && !defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) +#define HAVE_PCI_SYSFS_INIT +#endif + +#ifdef HAVE_PCI_SYSFS_INIT static int sysfs_initialized; /* = 0 */ +#endif /* show configuration fields */ #define pci_config_attr(field, format_string) \ @@ -1768,6 +1775,7 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) } #endif +#ifdef HAVE_PCI_SYSFS_INIT static int __init pci_sysfs_init(void) { #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) @@ -1794,6 +1802,7 @@ static int __init pci_sysfs_init(void) return 0; } late_initcall(pci_sysfs_init); +#endif static struct attribute *pci_dev_dev_attrs[] = { &dev_attr_boot_vga.attr, |
