mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
Merge branch 'pci/controller/host-common'
- Move struct pci_host_bridge allocation from pci_host_common_init() to callers, which significantly simplifies pcie-apple (Marc Zyngier) * pci/controller/host-common: PCI: host-generic: Move bridge allocation outside of pci_host_common_init()
This commit is contained in:
commit
12390db236
|
|
@ -53,16 +53,12 @@ struct pci_config_window *pci_host_common_ecam_create(struct device *dev,
|
|||
EXPORT_SYMBOL_GPL(pci_host_common_ecam_create);
|
||||
|
||||
int pci_host_common_init(struct platform_device *pdev,
|
||||
struct pci_host_bridge *bridge,
|
||||
const struct pci_ecam_ops *ops)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct pci_host_bridge *bridge;
|
||||
struct pci_config_window *cfg;
|
||||
|
||||
bridge = devm_pci_alloc_host_bridge(dev, 0);
|
||||
if (!bridge)
|
||||
return -ENOMEM;
|
||||
|
||||
of_pci_check_probe_only();
|
||||
|
||||
platform_set_drvdata(pdev, bridge);
|
||||
|
|
@ -85,12 +81,17 @@ EXPORT_SYMBOL_GPL(pci_host_common_init);
|
|||
int pci_host_common_probe(struct platform_device *pdev)
|
||||
{
|
||||
const struct pci_ecam_ops *ops;
|
||||
struct pci_host_bridge *bridge;
|
||||
|
||||
ops = of_device_get_match_data(&pdev->dev);
|
||||
if (!ops)
|
||||
return -ENODEV;
|
||||
|
||||
return pci_host_common_init(pdev, ops);
|
||||
bridge = devm_pci_alloc_host_bridge(&pdev->dev, 0);
|
||||
if (!bridge)
|
||||
return -ENOMEM;
|
||||
|
||||
return pci_host_common_init(pdev, bridge, ops);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pci_host_common_probe);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ struct pci_ecam_ops;
|
|||
|
||||
int pci_host_common_probe(struct platform_device *pdev);
|
||||
int pci_host_common_init(struct platform_device *pdev,
|
||||
struct pci_host_bridge *bridge,
|
||||
const struct pci_ecam_ops *ops);
|
||||
void pci_host_common_remove(struct platform_device *pdev);
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@ struct apple_pcie {
|
|||
const struct hw_info *hw;
|
||||
unsigned long *bitmap;
|
||||
struct list_head ports;
|
||||
struct list_head entry;
|
||||
struct completion event;
|
||||
struct irq_fwspec fwspec;
|
||||
u32 nvecs;
|
||||
|
|
@ -206,9 +205,6 @@ struct apple_pcie_port {
|
|||
int idx;
|
||||
};
|
||||
|
||||
static LIST_HEAD(pcie_list);
|
||||
static DEFINE_MUTEX(pcie_list_lock);
|
||||
|
||||
static void rmw_set(u32 set, void __iomem *addr)
|
||||
{
|
||||
writel_relaxed(readl_relaxed(addr) | set, addr);
|
||||
|
|
@ -724,32 +720,9 @@ static int apple_msi_init(struct apple_pcie *pcie)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void apple_pcie_register(struct apple_pcie *pcie)
|
||||
{
|
||||
guard(mutex)(&pcie_list_lock);
|
||||
|
||||
list_add_tail(&pcie->entry, &pcie_list);
|
||||
}
|
||||
|
||||
static void apple_pcie_unregister(struct apple_pcie *pcie)
|
||||
{
|
||||
guard(mutex)(&pcie_list_lock);
|
||||
|
||||
list_del(&pcie->entry);
|
||||
}
|
||||
|
||||
static struct apple_pcie *apple_pcie_lookup(struct device *dev)
|
||||
{
|
||||
struct apple_pcie *pcie;
|
||||
|
||||
guard(mutex)(&pcie_list_lock);
|
||||
|
||||
list_for_each_entry(pcie, &pcie_list, entry) {
|
||||
if (pcie->dev == dev)
|
||||
return pcie;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return pci_host_bridge_priv(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
static struct apple_pcie_port *apple_pcie_get_port(struct pci_dev *pdev)
|
||||
|
|
@ -875,13 +848,15 @@ static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
|
|||
static int apple_pcie_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct pci_host_bridge *bridge;
|
||||
struct apple_pcie *pcie;
|
||||
int ret;
|
||||
|
||||
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
|
||||
if (!pcie)
|
||||
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
|
||||
if (!bridge)
|
||||
return -ENOMEM;
|
||||
|
||||
pcie = pci_host_bridge_priv(bridge);
|
||||
pcie->dev = dev;
|
||||
pcie->hw = of_device_get_match_data(dev);
|
||||
if (!pcie->hw)
|
||||
|
|
@ -897,13 +872,7 @@ static int apple_pcie_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
apple_pcie_register(pcie);
|
||||
|
||||
ret = pci_host_common_init(pdev, &apple_pcie_cfg_ecam_ops);
|
||||
if (ret)
|
||||
apple_pcie_unregister(pcie);
|
||||
|
||||
return ret;
|
||||
return pci_host_common_init(pdev, bridge, &apple_pcie_cfg_ecam_ops);
|
||||
}
|
||||
|
||||
static const struct of_device_id apple_pcie_of_match[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user