[PATCH] powerpc: merge code values for identifying platforms
[pandora-kernel.git] / arch / powerpc / kernel / prom.c
index 3675ef4..1bf3642 100644 (file)
@@ -48,9 +48,6 @@
 #include <asm/machdep.h>
 #include <asm/pSeries_reconfig.h>
 #include <asm/pci-bridge.h>
-#ifdef CONFIG_PPC64
-#include <asm/systemcfg.h>
-#endif
 
 #ifdef DEBUG
 #define DBG(fmt...) printk(KERN_ERR fmt)
@@ -391,7 +388,7 @@ static int __devinit finish_node_interrupts(struct device_node *np,
 
 #ifdef CONFIG_PPC64
                /* We offset irq numbers for the u3 MPIC by 128 in PowerMac */
-               if (systemcfg->platform == PLATFORM_POWERMAC && ic && ic->parent) {
+               if (_machine == PLATFORM_POWERMAC && ic && ic->parent) {
                        char *name = get_property(ic->parent, "name", NULL);
                        if (name && !strcmp(name, "u3"))
                                np->intrs[intrcount].line += 128;
@@ -1161,13 +1158,9 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
        prop = (u32 *)of_get_flat_dt_prop(node, "linux,platform", NULL);
        if (prop == NULL)
                return 0;
-#ifdef CONFIG_PPC64
-       systemcfg->platform = *prop;
-#else
 #ifdef CONFIG_PPC_MULTIPLATFORM
        _machine = *prop;
 #endif
-#endif
 
 #ifdef CONFIG_PPC64
        /* check if iommu is forced on or off */
@@ -1264,7 +1257,14 @@ static int __init early_init_dt_scan_memory(unsigned long node,
        unsigned long l;
 
        /* We are scanning "memory" nodes only */
-       if (type == NULL || strcmp(type, "memory") != 0)
+       if (type == NULL) {
+               /*
+                * The longtrail doesn't have a device_type on the
+                * /memory node, so look for the node called /memory@0.
+                */
+               if (depth != 1 || strcmp(uname, "memory@0") != 0)
+                       return 0;
+       } else if (strcmp(type, "memory") != 0)
                return 0;
 
        reg = (cell_t *)of_get_flat_dt_prop(node, "reg", &l);
@@ -1339,9 +1339,6 @@ void __init early_init_devtree(void *params)
        of_scan_flat_dt(early_init_dt_scan_memory, NULL);
        lmb_enforce_memory_limit(memory_limit);
        lmb_analyze();
-#ifdef CONFIG_PPC64
-       systemcfg->physicalMemorySize = lmb_phys_mem_size();
-#endif
        lmb_reserve(0, __pa(klimit));
 
        DBG("Phys. mem: %lx\n", lmb_phys_mem_size());
@@ -1908,7 +1905,7 @@ static int of_finish_dynamic_node(struct device_node *node,
        /* We don't support that function on PowerMac, at least
         * not yet
         */
-       if (systemcfg->platform == PLATFORM_POWERMAC)
+       if (_machine == PLATFORM_POWERMAC)
                return -ENODEV;
 
        /* fix up new node's linux_phandle field */
@@ -1974,14 +1971,31 @@ EXPORT_SYMBOL(get_property);
 /*
  * Add a property to a node
  */
-void prom_add_property(struct device_node* np, struct property* prop)
+int prom_add_property(struct device_node* np, struct property* prop)
 {
-       struct property **next = &np->properties;
+       struct property **next;
 
        prop->next = NULL;      
-       while (*next)
+       write_lock(&devtree_lock);
+       next = &np->properties;
+       while (*next) {
+               if (strcmp(prop->name, (*next)->name) == 0) {
+                       /* duplicate ! don't insert it */
+                       write_unlock(&devtree_lock);
+                       return -1;
+               }
                next = &(*next)->next;
+       }
        *next = prop;
+       write_unlock(&devtree_lock);
+
+#ifdef CONFIG_PROC_DEVICETREE
+       /* try to add to proc as well if it was initialized */
+       if (np->pde)
+               proc_device_tree_add_prop(np->pde, prop);
+#endif /* CONFIG_PROC_DEVICETREE */
+
+       return 0;
 }
 
 /* I quickly hacked that one, check against spec ! */