Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5d937de authored by Grant Likely's avatar Grant Likely
Browse files

powerpc/pci: Make both ppc32 and ppc64 use sysdata for pci_controller



Currently, ppc32 uses sysdata for the pci_controller pointer, and
ppc64 uses it to hold the device_node pointer.  This patch moves the
of_node pointer into (struct pci_bus*)->dev.of_node and
(struct pci_dev*)->dev.of_node so that sysdata can be converted to always
use the pci_controller pointer instead.  It also fixes up the
allocating of pci devices so that the of_node pointer gets assigned
consistently and increments the ref count.

Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 04bea68b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose)
		       hose->global_number);
		return;
	}
	bus.dev->of_node = of_node_get(node);
	bus->secondary = hose->first_busno;
	hose->bus = bus;

+5 −22
Original line number Diff line number Diff line
@@ -164,13 +164,13 @@ extern void setup_indirect_pci(struct pci_controller* hose,
			       resource_size_t cfg_addr,
			       resource_size_t cfg_data, u32 flags);

#ifndef CONFIG_PPC64

static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
{
	return bus->sysdata;
}

#ifndef CONFIG_PPC64

static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
{
	struct pci_controller *host;
@@ -228,19 +228,10 @@ extern void * update_dn_pci_info(struct device_node *dn, void *data);

/* Get a device_node from a pci_dev.  This code must be fast except
 * in the case where the sysdata is incorrect and needs to be fixed
 * up (this will only happen once).
 * In this case the sysdata will have been inherited from a PCI host
 * bridge or a PCI-PCI bridge further up the tree, so it will point
 * to a valid struct pci_dn, just not the one we want.
 */
 * up (this will only happen once). */
static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
{
	struct device_node *dn = dev->sysdata;
	struct pci_dn *pdn = dn->data;

	if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number)
		return dn;	/* fast path.  sysdata is good */
	return fetch_dev_dn(dev);
	return dev->dev.of_node ? dev->dev.of_node : fetch_dev_dn(dev);
}

static inline int pci_device_from_OF_node(struct device_node *np,
@@ -258,7 +249,7 @@ static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
	if (bus->self)
		return pci_device_to_OF_node(bus->self);
	else
		return bus->sysdata; /* Must be root bus (PHB) */
		return bus->dev.of_node; /* Must be root bus (PHB) */
}

/** Find the bus corresponding to the indicated device node */
@@ -270,14 +261,6 @@ extern void pcibios_remove_pci_devices(struct pci_bus *bus);
/** Discover new pci devices under this bus, and add them */
extern void pcibios_add_pci_devices(struct pci_bus *bus);

static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
{
	struct device_node *busdn = bus->sysdata;

	BUG_ON(busdn == NULL);
	return PCI_DN(busdn)->phb;
}


extern void isa_bridge_find_early(struct pci_controller *hose);

+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
extern void pcibios_setup_bus_devices(struct pci_bus *bus);
extern void pcibios_setup_bus_self(struct pci_bus *bus);
extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
extern void pcibios_scan_phb(struct pci_controller *hose, void *sysdata);
extern void pcibios_scan_phb(struct pci_controller *hose);

#endif	/* __KERNEL__ */
#endif /* __ASM_POWERPC_PCI_H */
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ static int __devinit of_pci_phb_probe(struct platform_device *dev,
#endif /* CONFIG_EEH */

	/* Scan the bus */
	pcibios_scan_phb(phb, dev->dev.of_node);
	pcibios_scan_phb(phb);
	if (phb->bus == NULL)
		return -ENXIO;

+3 −8
Original line number Diff line number Diff line
@@ -1688,13 +1688,8 @@ int early_find_capability(struct pci_controller *hose, int bus, int devfn,
/**
 * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
 * @hose: Pointer to the PCI host controller instance structure
 * @sysdata: value to use for sysdata pointer.  ppc32 and ppc64 differ here
 *
 * Note: the 'data' pointer is a temporary measure.  As 32 and 64 bit
 * pci code gets merged, this parameter should become unnecessary because
 * both will use the same value.
 */
void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata)
void __devinit pcibios_scan_phb(struct pci_controller *hose)
{
	struct pci_bus *bus;
	struct device_node *node = hose->dn;
@@ -1704,13 +1699,13 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata)
		 node ? node->full_name : "<NO NAME>");

	/* Create an empty bus for the toplevel */
	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops,
			     sysdata);
	bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
	if (bus == NULL) {
		pr_err("Failed to create bus for PCI domain %04x\n",
			hose->global_number);
		return;
	}
	bus->dev.of_node = of_node_get(node);
	bus->secondary = hose->first_busno;
	hose->bus = bus;

Loading