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.
Unified · Split
| @@ -859,3 +859,14 @@ void sfp_unregister_socket(struct sfp_bus *bus) · 858 unmodified lines | ||
| 859 | 859 | sfp_bus_put(bus); |
| 860 | 860 | } |
| 861 | 861 | 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); | |
| @@ -570,6 +570,7 @@ struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode); · 569 unmodified lines | ||
| 570 | 570 | int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, |
| 571 | 571 | const struct sfp_upstream_ops *ops); |
| 572 | 572 | void sfp_bus_del_upstream(struct sfp_bus *bus); |
| 573 | +const char *sfp_get_name(struct sfp_bus *bus); | |
| 573 | 574 | #else |
| 574 | 575 | static inline int sfp_parse_port(struct sfp_bus *bus, |
| 575 | 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 | ||
| 648 | 649 | static inline void sfp_bus_del_upstream(struct sfp_bus *bus) |
| 649 | 650 | { |
| 650 | 651 | } |
| 652 | + | |
| 653 | +static inline const char *sfp_get_name(struct sfp_bus *bus) | |
| 654 | +{ | |
| 655 | + return NULL; | |
| 656 | +} | |
| 651 | 657 | #endif |
| 652 | 658 | |
| 653 | 659 | #endif |