PCI: Make pcie_port_bus_type const
authorRicardo B. Marliere <ricardo@marliere.net>
Thu, 8 Feb 2024 19:41:46 +0000 (16:41 -0300)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 8 Feb 2024 20:59:47 +0000 (14:59 -0600)
Now that the driver core can properly handle constant struct bus_type, move
the pcie_port_bus_type variable to be a constant structure as well, placing
it into read-only memory which can not be modified at runtime.

Link: https://lore.kernel.org/r/20240208-bus_cleanup-pci2-v1-1-5e578210b6f2@marliere.net
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci-driver.c
drivers/pci/pcie/portdrv.h

index 51ec9e7e784f0e3a82134a05b114abe5be90d07c..37cfec341fce1b5285fdcd5adb4599e4823266cc 100644 (file)
@@ -1714,7 +1714,7 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
        return 1;
 }
 
-struct bus_type pcie_port_bus_type = {
+const struct bus_type pcie_port_bus_type = {
        .name           = "pci_express",
        .match          = pcie_port_bus_match,
 };
index 1f3803bde7ee16067d4aa801057076268dfe4b51..12c89ea0313b9c4c5aa73744ea6aff9dee844d84 100644 (file)
@@ -96,7 +96,7 @@ struct pcie_port_service_driver {
 int pcie_port_service_register(struct pcie_port_service_driver *new);
 void pcie_port_service_unregister(struct pcie_port_service_driver *new);
 
-extern struct bus_type pcie_port_bus_type;
+extern const struct bus_type pcie_port_bus_type;
 
 struct pci_dev;