[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQSz_euUg0Ja8ZaH@stanley.mountain>
Date: Fri, 31 Oct 2025 16:05:01 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Tristram Ha <tristram.ha@...rochip.com>,
Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
Cc: Woojung Huh <woojung.huh@...rochip.com>, UNGLinuxDriver@...rochip.com,
Andrew Lunn <andrew@...n.ch>, Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH net] net: dsa: microchip: Fix a link check in
ksz9477_pcs_read()
The BMSR_LSTATUS define is 0x4 but the "p->phydev.link" variable
is a 1 bit bitfield in a u32. Since 4 doesn't fit in 0-1 range
it means that ".link" is always set to false. Add a !! to fix
this.
Fixes: e8c35bfce4c1 ("net: dsa: microchip: Add SGMII port support to KSZ9477 switch")
Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
---
This is from a new static checker warning Harshit and I wrote. Untested.
drivers/net/dsa/microchip/ksz9477.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index d747ea1c41a7..cf67d6377719 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -244,7 +244,7 @@ static int ksz9477_pcs_read(struct mii_bus *bus, int phy, int mmd, int reg)
p->phydev.link = 0;
}
} else if (reg == MII_BMSR) {
- p->phydev.link = (val & BMSR_LSTATUS);
+ p->phydev.link = !!(val & BMSR_LSTATUS);
}
}
--
2.51.0
Powered by blists - more mailing lists