[PATCH net-next v3 1/2] net: dsa: yt921x: Return early for failed MIB read

David Yang posted 2 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH net-next v3 1/2] net: dsa: yt921x: Return early for failed MIB read
Posted by David Yang 1 month, 1 week ago
This is a prerequisite for another patch. It does not change the
behavior on the success path.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/net/dsa/yt921x.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c
index 98e8915dd6c2..a968a3fb56f8 100644
--- a/drivers/net/dsa/yt921x.c
+++ b/drivers/net/dsa/yt921x.c
@@ -711,6 +711,12 @@ static int yt921x_read_mib(struct yt921x_priv *priv, int port)
 		WRITE_ONCE(*valp, val);
 	}
 
+	if (res) {
+		dev_err(dev, "Failed to %s port %d: %i\n", "read stats for",
+			port, res);
+		return res;
+	}
+
 	pp->rx_frames = mib->rx_64byte + mib->rx_65_127byte +
 			mib->rx_128_255byte + mib->rx_256_511byte +
 			mib->rx_512_1023byte + mib->rx_1024_1518byte +
@@ -720,10 +726,7 @@ static int yt921x_read_mib(struct yt921x_priv *priv, int port)
 			mib->tx_512_1023byte + mib->tx_1024_1518byte +
 			mib->tx_jumbo;
 
-	if (res)
-		dev_err(dev, "Failed to %s port %d: %i\n", "read stats for",
-			port, res);
-	return res;
+	return 0;
 }
 
 static void yt921x_poll_mib(struct work_struct *work)
-- 
2.51.0
Re: [PATCH net-next v3 1/2] net: dsa: yt921x: Return early for failed MIB read
Posted by Simon Horman 1 month ago
On Fri, Feb 27, 2026 at 09:50:53PM +0800, David Yang wrote:
> This is a prerequisite for another patch. It does not change the
> behavior on the success path.

I think that you need to discuss what change this introduces
on the error path. And the AI generated review did too.

Looking a bit more, it seems that Jakub offered feedback on
this in his review of v1 [1]. I do see that the commit message
has been updated. And is strictly correct. But I think the intention
of Jakub's feedback was that the behaviour is changed should be described.

[1] https://lore.kernel.org/netdev/20260205050813.2421675-1-kuba@kernel.org/

> 
> Signed-off-by: David Yang <mmyangfl@gmail.com>

-- 
pw-bot: changes-requested.