public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: mdio: mdio-bcm-unimac: Correct rate fallback logic
@ 2025-07-29 21:31 Florian Fainelli
  2025-07-29 22:20 ` Andrew Lunn
  2025-07-30 14:33 ` Simon Horman
  0 siblings, 2 replies; 6+ messages in thread
From: Florian Fainelli @ 2025-07-29 21:31 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Doug Berger,
	Broadcom internal kernel review list, Andrew Lunn,
	Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jacob Keller, open list

In case the rate for the parent clock is zero, make sure that we still
fallback to using a fixed rate for the divider calculation, otherwise we
simply ignore the desired MDIO bus clock frequency which can prevent us
from interfacing with Ethernet PHYs properly.

Fixes: ee975351cf0c ("net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/net/mdio/mdio-bcm-unimac.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
index b6e30bdf5325..9c0a11316cfd 100644
--- a/drivers/net/mdio/mdio-bcm-unimac.c
+++ b/drivers/net/mdio/mdio-bcm-unimac.c
@@ -209,10 +209,9 @@ static int unimac_mdio_clk_set(struct unimac_mdio_priv *priv)
 	if (ret)
 		return ret;
 
-	if (!priv->clk)
+	rate = clk_get_rate(priv->clk);
+	if (!priv->clk || !rate)
 		rate = 250000000;
-	else
-		rate = clk_get_rate(priv->clk);
 
 	div = (rate / (2 * priv->clk_freq)) - 1;
 	if (div & ~MDIO_CLK_DIV_MASK) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-30 14:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-29 21:31 [PATCH net] net: mdio: mdio-bcm-unimac: Correct rate fallback logic Florian Fainelli
2025-07-29 22:20 ` Andrew Lunn
2025-07-29 22:22   ` Florian Fainelli
2025-07-29 22:44     ` Andrew Lunn
2025-07-29 22:50       ` Florian Fainelli
2025-07-30 14:33 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox