Hello, Currently, a lot of PCI-related sysfs objects that are created when either the PCI driver is initialised or when a new device is added are dynamically created under the "/sys/bus/pci/devices/..." path. All the attributes are added when late_initcall() function executes when the PCI driver, and hence the PCI sub-system, is initialised, and also when the function pci_bus_add_devices() executes when a device is added: late_initcall() pci_sysfs_init() pci_create_sysfs_dev_files() sysfs_create_bin_file() pci_bus_add_devices() pci_bus_add_device() pci_create_sysfs_dev_files() ... When a device is stopped and removed the pci_remove_sysfs_dev_files() function executes dynamically removing all the attributes that were previously added: pci_stop_bus_device() pci_stop_dev() pci_remove_sysfs_dev_files() sysfs_remove_bin_file() The current implementation is known to cause problems [1]. As most of the PCI-related attributes does not need to be created and removed dynamically, and thus there is no need to also manage their create and remove life cycle manually. This series aims to convert the majority of the dynamic sysfs objects into static ones so that the PCI driver core can manage them automatically when the device is either added or removed. The aim is also to first reduce the reliance on using late_initcall() and eventually remove the need for it completely - this hopefully should move everything closer towards addressing the issue that has been identified in [1]. Aside from converting sysfs objects, this series also offers a series of style clean-up patches offering updates, style changes, etc. 1. https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/ Krzysztof Krzysztof Wilczyński (20): PCI: Convert dynamic "config" sysfs object into static PCI: Convert dynamic "rom" sysfs object into static PCI: Convert dynamic "reset" sysfs object into static PCI/VPD: Convert dynamic "vpd" sysfs object into static PCI: Convert dynamic "index" and "label" sysfs objects into static sysfs: Introduce BIN_ATTR_ADMIN_RO and BIN_ATTR_ADMIN_RW PCI: Convert PCI sysfs objects to use BIN_ATTR_ADMIN_RW macro PCI: Move to kstrtobool() to handle user input PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions PCI: Update style to be more consistent PCI: Rearrange attributes from the pci_dev_group PCI: Rearrange attributes from the pci_dev_config_attr_group PCI: Rearrange attributes from the pci_dev_rom_attr_group PCI: Rearrange attributes from the pci_dev_reset_attr_group PCI: Rearrange attributes from the pci_dev_attr_group PCI: Rearrange attributes from the pci_dev_hp_attr_group PCI: Rearrange attributes from the pci_bridge_attr_group PCI: Rearrange attributes from the pcie_dev_attr_group PCI: Rearrange attributes from the pci_bus_group PCI: Rearrange attributes from the pcibus_group drivers/pci/pci-label.c | 241 ++---- drivers/pci/pci-sysfs.c | 1655 ++++++++++++++++++++------------------- drivers/pci/pci.h | 16 +- drivers/pci/remove.c | 2 + drivers/pci/vpd.c | 58 +- include/linux/pci.h | 1 - include/linux/sysfs.h | 23 + 7 files changed, 976 insertions(+), 1020 deletions(-) -- 2.31.0