Skip to content

Commit

Permalink
net: dsa: move PHY setup on DSA MII bus to its own function
Browse files Browse the repository at this point in the history
In preparation for dealing with indirect reads and writes towards
certain PHY devices, move the code which deals with binding the PHY
device to the slave MII bus created by DSA to its own function:
dsa_slave_phy_connect().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Mar 11, 2015
1 parent 33d6737 commit c305c16
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,23 @@ static int dsa_slave_fixed_link_update(struct net_device *dev,
}

/* slave device setup *******************************************************/
static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
struct net_device *slave_dev)
{
struct dsa_switch *ds = p->parent;

p->phy = ds->slave_mii_bus->phy_map[p->port];
if (!p->phy)
return -ENODEV;

/* Use already configured phy mode */
p->phy_interface = p->phy->interface;
phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
p->phy_interface);

return 0;
}

static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
struct net_device *slave_dev)
{
Expand Down Expand Up @@ -662,14 +679,9 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
* MDIO bus instead
*/
if (!p->phy) {
p->phy = ds->slave_mii_bus->phy_map[p->port];
if (!p->phy)
return -ENODEV;

/* Use already configured phy mode */
p->phy_interface = p->phy->interface;
phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
p->phy_interface);
ret = dsa_slave_phy_connect(p, slave_dev);
if (ret)
return ret;
} else {
netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
p->phy->addr, p->phy->drv->name);
Expand Down

0 comments on commit c305c16

Please sign in to comment.