PCI: Add devm_pci_alloc_host_bridge() interface
Struct pci_host_bridge can be allocated by PCI host bridge drivers which usually allocate and map memory through devm managed interfaces. Add a devm version for the pci_alloc_host_bridge() interface to simplify PCI host controller driver porting and simplify the driver failure paths. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
parent
dff79b91b8
commit
5c3f18cce0
3 changed files with 25 additions and 2 deletions
|
@ -342,6 +342,7 @@ PER-CPU MEM
|
||||||
devm_free_percpu()
|
devm_free_percpu()
|
||||||
|
|
||||||
PCI
|
PCI
|
||||||
|
devm_pci_alloc_host_bridge() : managed PCI host bridge allocation
|
||||||
devm_pci_remap_cfgspace() : ioremap PCI configuration space
|
devm_pci_remap_cfgspace() : ioremap PCI configuration space
|
||||||
devm_pci_remap_cfg_resource() : ioremap PCI configuration space resource
|
devm_pci_remap_cfg_resource() : ioremap PCI configuration space resource
|
||||||
pcim_enable_device() : after success, all PCI ops become managed
|
pcim_enable_device() : after success, all PCI ops become managed
|
||||||
|
|
|
@ -510,14 +510,18 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pci_release_host_bridge_dev(struct device *dev)
|
static void devm_pci_release_host_bridge_dev(struct device *dev)
|
||||||
{
|
{
|
||||||
struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
|
struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
|
||||||
|
|
||||||
if (bridge->release_fn)
|
if (bridge->release_fn)
|
||||||
bridge->release_fn(bridge);
|
bridge->release_fn(bridge);
|
||||||
|
}
|
||||||
|
|
||||||
pci_free_host_bridge(bridge);
|
static void pci_release_host_bridge_dev(struct device *dev)
|
||||||
|
{
|
||||||
|
devm_pci_release_host_bridge_dev(dev);
|
||||||
|
pci_free_host_bridge(to_pci_host_bridge(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
|
struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
|
||||||
|
@ -535,6 +539,22 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pci_alloc_host_bridge);
|
EXPORT_SYMBOL(pci_alloc_host_bridge);
|
||||||
|
|
||||||
|
struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,
|
||||||
|
size_t priv)
|
||||||
|
{
|
||||||
|
struct pci_host_bridge *bridge;
|
||||||
|
|
||||||
|
bridge = devm_kzalloc(dev, sizeof(*bridge) + priv, GFP_KERNEL);
|
||||||
|
if (!bridge)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
INIT_LIST_HEAD(&bridge->windows);
|
||||||
|
bridge->dev.release = devm_pci_release_host_bridge_dev;
|
||||||
|
|
||||||
|
return bridge;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(devm_pci_alloc_host_bridge);
|
||||||
|
|
||||||
void pci_free_host_bridge(struct pci_host_bridge *bridge)
|
void pci_free_host_bridge(struct pci_host_bridge *bridge)
|
||||||
{
|
{
|
||||||
pci_free_resource_list(&bridge->windows);
|
pci_free_resource_list(&bridge->windows);
|
||||||
|
|
|
@ -458,6 +458,8 @@ static inline struct pci_host_bridge *pci_host_bridge_from_priv(void *priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pci_host_bridge *pci_alloc_host_bridge(size_t priv);
|
struct pci_host_bridge *pci_alloc_host_bridge(size_t priv);
|
||||||
|
struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,
|
||||||
|
size_t priv);
|
||||||
void pci_free_host_bridge(struct pci_host_bridge *bridge);
|
void pci_free_host_bridge(struct pci_host_bridge *bridge);
|
||||||
int pci_register_host_bridge(struct pci_host_bridge *bridge);
|
int pci_register_host_bridge(struct pci_host_bridge *bridge);
|
||||||
struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
|
struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus);
|
||||||
|
|
Loading…
Reference in a new issue