devlink: Move netdev_to_devlink helpers to devlink.c

Both netdev_to_devlink and netdev_to_devlink_port are used in devlink.c
only, so move them in order to reduce their scope.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Leon Romanovsky 2021-10-12 16:15:22 +03:00 committed by Jakub Kicinski
parent 21314638c9
commit 2bc50987dc
2 changed files with 18 additions and 17 deletions

View File

@ -1486,23 +1486,6 @@ void *devlink_priv(struct devlink *devlink);
struct devlink *priv_to_devlink(void *priv);
struct device *devlink_to_dev(const struct devlink *devlink);
static inline struct devlink_port *
netdev_to_devlink_port(struct net_device *dev)
{
if (dev->netdev_ops->ndo_get_devlink_port)
return dev->netdev_ops->ndo_get_devlink_port(dev);
return NULL;
}
static inline struct devlink *netdev_to_devlink(struct net_device *dev)
{
struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
if (devlink_port)
return devlink_port->devlink;
return NULL;
}
struct ib_device;
struct net *devlink_net(const struct devlink *devlink);

View File

@ -11381,6 +11381,24 @@ free_msg:
nlmsg_free(msg);
}
static struct devlink_port *netdev_to_devlink_port(struct net_device *dev)
{
if (!dev->netdev_ops->ndo_get_devlink_port)
return NULL;
return dev->netdev_ops->ndo_get_devlink_port(dev);
}
static struct devlink *netdev_to_devlink(struct net_device *dev)
{
struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
if (!devlink_port)
return NULL;
return devlink_port->devlink;
}
void devlink_compat_running_version(struct net_device *dev,
char *buf, size_t len)
{