diff options
author | Jiri Pirko <jiri@mellanox.com> | 2019-04-25 15:59:55 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-26 07:52:03 +0200 |
commit | e05b2d141fef22cfac1928cf0eb6890e5dae4216 (patch) | |
tree | 055d8c4330e6e9002a2bf4e9829febe8df84d59f /drivers/net/netdevsim/bus.c | |
parent | netdevsim: extend device attrs to support port addition and deletion (diff) | |
download | linux-e05b2d141fef22cfac1928cf0eb6890e5dae4216.tar.xz linux-e05b2d141fef22cfac1928cf0eb6890e5dae4216.zip |
netdevsim: move netdev creation/destruction to dev probe
Remove the existing way to create netdevsim over rtnetlink and move the
netdev creation/destruction to dev probe, so for every probed port,
a netdevsim-netdev instance is created.
Adjust selftests to work with new interface.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netdevsim/bus.c')
-rw-r--r-- | drivers/net/netdevsim/bus.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c index 549c399f29da..ae482347b67b 100644 --- a/drivers/net/netdevsim/bus.c +++ b/drivers/net/netdevsim/bus.c @@ -153,6 +153,9 @@ static struct device_type nsim_bus_dev_type = { .release = nsim_bus_dev_release, }; +static struct nsim_bus_dev * +nsim_bus_dev_new(unsigned int id, unsigned int port_count); + static ssize_t new_device_store(struct bus_type *bus, const char *buf, size_t count) { @@ -188,6 +191,8 @@ new_device_store(struct bus_type *bus, const char *buf, size_t count) } static BUS_ATTR_WO(new_device); +static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev); + static ssize_t del_device_store(struct bus_type *bus, const char *buf, size_t count) { @@ -261,7 +266,8 @@ static struct bus_type nsim_bus = { .num_vf = nsim_num_vf, }; -struct nsim_bus_dev *nsim_bus_dev_new(unsigned int id, unsigned int port_count) +static struct nsim_bus_dev * +nsim_bus_dev_new(unsigned int id, unsigned int port_count) { struct nsim_bus_dev *nsim_bus_dev; int err; @@ -270,8 +276,7 @@ struct nsim_bus_dev *nsim_bus_dev_new(unsigned int id, unsigned int port_count) if (!nsim_bus_dev) return ERR_PTR(-ENOMEM); - err = ida_alloc_range(&nsim_bus_dev_ids, - id == ~0 ? 0 : id, id, GFP_KERNEL); + err = ida_alloc_range(&nsim_bus_dev_ids, id, id, GFP_KERNEL); if (err < 0) goto err_nsim_bus_dev_free; nsim_bus_dev->dev.id = err; @@ -291,19 +296,7 @@ err_nsim_bus_dev_free: return ERR_PTR(err); } -struct nsim_bus_dev *nsim_bus_dev_new_with_ns(struct netdevsim *ns) -{ - struct nsim_bus_dev *nsim_bus_dev; - - dev_hold(ns->netdev); - rtnl_unlock(); - nsim_bus_dev = nsim_bus_dev_new(~0, 0); - rtnl_lock(); - dev_put(ns->netdev); - return nsim_bus_dev; -} - -void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev) +static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev) { device_unregister(&nsim_bus_dev->dev); ida_free(&nsim_bus_dev_ids, nsim_bus_dev->dev.id); |