devlink: create a special NDO for getting the devlink instance
Instead of iterating over all devlink ports add a NDO which will return the devlink instance from the driver. v2: add the netdev_to_devlink() helper (Michal) v3: check that devlink has ops (Florian) v4: hold devlink_mutex (Jiri) Suggested-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
f4b6bcc700
commit
b473b0d235
@@ -538,6 +538,15 @@ static inline struct devlink *priv_to_devlink(void *priv)
|
||||
return container_of(priv, struct devlink, priv);
|
||||
}
|
||||
|
||||
static inline struct devlink *netdev_to_devlink(struct net_device *dev)
|
||||
{
|
||||
#if IS_ENABLED(CONFIG_NET_DEVLINK)
|
||||
if (dev->netdev_ops->ndo_get_devlink)
|
||||
return dev->netdev_ops->ndo_get_devlink(dev);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ib_device;
|
||||
|
||||
#if IS_ENABLED(CONFIG_NET_DEVLINK)
|
||||
|
Reference in New Issue
Block a user