]> git.karo-electronics.de Git - linux-beck.git/commitdiff
PCI: Allow driver-specific data in host bridge
authorThierry Reding <treding@nvidia.com>
Fri, 25 Nov 2016 10:57:10 +0000 (11:57 +0100)
committerBjorn Helgaas <helgaas@kernel.org>
Wed, 7 Dec 2016 18:05:48 +0000 (12:05 -0600)
Provide a way to allocate driver-specific data along with a PCI host bridge
structure. The bridge's ->private field points to this data.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <helgaas@kernel.org>
drivers/pci/probe.c
include/linux/pci.h

index 4853c8fbd7010e250724a01ec653f70befc20277..cf9cb6f3078247986a996ffc8292b9c59a052a31 100644 (file)
@@ -521,11 +521,11 @@ static void pci_release_host_bridge_dev(struct device *dev)
        kfree(bridge);
 }
 
-static struct pci_host_bridge *pci_alloc_host_bridge(void)
+static struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
 {
        struct pci_host_bridge *bridge;
 
-       bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
+       bridge = kzalloc(sizeof(*bridge) + priv, GFP_KERNEL);
        if (!bridge)
                return NULL;
 
@@ -2253,7 +2253,7 @@ static struct pci_bus *pci_create_root_bus_msi(struct device *parent,
        int error;
        struct pci_host_bridge *bridge;
 
-       bridge = pci_alloc_host_bridge();
+       bridge = pci_alloc_host_bridge(0);
        if (!bridge)
                return NULL;
 
index f79634612fbf36c2337991de0c5787a719cd4a7f..beacb17e81fb1b29b2c81d88e60469f44a8289c1 100644 (file)
@@ -434,10 +434,21 @@ struct pci_host_bridge {
                        resource_size_t start,
                        resource_size_t size,
                        resource_size_t align);
+       unsigned long private[0] ____cacheline_aligned;
 };
 
 #define        to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
 
+static inline void *pci_host_bridge_priv(struct pci_host_bridge *bridge)
+{
+       return (void *)bridge->private;
+}
+
+static inline struct pci_host_bridge *pci_host_bridge_from_priv(void *priv)
+{
+       return container_of(priv, struct pci_host_bridge, private);
+}
+
 struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
 
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,