mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
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. This call will always be made while holding the RTNL which ensures that the SFP driver won't unbind from the device. The returned pointer to the bus name will only be used while RTNL is held. Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu> Tested-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b2db6f4ace
commit
0a2f7de0f3
@ -722,6 +722,28 @@ void sfp_bus_del_upstream(struct sfp_bus *bus)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(sfp_bus_del_upstream);
|
||||
|
||||
/**
|
||||
* sfp_get_name() - Get the SFP device name
|
||||
* @bus: a pointer to the &struct sfp_bus structure for the sfp module
|
||||
*
|
||||
* Gets the SFP device's name, if @bus has a registered socket. Callers must
|
||||
* hold RTNL, and the returned name is only valid until RTNL is released.
|
||||
*
|
||||
* Returns:
|
||||
* - The name of the SFP device registered with sfp_register_socket()
|
||||
* - %NULL if no device was registered on @bus
|
||||
*/
|
||||
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);
|
||||
|
||||
/* Socket driver entry points */
|
||||
int sfp_add_phy(struct sfp_bus *bus, struct phy_device *phydev)
|
||||
{
|
||||
|
@ -576,6 +576,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,
|
||||
@ -654,6 +655,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
|
||||
|
Loading…
Reference in New Issue
Block a user