Subject: Re: [PATCH net-next v15 04/14] net: sfp: Add helper to return the SFP bus name

From: "Russell King (Oracle)" <[email-masked]>
Date: Wed, 3 Jul 2024 16:36:20 +0100

On Wed, Jul 03, 2024 at 04:07:54PM +0200, Maxime Chevallier wrote:
> 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.

I think it's worth mentioning about the use case in this patch as well,
something like:

"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 <[email-masked]>
> Reviewed-by: Andrew Lunn <[email-masked]>
> ---
>  drivers/net/phy/sfp-bus.c | 11 +++++++++++
>  include/linux/sfp.h       |  6 ++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
> index 56953e66bb7b..37c85f1e6534 100644
> --- a/drivers/net/phy/sfp-bus.c
> +++ b/drivers/net/phy/sfp-bus.c
> @@ -860,3 +860,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);

Please move this to just below sfp_bus_del_upstream() since the
functions in this file are organised as:

- internal functions
- upstream callable functions
- downstream (sfp driver) callable functions.

Note also that the upstream callable functions are all documented with
kerneldoc, and sfp_get_name() is clearly a function called from the
upstream side.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!