diff options
author | Jiri Pirko <jiri@mellanox.com> | 2019-04-25 15:59:53 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-26 01:52:02 -0400 |
commit | 8320d145912738655cf631d27aa1829d8b17804e (patch) | |
tree | 6e7f4ea830549254a04ee3028d6b97f4d60f30dc /drivers/net/netdevsim/netdev.c | |
parent | ab1d0cc004d706523dcad7cdad97a2b94eecf169 (diff) | |
download | lwn-8320d145912738655cf631d27aa1829d8b17804e.tar.gz lwn-8320d145912738655cf631d27aa1829d8b17804e.zip |
netdevsim: implement dev probe/remove skeleton with port initialization
Implement netdevsim bus probing of netdevsim devices. For every probed
device create a devlink instance. According to the user-passed value,
create a number of ports represented by devlink port instances.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netdevsim/netdev.c')
-rw-r--r-- | drivers/net/netdevsim/netdev.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index eb823bd0dc39..99169fe521f2 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -74,7 +74,6 @@ static void nsim_free(struct net_device *dev) { struct netdevsim *ns = netdev_priv(dev); - nsim_dev_destroy(ns->nsim_dev); nsim_bus_dev_del(ns->nsim_bus_dev); /* netdev and vf state will be freed out of device_release() */ } @@ -364,26 +363,20 @@ static int nsim_newlink(struct net *src_net, struct net_device *dev, struct netdevsim *ns = netdev_priv(dev); int err; - ns->nsim_bus_dev = nsim_bus_dev_new(~0, 0); + ns->netdev = dev; + ns->nsim_bus_dev = nsim_bus_dev_new_with_ns(ns); if (IS_ERR(ns->nsim_bus_dev)) return PTR_ERR(ns->nsim_bus_dev); SET_NETDEV_DEV(dev, &ns->nsim_bus_dev->dev); - ns->netdev = dev; - ns->nsim_dev = nsim_dev_create_with_ns(ns->nsim_bus_dev, ns); - if (IS_ERR(ns->nsim_dev)) { - err = PTR_ERR(ns->nsim_dev); - goto err_dev_del; - } + ns->nsim_dev = dev_get_drvdata(&ns->nsim_bus_dev->dev); err = register_netdevice(dev); if (err) - goto err_dev_destroy; + goto err_dev_del; return 0; -err_dev_destroy: - nsim_dev_destroy(ns->nsim_dev); err_dev_del: nsim_bus_dev_del(ns->nsim_bus_dev); return err; |