aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powermac/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/platforms/powermac/pci.c')
-rw-r--r--arch/powerpc/platforms/powermac/pci.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 205d04471161..9923adc5248e 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -66,16 +66,16 @@ struct device_node *k2_skiplist[2];
66static int __init fixup_one_level_bus_range(struct device_node *node, int higher) 66static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
67{ 67{
68 for (; node != 0;node = node->sibling) { 68 for (; node != 0;node = node->sibling) {
69 int * bus_range; 69 const int * bus_range;
70 unsigned int *class_code; 70 const unsigned int *class_code;
71 int len; 71 int len;
72 72
73 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 73 /* For PCI<->PCI bridges or CardBus bridges, we go down */
74 class_code = (unsigned int *) get_property(node, "class-code", NULL); 74 class_code = get_property(node, "class-code", NULL);
75 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 75 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
76 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 76 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
77 continue; 77 continue;
78 bus_range = (int *) get_property(node, "bus-range", &len); 78 bus_range = get_property(node, "bus-range", &len);
79 if (bus_range != NULL && len > 2 * sizeof(int)) { 79 if (bus_range != NULL && len > 2 * sizeof(int)) {
80 if (bus_range[1] > higher) 80 if (bus_range[1] > higher)
81 higher = bus_range[1]; 81 higher = bus_range[1];
@@ -93,13 +93,15 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
93 */ 93 */
94static void __init fixup_bus_range(struct device_node *bridge) 94static void __init fixup_bus_range(struct device_node *bridge)
95{ 95{
96 int * bus_range; 96 int *bus_range, len;
97 int len; 97 struct property *prop;
98 98
99 /* Lookup the "bus-range" property for the hose */ 99 /* Lookup the "bus-range" property for the hose */
100 bus_range = (int *) get_property(bridge, "bus-range", &len); 100 prop = of_find_property(bridge, "bus-range", &len);
101 if (bus_range == NULL || len < 2 * sizeof(int)) 101 if (prop == NULL || prop->length < 2 * sizeof(int))
102 return; 102 return;
103
104 bus_range = (int *)prop->value;
103 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 105 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
104} 106}
105 107
@@ -237,7 +239,7 @@ static struct pci_ops macrisc_pci_ops =
237static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset) 239static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
238{ 240{
239 struct device_node *np; 241 struct device_node *np;
240 u32 *vendor, *device; 242 const u32 *vendor, *device;
241 243
242 if (offset >= 0x100) 244 if (offset >= 0x100)
243 return PCIBIOS_BAD_REGISTER_NUMBER; 245 return PCIBIOS_BAD_REGISTER_NUMBER;
@@ -245,8 +247,8 @@ static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
245 if (np == NULL) 247 if (np == NULL)
246 return PCIBIOS_DEVICE_NOT_FOUND; 248 return PCIBIOS_DEVICE_NOT_FOUND;
247 249
248 vendor = (u32 *)get_property(np, "vendor-id", NULL); 250 vendor = get_property(np, "vendor-id", NULL);
249 device = (u32 *)get_property(np, "device-id", NULL); 251 device = get_property(np, "device-id", NULL);
250 if (vendor == NULL || device == NULL) 252 if (vendor == NULL || device == NULL)
251 return PCIBIOS_DEVICE_NOT_FOUND; 253 return PCIBIOS_DEVICE_NOT_FOUND;
252 254
@@ -686,20 +688,21 @@ static void __init fixup_nec_usb2(void)
686 688
687 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) { 689 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) {
688 struct pci_controller *hose; 690 struct pci_controller *hose;
689 u32 data, *prop; 691 u32 data;
692 const u32 *prop;
690 u8 bus, devfn; 693 u8 bus, devfn;
691 694
692 prop = (u32 *)get_property(nec, "vendor-id", NULL); 695 prop = get_property(nec, "vendor-id", NULL);
693 if (prop == NULL) 696 if (prop == NULL)
694 continue; 697 continue;
695 if (0x1033 != *prop) 698 if (0x1033 != *prop)
696 continue; 699 continue;
697 prop = (u32 *)get_property(nec, "device-id", NULL); 700 prop = get_property(nec, "device-id", NULL);
698 if (prop == NULL) 701 if (prop == NULL)
699 continue; 702 continue;
700 if (0x0035 != *prop) 703 if (0x0035 != *prop)
701 continue; 704 continue;
702 prop = (u32 *)get_property(nec, "reg", NULL); 705 prop = get_property(nec, "reg", NULL);
703 if (prop == NULL) 706 if (prop == NULL)
704 continue; 707 continue;
705 devfn = (prop[0] >> 8) & 0xff; 708 devfn = (prop[0] >> 8) & 0xff;
@@ -898,7 +901,7 @@ static int __init add_bridge(struct device_node *dev)
898 struct pci_controller *hose; 901 struct pci_controller *hose;
899 struct resource rsrc; 902 struct resource rsrc;
900 char *disp_name; 903 char *disp_name;
901 int *bus_range; 904 const int *bus_range;
902 int primary = 1, has_address = 0; 905 int primary = 1, has_address = 0;
903 906
904 DBG("Adding PCI host bridge %s\n", dev->full_name); 907 DBG("Adding PCI host bridge %s\n", dev->full_name);
@@ -907,7 +910,7 @@ static int __init add_bridge(struct device_node *dev)
907 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 910 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
908 911
909 /* Get bus range if any */ 912 /* Get bus range if any */
910 bus_range = (int *) get_property(dev, "bus-range", &len); 913 bus_range = get_property(dev, "bus-range", &len);
911 if (bus_range == NULL || len < 2 * sizeof(int)) { 914 if (bus_range == NULL || len < 2 * sizeof(int)) {
912 printk(KERN_WARNING "Can't get bus-range for %s, assume" 915 printk(KERN_WARNING "Can't get bus-range for %s, assume"
913 " bus 0\n", dev->full_name); 916 " bus 0\n", dev->full_name);