]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
powerpc/85xx: fdt_set_phy_handle() should return an error code
authorTimur Tabi <timur@freescale.com>
Fri, 4 May 2012 12:21:28 +0000 (12:21 +0000)
committerAndy Fleming <afleming@freescale.com>
Fri, 6 Jul 2012 22:30:32 +0000 (17:30 -0500)
fdt_set_phy_handle() makes several FDT calls that could fail, so it should
not be hiding these errors.

Signed-off-by: Timur Tabi <timur@freescale.com>
board/freescale/common/fman.c
board/freescale/common/fman.h

index 8a55fde6f1c279cf3cc690d62b083f435aff877d..6ddf816201219f14efc37fa83c907d54f8ee5f3e 100644 (file)
  * ... update that Ethernet node's phy-handle property to point to the
  * ethernet-phy node.  This is how we link an Ethernet node to its PHY, so each
  * PHY in a virtual MDIO node must have an alias.
+ *
+ * Returns 0 on success, or a negative FDT error code on error.
  */
-void fdt_set_phy_handle(void *fdt, char *compat, phys_addr_t addr,
+int fdt_set_phy_handle(void *fdt, char *compat, phys_addr_t addr,
                        const char *alias)
 {
-       int offset, ph;
+       int offset;
+       unsigned int ph;
        const char *path;
 
        /* Get a path to the node that 'alias' points to */
        path = fdt_get_alias(fdt, alias);
-       if (path) {
-               /* Get the offset of that node */
-               int off = fdt_path_offset(fdt, path);
-               if (off > 0)
-                       ph = fdt_create_phandle(fdt, off);
-               else
-                       return;
-       } else {
-               return ;
-       }
+       if (!path)
+               return -FDT_ERR_BADPATH;
+
+       /* Get the offset of that node */
+       offset = fdt_path_offset(fdt, path);
+       if (offset < 0)
+               return offset;
 
-       /* failed to create a phandle */
-       if (ph <= 0)
-               return ;
+       ph = fdt_create_phandle(fdt, offset);
+       if (!ph)
+               return -FDT_ERR_BADPHANDLE;
 
        offset = fdt_node_offset_by_compat_reg(fdt, compat, addr);
-       if (offset > 0)
-               fdt_setprop(fdt, offset, "phy-handle", &ph, sizeof(ph));
+       if (offset < 0)
+               return offset;
+
+       return fdt_setprop(fdt, offset, "phy-handle", &ph, sizeof(ph));
 }
index 19ef7c4fbc41302d4d46fac273045c6f7381df30..d39ef080c1f7eeb7159b828293a0d81e23431daa 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef __FMAN_BOARD_HELPER__
 #define __FMAN_BOARD_HELPER__
 
-void fdt_set_phy_handle(void *fdt, char *compat, phys_addr_t addr,
+int fdt_set_phy_handle(void *fdt, char *compat, phys_addr_t addr,
                        const char *alias);
 
 #endif