]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - arch/powerpc/cpu/mpc85xx/portals.c
Merge branch 'master' of git://www.denx.de/git/u-boot-mpc85xx
[karo-tx-uboot.git] / arch / powerpc / cpu / mpc85xx / portals.c
index d529095ee8c2884fee16508097fa753c6b8e0b62..672edde455ef030cce21e95884b5a71661f8240c 100644 (file)
@@ -128,24 +128,32 @@ static int fdt_qportal(void *blob, int off, int id, char *name,
 
        childoff = fdt_subnode_offset(blob, off, name);
        if (create) {
-               if (childoff <= 0)
-                       childoff = fdt_add_subnode(blob, off, name);
+               char handle[64], *p;
 
-               if (childoff > 0) {
-                       char handle[64], *p;
+               strncpy(handle, name, sizeof(handle));
+               p = strchr(handle, '@');
+               if (!strncmp(name, "fman", 4)) {
+                       *p = *(p + 1);
+                       p++;
+               }
+               *p = '\0';
 
-                       strncpy(handle, name, sizeof(handle));
-                       p = strchr(handle, '@');
-                       if (!strncmp(name, "fman", 4)) {
-                               *p = *(p + 1);
-                               p++;
-                       }
-                       *p = '\0';
+               dev_off = fdt_path_offset(blob, handle);
+               /* skip this node if alias is not found */
+               if (dev_off == -FDT_ERR_BADPATH)
+                       return 0;
+               if (dev_off < 0)
+                       return dev_off;
 
-                       dev_off = fdt_path_offset(blob, handle);
-                       if (dev_off < 0)
-                               return dev_off;
+               if (childoff <= 0)
+                       childoff = fdt_add_subnode(blob, off, name);
 
+               /* need to update the dev_off after adding a subnode */
+               dev_off = fdt_path_offset(blob, handle);
+               if (dev_off < 0)
+                       return dev_off;
+
+               if (childoff > 0) {
                        dev_handle = fdt_get_phandle(blob, dev_off);
                        if (dev_handle <= 0) {
                                dev_handle = fdt_alloc_phandle(blob);