[PATCH net-next 2/2] net: stmmac: Check stmmac_hw_setup() in stmmac_resume()

Tiezhu Yang posted 2 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH net-next 2/2] net: stmmac: Check stmmac_hw_setup() in stmmac_resume()
Posted by Tiezhu Yang 2 months, 2 weeks ago
stmmac_hw_setup() may return 0 on success and an appropriate negative
integer as defined in errno.h file on failure, just check it and then
return early if failed in stmmac_resume().

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b948df1bff9a..2bfacab71ab9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7975,7 +7975,14 @@ int stmmac_resume(struct device *dev)
 	stmmac_free_tx_skbufs(priv);
 	stmmac_clear_descriptors(priv, &priv->dma_conf);
 
-	stmmac_hw_setup(ndev, false);
+	ret = stmmac_hw_setup(ndev, false);
+	if (ret < 0) {
+		netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
+		mutex_unlock(&priv->lock);
+		rtnl_unlock();
+		return ret;
+	}
+
 	stmmac_init_coalesce(priv);
 	phylink_rx_clk_stop_block(priv->phylink);
 	stmmac_set_rx_mode(ndev);
-- 
2.42.0
Re: [PATCH net-next 2/2] net: stmmac: Check stmmac_hw_setup() in stmmac_resume()
Posted by Huacai Chen 2 months, 2 weeks ago
On Tue, Jul 22, 2025 at 2:27 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> stmmac_hw_setup() may return 0 on success and an appropriate negative
> integer as defined in errno.h file on failure, just check it and then
> return early if failed in stmmac_resume().
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index b948df1bff9a..2bfacab71ab9 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -7975,7 +7975,14 @@ int stmmac_resume(struct device *dev)
>         stmmac_free_tx_skbufs(priv);
>         stmmac_clear_descriptors(priv, &priv->dma_conf);
>
> -       stmmac_hw_setup(ndev, false);
> +       ret = stmmac_hw_setup(ndev, false);
> +       if (ret < 0) {
> +               netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
> +               mutex_unlock(&priv->lock);
> +               rtnl_unlock();
> +               return ret;
> +       }
> +
>         stmmac_init_coalesce(priv);
>         phylink_rx_clk_stop_block(priv->phylink);
>         stmmac_set_rx_mode(ndev);
> --
> 2.42.0
>
>
Re: [PATCH net-next 2/2] net: stmmac: Check stmmac_hw_setup() in stmmac_resume()
Posted by Maxime Chevallier 2 months, 2 weeks ago
On Tue, 22 Jul 2025 14:27:16 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

> stmmac_hw_setup() may return 0 on success and an appropriate negative
> integer as defined in errno.h file on failure, just check it and then
> return early if failed in stmmac_resume().
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime