From: patrice.chotard at st.com Date: Mon, 29 May 2017 09:57:42 +0200 Subject: [U-Boot] [PATCH v4 3/5] drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index() fails In-Reply-To: <1496044664-13297-1-git-send-email-patrice.chotard@st.com> References: <1496044664-13297-1-git-send-email-patrice.chotard@st.com> Message-ID: <1496044664-13297-4-git-send-email-patrice.chotard@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Patrice Chotard 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 Signed-off-by: Patrice Chotard --- 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