Commit 8eba37f7 authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

net: devlink: use devlink_port pointer instead of ndo_get_devlink_port

Use newly introduced devlink_port pointer instead of getting it calling
to ndo_get_devlink_port op.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e705a621
......@@ -12505,14 +12505,6 @@ static void __devlink_compat_running_version(struct devlink *devlink,
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);
}
void devlink_compat_running_version(struct devlink *devlink,
char *buf, size_t len)
{
......@@ -12558,7 +12550,7 @@ int devlink_compat_phys_port_name_get(struct net_device *dev,
*/
ASSERT_RTNL();
devlink_port = netdev_to_devlink_port(dev);
devlink_port = dev->devlink_port;
if (!devlink_port)
return -EOPNOTSUPP;
......@@ -12574,7 +12566,7 @@ int devlink_compat_switch_id_get(struct net_device *dev,
* devlink_port instance cannot disappear in the middle. No need to take
* any devlink lock as only permanent values are accessed.
*/
devlink_port = netdev_to_devlink_port(dev);
devlink_port = dev->devlink_port;
if (!devlink_port || !devlink_port->switch_port)
return -EOPNOTSUPP;
......
......@@ -532,7 +532,7 @@ static ssize_t phys_port_name_show(struct device *dev,
* returning early without hitting the trylock/restart below.
*/
if (!netdev->netdev_ops->ndo_get_phys_port_name &&
!netdev->netdev_ops->ndo_get_devlink_port)
!netdev->devlink_port)
return -EOPNOTSUPP;
if (!rtnl_trylock())
......@@ -562,7 +562,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
* because recurse is false when calling dev_get_port_parent_id.
*/
if (!netdev->netdev_ops->ndo_get_port_parent_id &&
!netdev->netdev_ops->ndo_get_devlink_port)
!netdev->devlink_port)
return -EOPNOTSUPP;
if (!rtnl_trylock())
......
......@@ -44,16 +44,9 @@ struct ethtool_devlink_compat {
static struct devlink *netdev_to_devlink_get(struct net_device *dev)
{
struct devlink_port *devlink_port;
if (!dev->netdev_ops->ndo_get_devlink_port)
return NULL;
devlink_port = dev->netdev_ops->ndo_get_devlink_port(dev);
if (!devlink_port)
if (!dev->devlink_port)
return NULL;
return devlink_try_get(devlink_port->devlink);
return devlink_try_get(dev->devlink_port->devlink);
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment