From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Date: Mon, 6 Jul 2020 01:40:32 +0100 Subject: [PATCH 01/15] net: sun8i-emac: Bail out on PHY error In-Reply-To: <20200706004046.20842-1-andre.przywara@arm.com> References: <20200706004046.20842-1-andre.przywara@arm.com> Message-ID: <20200706004046.20842-2-andre.przywara@arm.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de When phy_startup() returns with an error, because there is no link or the user interrupted the process, we shall stop the _start() routine and return with an error, instead of proceeding anyway. This fixes pointless operations when there is no Ethernet cable connected, for instance. Signed-off-by: Andre Przywara --- drivers/net/sun8i_emac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index e2b05ace8f..d6685e00dc 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -435,6 +435,7 @@ static int _sun8i_emac_eth_init(struct emac_eth_dev *priv, u8 *enetaddr) { u32 reg, v; int timeout = 100; + int ret; reg = readl((priv->mac_reg + EMAC_CTL1)); @@ -473,7 +474,9 @@ static int _sun8i_emac_eth_init(struct emac_eth_dev *priv, u8 *enetaddr) tx_descs_init(priv); /* PHY Start Up */ - phy_startup(priv->phydev); + ret = phy_startup(priv->phydev); + if (ret) + return ret; sun8i_adjust_link(priv, priv->phydev); -- 2.17.5