aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/pci_32.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2007-06-27 14:09:43 -0400
committerKumar Gala <galak@kernel.crashing.org>2007-06-29 02:58:45 -0400
commita4c9e328279d55622d56507629d6b8942e8cc9c9 (patch)
tree6e1791cfdfd6c0b9e56f1b154fca715b9aed9fbd /arch/powerpc/kernel/pci_32.c
parent58083dade53cd434e134cd26ae5e89061f6de1ff (diff)
[POWERPC] Use ppc64 style list management for pci_controller on ppc32
Use the ppc64 style list management and allocation functions for pci_controllers. This makes the pci_controller structs just a bit more common between ppc32 & ppc64. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/pci_32.c')
-rw-r--r--arch/powerpc/kernel/pci_32.c61
1 files changed, 10 insertions, 51 deletions
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 3dd931ecce91..10d8a3542cf6 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -55,8 +55,7 @@ static u8* pci_to_OF_bus_map;
55 */ 55 */
56int pci_assign_all_buses; 56int pci_assign_all_buses;
57 57
58struct pci_controller* hose_head; 58LIST_HEAD(hose_list);
59struct pci_controller** hose_tail = &hose_head;
60 59
61static int pci_bus_count; 60static int pci_bus_count;
62 61
@@ -607,25 +606,6 @@ pcibios_enable_resources(struct pci_dev *dev, int mask)
607 return 0; 606 return 0;
608} 607}
609 608
610static int next_controller_index;
611
612struct pci_controller * __init
613pcibios_alloc_controller(struct device_node *dev)
614{
615 struct pci_controller *hose;
616
617 hose = (struct pci_controller *)alloc_bootmem(sizeof(*hose));
618 memset(hose, 0, sizeof(struct pci_controller));
619
620 *hose_tail = hose;
621 hose_tail = &hose->next;
622
623 hose->global_number = next_controller_index++;
624 hose->arch_data = dev;
625
626 return hose;
627}
628
629#ifdef CONFIG_PPC_OF 609#ifdef CONFIG_PPC_OF
630/* 610/*
631 * Functions below are used on OpenFirmware machines. 611 * Functions below are used on OpenFirmware machines.
@@ -671,7 +651,7 @@ void
671pcibios_make_OF_bus_map(void) 651pcibios_make_OF_bus_map(void)
672{ 652{
673 int i; 653 int i;
674 struct pci_controller* hose; 654 struct pci_controller *hose, *tmp;
675 struct property *map_prop; 655 struct property *map_prop;
676 struct device_node *dn; 656 struct device_node *dn;
677 657
@@ -688,7 +668,7 @@ pcibios_make_OF_bus_map(void)
688 pci_to_OF_bus_map[i] = 0xff; 668 pci_to_OF_bus_map[i] = 0xff;
689 669
690 /* For each hose, we begin searching bridges */ 670 /* For each hose, we begin searching bridges */
691 for(hose=hose_head; hose; hose=hose->next) { 671 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
692 struct device_node* node; 672 struct device_node* node;
693 node = (struct device_node *)hose->arch_data; 673 node = (struct device_node *)hose->arch_data;
694 if (!node) 674 if (!node)
@@ -819,27 +799,6 @@ pci_device_to_OF_node(struct pci_dev *dev)
819} 799}
820EXPORT_SYMBOL(pci_device_to_OF_node); 800EXPORT_SYMBOL(pci_device_to_OF_node);
821 801
822/* This routine is meant to be used early during boot, when the
823 * PCI bus numbers have not yet been assigned, and you need to
824 * issue PCI config cycles to an OF device.
825 * It could also be used to "fix" RTAS config cycles if you want
826 * to set pci_assign_all_buses to 1 and still use RTAS for PCI
827 * config cycles.
828 */
829struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
830{
831 if (!have_of)
832 return NULL;
833 while(node) {
834 struct pci_controller* hose;
835 for (hose=hose_head;hose;hose=hose->next)
836 if (hose->arch_data == node)
837 return hose;
838 node=node->parent;
839 }
840 return NULL;
841}
842
843static int 802static int
844find_OF_pci_device_filter(struct device_node* node, void* data) 803find_OF_pci_device_filter(struct device_node* node, void* data)
845{ 804{
@@ -1248,14 +1207,14 @@ pcibios_fixup_p2p_bridges(void)
1248static int __init 1207static int __init
1249pcibios_init(void) 1208pcibios_init(void)
1250{ 1209{
1251 struct pci_controller *hose; 1210 struct pci_controller *hose, *tmp;
1252 struct pci_bus *bus; 1211 struct pci_bus *bus;
1253 int next_busno; 1212 int next_busno = 0;
1254 1213
1255 printk(KERN_INFO "PCI: Probing PCI hardware\n"); 1214 printk(KERN_INFO "PCI: Probing PCI hardware\n");
1256 1215
1257 /* Scan all of the recorded PCI controllers. */ 1216 /* Scan all of the recorded PCI controllers. */
1258 for (next_busno = 0, hose = hose_head; hose; hose = hose->next) { 1217 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
1259 if (pci_assign_all_buses) 1218 if (pci_assign_all_buses)
1260 hose->first_busno = next_busno; 1219 hose->first_busno = next_busno;
1261 hose->last_busno = 0xff; 1220 hose->last_busno = 0xff;
@@ -1410,9 +1369,9 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
1410static struct pci_controller* 1369static struct pci_controller*
1411pci_bus_to_hose(int bus) 1370pci_bus_to_hose(int bus)
1412{ 1371{
1413 struct pci_controller* hose = hose_head; 1372 struct pci_controller *hose, *tmp;
1414 1373
1415 for (; hose; hose = hose->next) 1374 list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
1416 if (bus >= hose->first_busno && bus <= hose->last_busno) 1375 if (bus >= hose->first_busno && bus <= hose->last_busno)
1417 return hose; 1376 return hose;
1418 return NULL; 1377 return NULL;
@@ -1462,9 +1421,9 @@ long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
1462 1421
1463unsigned long pci_address_to_pio(phys_addr_t address) 1422unsigned long pci_address_to_pio(phys_addr_t address)
1464{ 1423{
1465 struct pci_controller* hose = hose_head; 1424 struct pci_controller *hose, *tmp;
1466 1425
1467 for (; hose; hose = hose->next) { 1426 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
1468 unsigned int size = hose->io_resource.end - 1427 unsigned int size = hose->io_resource.end -
1469 hose->io_resource.start + 1; 1428 hose->io_resource.start + 1;
1470 if (address >= hose->io_base_phys && 1429 if (address >= hose->io_base_phys &&