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 | sfp_bus_put(bus); | 859 | sfp_bus_put(bus); |
| 860 | } | 860 | } |
| 861 | EXPORT_SYMBOL_GPL(sfp_unregister_socket); | 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 | int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, | 570 | int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream, |
| 571 | const struct sfp_upstream_ops *ops); | 571 | const struct sfp_upstream_ops *ops); |
| 572 | void sfp_bus_del_upstream(struct sfp_bus *bus); | 572 | void sfp_bus_del_upstream(struct sfp_bus *bus); |
| 573 | const char *sfp_get_name(struct sfp_bus *bus); | ||
| 573 | #else | 574 | #else |
| 574 | static inline int sfp_parse_port(struct sfp_bus *bus, | 575 | static 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 | |||
| 648 | static inline void sfp_bus_del_upstream(struct sfp_bus *bus) | 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 | #endif | 657 | #endif |
| 652 | 658 | ||
| 653 | #endif | 659 | #endif |