Skip to content
Snippets Groups Projects
Commit 1fc0d594 authored by Timur Tabi's avatar Timur Tabi Committed by Andy Fleming
Browse files

powerpc/85xx: fdt_set_phy_handle() should return an error code


fdt_set_phy_handle() makes several FDT calls that could fail, so it should
not be hiding these errors.

Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
parent fb365a8a
No related branches found
No related tags found
No related merge requests found
...@@ -37,31 +37,33 @@ ...@@ -37,31 +37,33 @@
* ... update that Ethernet node's phy-handle property to point to the * ... 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 * 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. * 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) const char *alias)
{ {
int offset, ph; int offset;
unsigned int ph;
const char *path; const char *path;
/* Get a path to the node that 'alias' points to */ /* Get a path to the node that 'alias' points to */
path = fdt_get_alias(fdt, alias); path = fdt_get_alias(fdt, alias);
if (path) { if (!path)
/* Get the offset of that node */ return -FDT_ERR_BADPATH;
int off = fdt_path_offset(fdt, path);
if (off > 0) /* Get the offset of that node */
ph = fdt_create_phandle(fdt, off); offset = fdt_path_offset(fdt, path);
else if (offset < 0)
return; return offset;
} else {
return ;
}
/* failed to create a phandle */ ph = fdt_create_phandle(fdt, offset);
if (ph <= 0) if (!ph)
return ; return -FDT_ERR_BADPHANDLE;
offset = fdt_node_offset_by_compat_reg(fdt, compat, addr); offset = fdt_node_offset_by_compat_reg(fdt, compat, addr);
if (offset > 0) if (offset < 0)
fdt_setprop(fdt, offset, "phy-handle", &ph, sizeof(ph)); return offset;
return fdt_setprop(fdt, offset, "phy-handle", &ph, sizeof(ph));
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef __FMAN_BOARD_HELPER__ #ifndef __FMAN_BOARD_HELPER__
#define __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); const char *alias);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment