Skip to content

Commit 9c5625f

Browse files
minimaxwelldavem330
authored andcommitted
net: sfp: pass the phy_device when disconnecting an sfp module's PHY
Pass the phy_device as a parameter to the sfp upstream .disconnect_phy operation. This is preparatory work to help track phy devices across a net_device's link. Signed-off-by: Maxime Chevallier <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02018c5 commit 9c5625f

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

drivers/net/phy/phy_device.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ static void phy_mdio_device_remove(struct mdio_device *mdiodev)
266266

267267
static struct phy_driver genphy_driver;
268268

269+
static struct phy_link_topology *phy_get_link_topology(struct phy_device *phydev)
270+
{
271+
if (phydev->attached_dev)
272+
return &phydev->attached_dev->link_topo;
273+
274+
return NULL;
275+
}
276+
269277
static LIST_HEAD(phy_fixup_list);
270278
static DEFINE_MUTEX(phy_fixup_lock);
271279

drivers/net/phy/phylink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3319,7 +3319,8 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
33193319
return ret;
33203320
}
33213321

3322-
static void phylink_sfp_disconnect_phy(void *upstream)
3322+
static void phylink_sfp_disconnect_phy(void *upstream,
3323+
struct phy_device *phydev)
33233324
{
33243325
phylink_disconnect_phy(upstream);
33253326
}

drivers/net/phy/sfp-bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ static void sfp_unregister_bus(struct sfp_bus *bus)
486486
bus->socket_ops->stop(bus->sfp);
487487
bus->socket_ops->detach(bus->sfp);
488488
if (bus->phydev && ops && ops->disconnect_phy)
489-
ops->disconnect_phy(bus->upstream);
489+
ops->disconnect_phy(bus->upstream, bus->phydev);
490490
}
491491
bus->registered = false;
492492
}
@@ -742,7 +742,7 @@ void sfp_remove_phy(struct sfp_bus *bus)
742742
const struct sfp_upstream_ops *ops = sfp_get_upstream_ops(bus);
743743

744744
if (ops && ops->disconnect_phy)
745-
ops->disconnect_phy(bus->upstream);
745+
ops->disconnect_phy(bus->upstream, bus->phydev);
746746
bus->phydev = NULL;
747747
}
748748
EXPORT_SYMBOL_GPL(sfp_remove_phy);

include/linux/sfp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ struct sfp_upstream_ops {
544544
void (*link_down)(void *priv);
545545
void (*link_up)(void *priv);
546546
int (*connect_phy)(void *priv, struct phy_device *);
547-
void (*disconnect_phy)(void *priv);
547+
void (*disconnect_phy)(void *priv, struct phy_device *);
548548
};
549549

550550
#if IS_ENABLED(CONFIG_SFP)

0 commit comments

Comments
 (0)