Commit cdb9b9f7 authored by Paul Mackerras's avatar Paul Mackerras Committed by Greg Kroah-Hartman

[PATCH] PCI: Small rearrangement of PCI probing code

This patch makes some small rearrangements of the PCI probing code in
order to make it possible for arch code to set up the PCI tree
without needing to duplicate code from the PCI layer unnecessarily.
PPC64 will use this to set up the PCI tree from the Open Firmware
device tree, which we need to do on logically-partitioned pSeries
systems.
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c87f883e
...@@ -29,7 +29,6 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } ...@@ -29,7 +29,6 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }
#endif #endif
/* Functions for PCI Hotplug drivers to use */ /* Functions for PCI Hotplug drivers to use */
extern struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr);
extern unsigned int pci_do_scan_bus(struct pci_bus *bus); extern unsigned int pci_do_scan_bus(struct pci_bus *bus);
extern int pci_remove_device_safe(struct pci_dev *dev); extern int pci_remove_device_safe(struct pci_dev *dev);
extern unsigned char pci_max_busnr(void); extern unsigned char pci_max_busnr(void);
......
...@@ -753,26 +753,18 @@ pci_scan_device(struct pci_bus *bus, int devfn) ...@@ -753,26 +753,18 @@ pci_scan_device(struct pci_bus *bus, int devfn)
kfree(dev); kfree(dev);
return NULL; return NULL;
} }
device_initialize(&dev->dev);
dev->dev.release = pci_release_dev;
pci_dev_get(dev);
dev->dev.dma_mask = &dev->dma_mask;
dev->dev.coherent_dma_mask = 0xffffffffull;
return dev; return dev;
} }
struct pci_dev * __devinit void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
pci_scan_single_device(struct pci_bus *bus, int devfn)
{ {
struct pci_dev *dev; device_initialize(&dev->dev);
dev->dev.release = pci_release_dev;
dev = pci_scan_device(bus, devfn); pci_dev_get(dev);
pci_scan_msi_device(dev);
if (!dev) dev->dev.dma_mask = &dev->dma_mask;
return NULL; dev->dev.coherent_dma_mask = 0xffffffffull;
/* Fix up broken headers */ /* Fix up broken headers */
pci_fixup_device(pci_fixup_header, dev); pci_fixup_device(pci_fixup_header, dev);
...@@ -785,6 +777,19 @@ pci_scan_single_device(struct pci_bus *bus, int devfn) ...@@ -785,6 +777,19 @@ pci_scan_single_device(struct pci_bus *bus, int devfn)
spin_lock(&pci_bus_lock); spin_lock(&pci_bus_lock);
list_add_tail(&dev->bus_list, &bus->devices); list_add_tail(&dev->bus_list, &bus->devices);
spin_unlock(&pci_bus_lock); spin_unlock(&pci_bus_lock);
}
struct pci_dev * __devinit
pci_scan_single_device(struct pci_bus *bus, int devfn)
{
struct pci_dev *dev;
dev = pci_scan_device(bus, devfn);
if (!dev)
return NULL;
pci_device_add(dev, bus);
pci_scan_msi_device(dev);
return dev; return dev;
} }
...@@ -881,7 +886,8 @@ unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus) ...@@ -881,7 +886,8 @@ unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
return max; return max;
} }
struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata) struct pci_bus * __devinit pci_create_bus(struct device *parent,
int bus, struct pci_ops *ops, void *sysdata)
{ {
int error; int error;
struct pci_bus *b; struct pci_bus *b;
...@@ -938,8 +944,6 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, ...@@ -938,8 +944,6 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus,
b->resource[0] = &ioport_resource; b->resource[0] = &ioport_resource;
b->resource[1] = &iomem_resource; b->resource[1] = &iomem_resource;
b->subordinate = pci_scan_child_bus(b);
return b; return b;
sys_create_link_err: sys_create_link_err:
...@@ -957,6 +961,18 @@ err_out: ...@@ -957,6 +961,18 @@ err_out:
kfree(b); kfree(b);
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(pci_create_bus);
struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
int bus, struct pci_ops *ops, void *sysdata)
{
struct pci_bus *b;
b = pci_create_bus(parent, bus, ops, sysdata);
if (b)
b->subordinate = pci_scan_child_bus(b);
return b;
}
EXPORT_SYMBOL(pci_scan_bus_parented); EXPORT_SYMBOL(pci_scan_bus_parented);
#ifdef CONFIG_HOTPLUG #ifdef CONFIG_HOTPLUG
......
...@@ -315,8 +315,11 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s ...@@ -315,8 +315,11 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s
pci_bus_add_devices(root_bus); pci_bus_add_devices(root_bus);
return root_bus; return root_bus;
} }
struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata);
struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr);
int pci_scan_slot(struct pci_bus *bus, int devfn); int pci_scan_slot(struct pci_bus *bus, int devfn);
struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
unsigned int pci_scan_child_bus(struct pci_bus *bus); unsigned int pci_scan_child_bus(struct pci_bus *bus);
void pci_bus_add_device(struct pci_dev *dev); void pci_bus_add_device(struct pci_dev *dev);
void pci_read_bridge_bases(struct pci_bus *child); void pci_read_bridge_bases(struct pci_bus *child);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment