diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2011-02-04 13:24:11 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-02-04 13:46:51 -0500 |
commit | b5d937de0367d26f65b9af1aef5f2c34c1939be0 (patch) | |
tree | e91eaaa72ef1aae543a1fa494171f7e3c0c14d94 /arch/powerpc/kernel | |
parent | 04bea68b2f0eeebb089ecc67b618795925268b4a (diff) |
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: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/of_platform.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 11 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_32.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_dn.c | 9 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_of_scan.c | 4 |
6 files changed, 16 insertions, 18 deletions
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index b2c363ef38ad..9bd951c67767 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c | |||
@@ -74,7 +74,7 @@ static int __devinit of_pci_phb_probe(struct platform_device *dev, | |||
74 | #endif /* CONFIG_EEH */ | 74 | #endif /* CONFIG_EEH */ |
75 | 75 | ||
76 | /* Scan the bus */ | 76 | /* Scan the bus */ |
77 | pcibios_scan_phb(phb, dev->dev.of_node); | 77 | pcibios_scan_phb(phb); |
78 | if (phb->bus == NULL) | 78 | if (phb->bus == NULL) |
79 | return -ENXIO; | 79 | return -ENXIO; |
80 | 80 | ||
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index eb341be9a4d9..3cd85faa8ac6 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -1688,13 +1688,8 @@ int early_find_capability(struct pci_controller *hose, int bus, int devfn, | |||
1688 | /** | 1688 | /** |
1689 | * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus | 1689 | * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus |
1690 | * @hose: Pointer to the PCI host controller instance structure | 1690 | * @hose: Pointer to the PCI host controller instance structure |
1691 | * @sysdata: value to use for sysdata pointer. ppc32 and ppc64 differ here | ||
1692 | * | ||
1693 | * Note: the 'data' pointer is a temporary measure. As 32 and 64 bit | ||
1694 | * pci code gets merged, this parameter should become unnecessary because | ||
1695 | * both will use the same value. | ||
1696 | */ | 1691 | */ |
1697 | void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata) | 1692 | void __devinit pcibios_scan_phb(struct pci_controller *hose) |
1698 | { | 1693 | { |
1699 | struct pci_bus *bus; | 1694 | struct pci_bus *bus; |
1700 | struct device_node *node = hose->dn; | 1695 | struct device_node *node = hose->dn; |
@@ -1704,13 +1699,13 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata) | |||
1704 | node ? node->full_name : "<NO NAME>"); | 1699 | node ? node->full_name : "<NO NAME>"); |
1705 | 1700 | ||
1706 | /* Create an empty bus for the toplevel */ | 1701 | /* Create an empty bus for the toplevel */ |
1707 | bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, | 1702 | bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose); |
1708 | sysdata); | ||
1709 | if (bus == NULL) { | 1703 | if (bus == NULL) { |
1710 | pr_err("Failed to create bus for PCI domain %04x\n", | 1704 | pr_err("Failed to create bus for PCI domain %04x\n", |
1711 | hose->global_number); | 1705 | hose->global_number); |
1712 | return; | 1706 | return; |
1713 | } | 1707 | } |
1708 | bus->dev.of_node = of_node_get(node); | ||
1714 | bus->secondary = hose->first_busno; | 1709 | bus->secondary = hose->first_busno; |
1715 | hose->bus = bus; | 1710 | hose->bus = bus; |
1716 | 1711 | ||
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index e7db5b48004a..bedb370459f2 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -381,7 +381,7 @@ static int __init pcibios_init(void) | |||
381 | if (pci_assign_all_buses) | 381 | if (pci_assign_all_buses) |
382 | hose->first_busno = next_busno; | 382 | hose->first_busno = next_busno; |
383 | hose->last_busno = 0xff; | 383 | hose->last_busno = 0xff; |
384 | pcibios_scan_phb(hose, hose); | 384 | pcibios_scan_phb(hose); |
385 | pci_bus_add_devices(hose->bus); | 385 | pci_bus_add_devices(hose->bus); |
386 | if (pci_assign_all_buses || next_busno <= hose->last_busno) | 386 | if (pci_assign_all_buses || next_busno <= hose->last_busno) |
387 | next_busno = hose->last_busno + pcibios_assign_bus_offset; | 387 | next_busno = hose->last_busno + pcibios_assign_bus_offset; |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 851577608a78..fc6452b6be9f 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -64,7 +64,7 @@ static int __init pcibios_init(void) | |||
64 | 64 | ||
65 | /* Scan all of the recorded PCI controllers. */ | 65 | /* Scan all of the recorded PCI controllers. */ |
66 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | 66 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { |
67 | pcibios_scan_phb(hose, hose->dn); | 67 | pcibios_scan_phb(hose); |
68 | pci_bus_add_devices(hose->bus); | 68 | pci_bus_add_devices(hose->bus); |
69 | } | 69 | } |
70 | 70 | ||
@@ -242,10 +242,10 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, | |||
242 | break; | 242 | break; |
243 | bus = NULL; | 243 | bus = NULL; |
244 | } | 244 | } |
245 | if (bus == NULL || bus->sysdata == NULL) | 245 | if (bus == NULL || bus->dev.of_node == NULL) |
246 | return -ENODEV; | 246 | return -ENODEV; |
247 | 247 | ||
248 | hose_node = (struct device_node *)bus->sysdata; | 248 | hose_node = bus->dev.of_node; |
249 | hose = PCI_DN(hose_node)->phb; | 249 | hose = PCI_DN(hose_node)->phb; |
250 | 250 | ||
251 | switch (which) { | 251 | switch (which) { |
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index d56b35ee7f74..29852688ceaa 100644 --- a/arch/powerpc/kernel/pci_dn.c +++ b/arch/powerpc/kernel/pci_dn.c | |||
@@ -161,7 +161,7 @@ static void *is_devfn_node(struct device_node *dn, void *data) | |||
161 | /* | 161 | /* |
162 | * This is the "slow" path for looking up a device_node from a | 162 | * This is the "slow" path for looking up a device_node from a |
163 | * pci_dev. It will hunt for the device under its parent's | 163 | * pci_dev. It will hunt for the device under its parent's |
164 | * phb and then update sysdata for a future fastpath. | 164 | * phb and then update of_node pointer. |
165 | * | 165 | * |
166 | * It may also do fixups on the actual device since this happens | 166 | * It may also do fixups on the actual device since this happens |
167 | * on the first read/write. | 167 | * on the first read/write. |
@@ -170,16 +170,19 @@ static void *is_devfn_node(struct device_node *dn, void *data) | |||
170 | * In this case it may probe for real hardware ("just in case") | 170 | * In this case it may probe for real hardware ("just in case") |
171 | * and add a device_node to the device tree if necessary. | 171 | * and add a device_node to the device tree if necessary. |
172 | * | 172 | * |
173 | * Is this function necessary anymore now that dev->dev.of_node is | ||
174 | * used to store the node pointer? | ||
175 | * | ||
173 | */ | 176 | */ |
174 | struct device_node *fetch_dev_dn(struct pci_dev *dev) | 177 | struct device_node *fetch_dev_dn(struct pci_dev *dev) |
175 | { | 178 | { |
176 | struct device_node *orig_dn = dev->sysdata; | 179 | struct device_node *orig_dn = dev->dev.of_node; |
177 | struct device_node *dn; | 180 | struct device_node *dn; |
178 | unsigned long searchval = (dev->bus->number << 8) | dev->devfn; | 181 | unsigned long searchval = (dev->bus->number << 8) | dev->devfn; |
179 | 182 | ||
180 | dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); | 183 | dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); |
181 | if (dn) | 184 | if (dn) |
182 | dev->sysdata = dn; | 185 | dev->dev.of_node = dn; |
183 | return dn; | 186 | return dn; |
184 | } | 187 | } |
185 | EXPORT_SYMBOL(fetch_dev_dn); | 188 | EXPORT_SYMBOL(fetch_dev_dn); |
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index e751506323b4..1e89a72fd030 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c | |||
@@ -135,7 +135,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, | |||
135 | pr_debug(" create device, devfn: %x, type: %s\n", devfn, type); | 135 | pr_debug(" create device, devfn: %x, type: %s\n", devfn, type); |
136 | 136 | ||
137 | dev->bus = bus; | 137 | dev->bus = bus; |
138 | dev->sysdata = node; | 138 | dev->dev.of_node = of_node_get(node); |
139 | dev->dev.parent = bus->bridge; | 139 | dev->dev.parent = bus->bridge; |
140 | dev->dev.bus = &pci_bus_type; | 140 | dev->dev.bus = &pci_bus_type; |
141 | dev->devfn = devfn; | 141 | dev->devfn = devfn; |
@@ -238,7 +238,7 @@ void __devinit of_scan_pci_bridge(struct device_node *node, | |||
238 | bus->primary = dev->bus->number; | 238 | bus->primary = dev->bus->number; |
239 | bus->subordinate = busrange[1]; | 239 | bus->subordinate = busrange[1]; |
240 | bus->bridge_ctl = 0; | 240 | bus->bridge_ctl = 0; |
241 | bus->sysdata = node; | 241 | bus->dev.of_node = of_node_get(node); |
242 | 242 | ||
243 | /* parse ranges property */ | 243 | /* parse ranges property */ |
244 | /* PCI #address-cells == 3 and #size-cells == 2 always */ | 244 | /* PCI #address-cells == 3 and #size-cells == 2 always */ |