Skip to content

Commit

Permalink
net: sfp: Add helper to return the SFP bus name
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Maxime Chevallier authored and David S. Miller committed Apr 6, 2024
1 parent e75e4e0 commit fdd3539
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/phy/sfp-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 6 additions & 0 deletions include/linux/sfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ struct sfp_bus *sfp_bus_find_fwnode(const struct fwnode_handle *fwnode);
int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
const struct sfp_upstream_ops *ops);
void sfp_bus_del_upstream(struct sfp_bus *bus);
const char *sfp_get_name(struct sfp_bus *bus);
#else
static inline int sfp_parse_port(struct sfp_bus *bus,
const struct sfp_eeprom_id *id,
Expand Down Expand Up @@ -648,6 +649,11 @@ static inline int sfp_bus_add_upstream(struct sfp_bus *bus, void *upstream,
static inline void sfp_bus_del_upstream(struct sfp_bus *bus)
{
}

static inline const char *sfp_get_name(struct sfp_bus *bus)
{
return NULL;
}
#endif

#endif

0 comments on commit fdd3539

Please sign in to comment.