On Sat, Sep 19, 2020 at 04:43:31PM +0200, Andrew Lunn wrote:
> Hide away from DSA drivers how devlink works.
>
> Signed-off-by: Andrew Lunn <[email protected]>
> ---
> include/net/dsa.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 01da896b2998..a24d5158ee0c 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -685,6 +685,20 @@ static inline struct dsa_switch
> *dsa_devlink_to_ds(struct devlink *dl)
> return dl_priv->ds;
> }
>
> +static inline
> +struct dsa_switch *dsa_devlink_port_to_ds(struct devlink_port *port)
> +{
> + struct devlink *dl = port->devlink;
> + struct dsa_devlink_priv *dl_priv = devlink_priv(dl);
> +
> + return dl_priv->ds;
> +}
> +
> +static inline int dsa_devlink_port_to_port(struct devlink_port *port)
How about dsa_devlink_port_to_index?
It avoids the repetition and it also indicates more clearly that it
returns an index rather than a struct dsa_port, without needing to fire
up ctags.
> +{
> + return port->index;
> +}
> +
> struct dsa_switch_driver {
> struct list_head list;
> const struct dsa_switch_ops *ops;
> --
> 2.28.0
>
Thanks,
-Vladimir