[POWERPC] Remove old interface find_type_devices
[powerpc.git] / arch / powerpc / kernel / prom.c
index 1fc732a..860c88b 100644 (file)
@@ -390,18 +390,19 @@ static unsigned long __init unflatten_dt_node(unsigned long mem,
                if (allnextpp) {
                        pp->name = "name";
                        pp->length = sz;
-                       pp->value = (unsigned char *)(pp + 1);
+                       pp->value = pp + 1;
                        *prev_pp = pp;
                        prev_pp = &pp->next;
                        memcpy(pp->value, ps, sz - 1);
                        ((char *)pp->value)[sz - 1] = 0;
-                       DBG("fixed up name for %s -> %s\n", pathp, pp->value);
+                       DBG("fixed up name for %s -> %s\n", pathp,
+                               (char *)pp->value);
                }
        }
        if (allnextpp) {
                *prev_pp = NULL;
-               np->name = get_property(np, "name", NULL);
-               np->type = get_property(np, "device_type", NULL);
+               np->name = of_get_property(np, "name", NULL);
+               np->type = of_get_property(np, "device_type", NULL);
 
                if (!np->name)
                        np->name = "<NULL>";
@@ -719,6 +720,7 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
                                            const char *uname, int depth, void *data)
 {
        unsigned long *lprop;
+       u32 *prop;
        unsigned long l;
        char *p;
 
@@ -760,6 +762,22 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
                crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
 
+#ifdef CONFIG_BLK_DEV_INITRD
+       DBG("Looking for initrd properties... ");
+       prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
+       if (prop) {
+               initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));
+               prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
+               if (prop) {
+                       initrd_end = (unsigned long)__va(of_read_ulong(prop, l/4));
+                       initrd_below_start_ok = 1;
+               } else {
+                       initrd_start = 0;
+               }
+       }
+       DBG("initrd_start=0x%lx  initrd_end=0x%lx\n", initrd_start, initrd_end);
+#endif /* CONFIG_BLK_DEV_INITRD */
+
        /* Retreive command line */
        p = of_get_flat_dt_prop(node, "bootargs", &l);
        if (p != NULL && l > 0)
@@ -926,6 +944,12 @@ static void __init early_reserve_mem(void)
        self_size = initial_boot_params->totalsize;
        lmb_reserve(self_base, self_size);
 
+#ifdef CONFIG_BLK_DEV_INITRD
+       /* then reserve the initrd, if any */
+       if (initrd_start && (initrd_end > initrd_start))
+               lmb_reserve(__pa(initrd_start), initrd_end - initrd_start);
+#endif /* CONFIG_BLK_DEV_INITRD */
+
 #ifdef CONFIG_PPC32
        /* 
         * Handle the case where we might be booting from an old kexec
@@ -954,9 +978,6 @@ static void __init early_reserve_mem(void)
                size = *(reserve_map++);
                if (size == 0)
                        break;
-               /* skip if the reservation is for the blob */
-               if (base == self_base && size == self_size)
-                       continue;
                DBG("reserving: %llx -> %llx\n", base, size);
                lmb_reserve(base, size);
        }
@@ -991,7 +1012,7 @@ void __init early_init_devtree(void *params)
        of_scan_flat_dt(early_init_dt_scan_memory, NULL);
 
        /* Save command line for /proc/cmdline and then parse parameters */
-       strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE);
+       strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
        parse_early_param();
 
        /* Reserve LMB regions used by kernel, initrd, dt, etc... */
@@ -1021,37 +1042,35 @@ void __init early_init_devtree(void *params)
 
 #undef printk
 
-int
-prom_n_addr_cells(struct device_node* np)
+int of_n_addr_cells(struct device_node* np)
 {
        const int *ip;
        do {
                if (np->parent)
                        np = np->parent;
-               ip = get_property(np, "#address-cells", NULL);
+               ip = of_get_property(np, "#address-cells", NULL);
                if (ip != NULL)
                        return *ip;
        } while (np->parent);
        /* No #address-cells property for the root node, default to 1 */
        return 1;
 }
-EXPORT_SYMBOL(prom_n_addr_cells);
+EXPORT_SYMBOL(of_n_addr_cells);
 
-int
-prom_n_size_cells(struct device_node* np)
+int of_n_size_cells(struct device_node* np)
 {
        const int* ip;
        do {
                if (np->parent)
                        np = np->parent;
-               ip = get_property(np, "#size-cells", NULL);
+               ip = of_get_property(np, "#size-cells", NULL);
                if (ip != NULL)
                        return *ip;
        } while (np->parent);
        /* No #size-cells property for the root node, default to 1 */
        return 1;
 }
-EXPORT_SYMBOL(prom_n_size_cells);
+EXPORT_SYMBOL(of_n_size_cells);
 
 /**
  * Construct and return a list of the device_nodes with a given name.
@@ -1072,51 +1091,16 @@ struct device_node *find_devices(const char *name)
 }
 EXPORT_SYMBOL(find_devices);
 
-/**
- * Construct and return a list of the device_nodes with a given type.
- */
-struct device_node *find_type_devices(const char *type)
-{
-       struct device_node *head, **prevp, *np;
-
-       prevp = &head;
-       for (np = allnodes; np != 0; np = np->allnext) {
-               if (np->type != 0 && strcasecmp(np->type, type) == 0) {
-                       *prevp = np;
-                       prevp = &np->next;
-               }
-       }
-       *prevp = NULL;
-       return head;
-}
-EXPORT_SYMBOL(find_type_devices);
-
-/**
- * Returns all nodes linked together
- */
-struct device_node *find_all_nodes(void)
-{
-       struct device_node *head, **prevp, *np;
-
-       prevp = &head;
-       for (np = allnodes; np != 0; np = np->allnext) {
-               *prevp = np;
-               prevp = &np->next;
-       }
-       *prevp = NULL;
-       return head;
-}
-EXPORT_SYMBOL(find_all_nodes);
-
 /** Checks if the given "compat" string matches one of the strings in
  * the device's "compatible" property
  */
-int device_is_compatible(const struct device_node *device, const char *compat)
+int of_device_is_compatible(const struct device_node *device,
+               const char *compat)
 {
        const char* cp;
        int cplen, l;
 
-       cp = get_property(device, "compatible", &cplen);
+       cp = of_get_property(device, "compatible", &cplen);
        if (cp == NULL)
                return 0;
        while (cplen > 0) {
@@ -1129,7 +1113,7 @@ int device_is_compatible(const struct device_node *device, const char *compat)
 
        return 0;
 }
-EXPORT_SYMBOL(device_is_compatible);
+EXPORT_SYMBOL(of_device_is_compatible);
 
 
 /**
@@ -1143,51 +1127,13 @@ int machine_is_compatible(const char *compat)
 
        root = of_find_node_by_path("/");
        if (root) {
-               rc = device_is_compatible(root, compat);
+               rc = of_device_is_compatible(root, compat);
                of_node_put(root);
        }
        return rc;
 }
 EXPORT_SYMBOL(machine_is_compatible);
 
-/**
- * Construct and return a list of the device_nodes with a given type
- * and compatible property.
- */
-struct device_node *find_compatible_devices(const char *type,
-                                           const char *compat)
-{
-       struct device_node *head, **prevp, *np;
-
-       prevp = &head;
-       for (np = allnodes; np != 0; np = np->allnext) {
-               if (type != NULL
-                   && !(np->type != 0 && strcasecmp(np->type, type) == 0))
-                       continue;
-               if (device_is_compatible(np, compat)) {
-                       *prevp = np;
-                       prevp = &np->next;
-               }
-       }
-       *prevp = NULL;
-       return head;
-}
-EXPORT_SYMBOL(find_compatible_devices);
-
-/**
- * Find the device_node with a given full_name.
- */
-struct device_node *find_path_device(const char *path)
-{
-       struct device_node *np;
-
-       for (np = allnodes; np != 0; np = np->allnext)
-               if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
-                       return np;
-       return NULL;
-}
-EXPORT_SYMBOL(find_path_device);
-
 /*******
  *
  * New implementation of the OF "find" APIs, return a refcounted
@@ -1221,8 +1167,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
                if (np->name != NULL && strcasecmp(np->name, name) == 0
                    && of_node_get(np))
                        break;
-       if (from)
-               of_node_put(from);
+       of_node_put(from);
        read_unlock(&devtree_lock);
        return np;
 }
@@ -1250,8 +1195,7 @@ struct device_node *of_find_node_by_type(struct device_node *from,
                if (np->type != 0 && strcasecmp(np->type, type) == 0
                    && of_node_get(np))
                        break;
-       if (from)
-               of_node_put(from);
+       of_node_put(from);
        read_unlock(&devtree_lock);
        return np;
 }
@@ -1282,11 +1226,10 @@ struct device_node *of_find_compatible_node(struct device_node *from,
                if (type != NULL
                    && !(np->type != 0 && strcasecmp(np->type, type) == 0))
                        continue;
-               if (device_is_compatible(np, compatible) && of_node_get(np))
+               if (of_device_is_compatible(np, compatible) && of_node_get(np))
                        break;
        }
-       if (from)
-               of_node_put(from);
+       of_node_put(from);
        read_unlock(&devtree_lock);
        return np;
 }
@@ -1329,8 +1272,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
        for (np = allnodes; np != 0; np = np->allnext)
                if (np->linux_phandle == handle)
                        break;
-       if (np)
-               of_node_get(np);
+       of_node_get(np);
        read_unlock(&devtree_lock);
        return np;
 }
@@ -1353,8 +1295,7 @@ struct device_node *of_find_all_nodes(struct device_node *prev)
        for (; np != 0; np = np->allnext)
                if (of_node_get(np))
                        break;
-       if (prev)
-               of_node_put(prev);
+       of_node_put(prev);
        read_unlock(&devtree_lock);
        return np;
 }
@@ -1399,8 +1340,7 @@ struct device_node *of_get_next_child(const struct device_node *node,
        for (; next != 0; next = next->sibling)
                if (of_node_get(next))
                        break;
-       if (prev)
-               of_node_put(prev);
+       of_node_put(prev);
        read_unlock(&devtree_lock);
        return next;
 }
@@ -1533,8 +1473,8 @@ static int of_finish_dynamic_node(struct device_node *node)
        int err = 0;
        const phandle *ibm_phandle;
 
-       node->name = get_property(node, "name", NULL);
-       node->type = get_property(node, "device_type", NULL);
+       node->name = of_get_property(node, "name", NULL);
+       node->type = of_get_property(node, "device_type", NULL);
 
        if (!parent) {
                err = -ENODEV;
@@ -1548,7 +1488,7 @@ static int of_finish_dynamic_node(struct device_node *node)
                return -ENODEV;
 
        /* fix up new node's linux_phandle field */
-       if ((ibm_phandle = get_property(node, "ibm,phandle", NULL)))
+       if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))
                node->linux_phandle = *ibm_phandle;
 
 out:
@@ -1605,18 +1545,19 @@ struct property *of_find_property(const struct device_node *np,
 
        return pp;
 }
+EXPORT_SYMBOL(of_find_property);
 
 /*
  * Find a property with a given name for a given node
  * and return the value.
  */
-const void *get_property(const struct device_node *np, const char *name,
+const void *of_get_property(const struct device_node *np, const char *name,
                         int *lenp)
 {
        struct property *pp = of_find_property(np,name,lenp);
        return pp ? pp->value : NULL;
 }
-EXPORT_SYMBOL(get_property);
+EXPORT_SYMBOL(of_get_property);
 
 /*
  * Add a property to a node
@@ -1747,10 +1688,10 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
                /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
                 * fallback to "reg" property and assume no threads
                 */
-               intserv = get_property(np, "ibm,ppc-interrupt-server#s",
+               intserv = of_get_property(np, "ibm,ppc-interrupt-server#s",
                                &plen);
                if (intserv == NULL) {
-                       const u32 *reg = get_property(np, "reg", NULL);
+                       const u32 *reg = of_get_property(np, "reg", NULL);
                        if (reg == NULL)
                                continue;
                        if (*reg == hardid) {