Skip to contentSkip to conversation

r8169: don't scan PHY addresses > 0

PATCH Superseded Heiner Kallweit 2 participants 2 messages Feb 3, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 r8169: don't scan PHY addresses > 0

The PHY address is a dummy anyway, because r8169 PHY access registers don't support a PHY address. Therefore scan address 0 only, this saves some cpu cycles and allows to remove two checks.

---
 drivers/net/ethernet/realtek/r8169_main.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -6
index 5a5eba49c..a65a6cbe9 100644
@@ -5180,9 +5180,6 @@ static int r8169_mdio_read_reg(struct mii_bus *mii_bus, int phyaddr, int phyreg)
 {
 	struct rtl8169_private *tp = mii_bus->priv;
 
-	if (phyaddr > 0)
-		return -ENODEV;
-
 	return rtl_readphy(tp, phyreg);
 }
 
@@ -5191,9 +5188,6 @@ static int r8169_mdio_write_reg(struct mii_bus *mii_bus, int phyaddr,
 {
 	struct rtl8169_private *tp = mii_bus->priv;
 
-	if (phyaddr > 0)
-		return -ENODEV;
-
 	rtl_writephy(tp, phyreg, val);
 
 	return 0;
@@ -5222,6 +5216,7 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
 	new_bus->priv = tp;
 	new_bus->parent = &pdev->dev;
 	new_bus->irq[0] = PHY_MAC_INTERRUPT;
+	new_bus->phy_mask = GENMASK(31, 1);
 	snprintf(new_bus->id, MII_BUS_ID_SIZE, "r8169-%x-%x",
 		 pci_domain_nr(pdev->bus), pci_dev_id(pdev));
 
Signature · 1 line
2.48.1
#1 lore raw
Quoted 3 lines · Heiner Kallweit

The PHY address is a dummy anyway, because r8169 PHY access registers don't support a PHY address. Therefore scan address 0 only, this saves some cpu cycles and allows to remove two checks.

The IOCTL interface allows you to access any address on the bus. So you should probably keep the tests. Setting phy_mask however is a good idea.

Andrew