phy: Add API for {un}registering an mdio device to a bus.
Rather than have drivers directly manipulate the mii_bus structure, provide and API for registering and unregistering devices on an MDIO bus, and performing lookups. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
801a8ef54e
commit
7f854420fb
@@ -1406,7 +1406,7 @@ static void tg3_mdio_config_5785(struct tg3 *tp)
|
||||
u32 val;
|
||||
struct phy_device *phydev;
|
||||
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) {
|
||||
case PHY_ID_BCM50610:
|
||||
case PHY_ID_BCM50610M:
|
||||
@@ -1554,7 +1554,7 @@ static int tg3_mdio_init(struct tg3 *tp)
|
||||
return i;
|
||||
}
|
||||
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
|
||||
if (!phydev || !phydev->drv) {
|
||||
dev_warn(&tp->pdev->dev, "No PHY devices\n");
|
||||
@@ -1964,7 +1964,7 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv)
|
||||
u32 old_tx_mode = tp->tx_mode;
|
||||
|
||||
if (tg3_flag(tp, USE_PHYLIB))
|
||||
autoneg = tp->mdio_bus->phy_map[tp->phy_addr]->autoneg;
|
||||
autoneg = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)->autoneg;
|
||||
else
|
||||
autoneg = tp->link_config.autoneg;
|
||||
|
||||
@@ -2000,7 +2000,7 @@ static void tg3_adjust_link(struct net_device *dev)
|
||||
u8 oldflowctrl, linkmesg = 0;
|
||||
u32 mac_mode, lcl_adv, rmt_adv;
|
||||
struct tg3 *tp = netdev_priv(dev);
|
||||
struct phy_device *phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
struct phy_device *phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
|
||||
spin_lock_bh(&tp->lock);
|
||||
|
||||
@@ -2089,7 +2089,7 @@ static int tg3_phy_init(struct tg3 *tp)
|
||||
/* Bring the PHY back to a known state. */
|
||||
tg3_bmcr_reset(tp);
|
||||
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
|
||||
/* Attach the MAC to the PHY. */
|
||||
phydev = phy_connect(tp->dev, phydev_name(phydev),
|
||||
@@ -2116,7 +2116,7 @@ static int tg3_phy_init(struct tg3 *tp)
|
||||
SUPPORTED_Asym_Pause);
|
||||
break;
|
||||
default:
|
||||
phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
|
||||
phy_disconnect(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -2136,7 +2136,7 @@ static void tg3_phy_start(struct tg3 *tp)
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
|
||||
return;
|
||||
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
|
||||
if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) {
|
||||
tp->phy_flags &= ~TG3_PHYFLG_IS_LOW_POWER;
|
||||
@@ -2156,13 +2156,13 @@ static void tg3_phy_stop(struct tg3 *tp)
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
|
||||
return;
|
||||
|
||||
phy_stop(tp->mdio_bus->phy_map[tp->phy_addr]);
|
||||
phy_stop(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr));
|
||||
}
|
||||
|
||||
static void tg3_phy_fini(struct tg3 *tp)
|
||||
{
|
||||
if (tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) {
|
||||
phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]);
|
||||
phy_disconnect(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr));
|
||||
tp->phy_flags &= ~TG3_PHYFLG_IS_CONNECTED;
|
||||
}
|
||||
}
|
||||
@@ -4046,7 +4046,7 @@ static int tg3_power_down_prepare(struct tg3 *tp)
|
||||
struct phy_device *phydev;
|
||||
u32 phyid, advertising;
|
||||
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
|
||||
tp->phy_flags |= TG3_PHYFLG_IS_LOW_POWER;
|
||||
|
||||
@@ -12074,7 +12074,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
|
||||
struct phy_device *phydev;
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
|
||||
return -EAGAIN;
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
return phy_ethtool_gset(phydev, cmd);
|
||||
}
|
||||
|
||||
@@ -12141,7 +12141,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
|
||||
struct phy_device *phydev;
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
|
||||
return -EAGAIN;
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
return phy_ethtool_sset(phydev, cmd);
|
||||
}
|
||||
|
||||
@@ -12296,7 +12296,7 @@ static int tg3_nway_reset(struct net_device *dev)
|
||||
if (tg3_flag(tp, USE_PHYLIB)) {
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
|
||||
return -EAGAIN;
|
||||
r = phy_start_aneg(tp->mdio_bus->phy_map[tp->phy_addr]);
|
||||
r = phy_start_aneg(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr));
|
||||
} else {
|
||||
u32 bmcr;
|
||||
|
||||
@@ -12414,7 +12414,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam
|
||||
u32 newadv;
|
||||
struct phy_device *phydev;
|
||||
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
|
||||
if (!(phydev->supported & SUPPORTED_Pause) ||
|
||||
(!(phydev->supported & SUPPORTED_Asym_Pause) &&
|
||||
@@ -13924,7 +13924,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||
struct phy_device *phydev;
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED))
|
||||
return -EAGAIN;
|
||||
phydev = tp->mdio_bus->phy_map[tp->phy_addr];
|
||||
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
|
||||
return phy_mii_ioctl(phydev, ifr, cmd);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user