History

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.

Maxime Chevallier committed 2 years ago

Commit dedd7021 parent 034fcc22 files · +17 −0Browse files

Unified · Split

2 files
  1. drivers/net/phy/sfp-bus.c +11 −0
  2. include/linux/sfp.h +6 −0
drivers/net/phy/sfp-bus.c+11−0
@@ -859,3 +859,14 @@ void sfp_unregister_socket(struct sfp_bus *bus) · 858 unmodified lines
859859 sfp_bus_put(bus);
860860 }
861861 EXPORT_SYMBOL_GPL(sfp_unregister_socket);
862+
863+const char *sfp_get_name(struct sfp_bus *bus)
864+{
865+ ASSERT_RTNL();
866+
867+ if (bus->sfp_dev)
868+ return dev_name(bus->sfp_dev);
869+
870+ return NULL;
871+}
872+EXPORT_SYMBOL_GPL(sfp_get_name);
include/linux/sfp.h+6−0
@@ -570,6 +570,7 @@ struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode); · 569 unmodified lines
570570 int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
571571 const struct sfp_upstream_ops *ops);
572572 void sfp_bus_del_upstream(struct sfp_bus *bus);
573+const char *sfp_get_name(struct sfp_bus *bus);
573574 #else
574575 static inline int sfp_parse_port(struct sfp_bus *bus,
575576 const struct sfp_eeprom_id *id,
@@ -648,6 +649,11 @@ static inline int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, · 72 unmodified lines
648649 static inline void sfp_bus_del_upstream(struct sfp_bus *bus)
649650 {
650651 }
652+
653+static inline const char *sfp_get_name(struct sfp_bus *bus)
654+{
655+ return NULL;
656+}
651657 #endif
652658
653659 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t