Add generic sys_ipc wrapper
[safe/jmp/linux-2.6] / arch / powerpc / kernel / rtas_pci.c
index 99aaae3..54e66da 100644 (file)
@@ -56,21 +56,6 @@ static inline int config_access_valid(struct pci_dn *dn, int where)
        return 0;
 }
 
-static int of_device_available(struct device_node * dn)
-{
-        const char *status;
-
-        status = of_get_property(dn, "status", NULL);
-
-        if (!status)
-                return 1;
-
-        if (!strcmp(status, "okay"))
-                return 1;
-
-        return 0;
-}
-
 int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
 {
        int returnval = -1;
@@ -108,16 +93,13 @@ static int rtas_pci_read_config(struct pci_bus *bus,
 {
        struct device_node *busdn, *dn;
 
-       if (bus->self)
-               busdn = pci_device_to_OF_node(bus->self);
-       else
-               busdn = bus->sysdata;   /* must be a phb */
+       busdn = pci_bus_to_OF_node(bus);
 
        /* Search only direct children of the bus */
        for (dn = busdn->child; dn; dn = dn->sibling) {
                struct pci_dn *pdn = PCI_DN(dn);
                if (pdn && pdn->devfn == devfn
-                   && of_device_available(dn))
+                   && of_device_is_available(dn))
                        return rtas_read_config(pdn, where, size, val);
        }
 
@@ -155,27 +137,24 @@ static int rtas_pci_write_config(struct pci_bus *bus,
 {
        struct device_node *busdn, *dn;
 
-       if (bus->self)
-               busdn = pci_device_to_OF_node(bus->self);
-       else
-               busdn = bus->sysdata;   /* must be a phb */
+       busdn = pci_bus_to_OF_node(bus);
 
        /* Search only direct children of the bus */
        for (dn = busdn->child; dn; dn = dn->sibling) {
                struct pci_dn *pdn = PCI_DN(dn);
                if (pdn && pdn->devfn == devfn
-                   && of_device_available(dn))
+                   && of_device_is_available(dn))
                        return rtas_write_config(pdn, where, size, val);
        }
        return PCIBIOS_DEVICE_NOT_FOUND;
 }
 
-struct pci_ops rtas_pci_ops = {
+static struct pci_ops rtas_pci_ops = {
        .read = rtas_pci_read_config,
        .write = rtas_pci_write_config,
 };
 
-int is_python(struct device_node *dev)
+static int is_python(struct device_node *dev)
 {
        const char *model = of_get_property(dev, "model", NULL);
 
@@ -280,10 +259,7 @@ void __init find_and_init_phbs(void)
        struct pci_controller *phb;
        struct device_node *root = of_find_node_by_path("/");
 
-       for (node = of_get_next_child(root, NULL);
-            node != NULL;
-            node = of_get_next_child(root, node)) {
-
+       for_each_child_of_node(root, node) {
                if (node->type == NULL || (strcmp(node->type, "pci") != 0 &&
                                           strcmp(node->type, "pciex") != 0))
                        continue;
@@ -319,51 +295,3 @@ void __init find_and_init_phbs(void)
 #endif /* CONFIG_PPC32 */
        }
 }
-
-/* RPA-specific bits for removing PHBs */
-int pcibios_remove_root_bus(struct pci_controller *phb)
-{
-       struct pci_bus *b = phb->bus;
-       struct resource *res;
-       int rc, i;
-
-       res = b->resource[0];
-       if (!res->flags) {
-               printk(KERN_ERR "%s: no IO resource for PHB %s\n", __FUNCTION__,
-                               b->name);
-               return 1;
-       }
-
-       rc = pcibios_unmap_io_space(b);
-       if (rc) {
-               printk(KERN_ERR "%s: failed to unmap IO on bus %s\n",
-                       __FUNCTION__, b->name);
-               return 1;
-       }
-
-       if (release_resource(res)) {
-               printk(KERN_ERR "%s: failed to release IO on bus %s\n",
-                               __FUNCTION__, b->name);
-               return 1;
-       }
-
-       for (i = 1; i < 3; ++i) {
-               res = b->resource[i];
-               if (!res->flags && i == 0) {
-                       printk(KERN_ERR "%s: no MEM resource for PHB %s\n",
-                               __FUNCTION__, b->name);
-                       return 1;
-               }
-               if (res->flags && release_resource(res)) {
-                       printk(KERN_ERR
-                              "%s: failed to release IO %d on bus %s\n",
-                               __FUNCTION__, i, b->name);
-                       return 1;
-               }
-       }
-
-       pcibios_free_controller(phb);
-
-       return 0;
-}
-EXPORT_SYMBOL(pcibios_remove_root_bus);