[U-Boot] [PATCH v4 3/5] drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index() fails

patrice.chotard at st.com patrice.chotard at st.com
Mon May 29 07:57:42 UTC 2017


From: Patrice Chotard <patrice.chotard at st.com>

phy->dev need to be set to NULL in case of generic_phy_get_by_index()
fails. Then phy->dev can be used to check if the phy is valid

Reported-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---

v4:	_ ensure that phy->dev is set to NULL in case of 
          generic_phy_get_by_index() fails

 drivers/phy/phy-uclass.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 0d8bef7..5edc80c 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -46,6 +46,8 @@ int generic_phy_get_by_index(struct udevice *dev, int index,
 	debug("%s(dev=%p, index=%d, phy=%p)\n", __func__, dev, index, phy);
 
 	assert(phy);
+	phy->dev = NULL;
+
 	ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
 					     "phys", "#phy-cells", 0, index,
 					     &args);
-- 
1.9.1



More information about the U-Boot mailing list