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
859 sfp_bus_put(bus);859 sfp_bus_put(bus);
860}860}
861EXPORT_SYMBOL_GPL(sfp_unregister_socket);861EXPORT_SYMBOL_GPL(sfp_unregister_socket);
862
863const 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}
872EXPORT_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
570int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,570int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
571 const struct sfp_upstream_ops *ops);571 const struct sfp_upstream_ops *ops);
572void sfp_bus_del_upstream(struct sfp_bus *bus);572void sfp_bus_del_upstream(struct sfp_bus *bus);
573const char *sfp_get_name(struct sfp_bus *bus);
573#else574#else
574static inline int sfp_parse_port(struct sfp_bus *bus,575static inline int sfp_parse_port(struct sfp_bus *bus,
575 const struct sfp_eeprom_id *id,576 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
648static inline void sfp_bus_del_upstream(struct sfp_bus *bus)649static inline void sfp_bus_del_upstream(struct sfp_bus *bus)
649{650{
650}651}
652
653static inline const char *sfp_get_name(struct sfp_bus *bus)
654{
655 return NULL;
656}
651#endif657#endif
652 658
653#endif659#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