summaryrefslogtreecommitdiff
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorMaxime Chevallier <maxime.chevallier@bootlin.com>2023-12-21 19:00:37 +0100
committerDavid S. Miller <davem@davemloft.net>2024-01-01 18:38:56 +0000
commitdedd702a35793ab462fce4c737eeba0badf9718e (patch)
tree6e8852ae74ba33123aec0b981887511206943053 /drivers/net/phy
parent034fcc210349b873ece7356905be5c6ca11eef2a (diff)
downloadlwn-dedd702a35793ab462fce4c737eeba0badf9718e.tar.gz
lwn-dedd702a35793ab462fce4c737eeba0badf9718e.zip
net: sfp: Add helper to return the SFP bus name
Knowing the bus name is helpful when we want to expose the link topology to userspace, add a helper to return the SFP bus name. Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/sfp-bus.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index 3a86c41e1235..fb1c102714b5 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -859,3 +859,14 @@ void sfp_unregister_socket(struct sfp_bus *bus)
sfp_bus_put(bus);
}
EXPORT_SYMBOL_GPL(sfp_unregister_socket);
+
+const char *sfp_get_name(struct sfp_bus *bus)
+{
+ ASSERT_RTNL();
+
+ if (bus->sfp_dev)
+ return dev_name(bus->sfp_dev);
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(sfp_get_name);