Commit 20d50e8c authored by Stephen Hemminger's avatar Stephen Hemminger

[BRIDGE]: Cleanup of bridge allocation.

Minor cleanup (lead in to later sysfs support).  
Change new_nb to new_bridge_dev and return the net_device rather than
bridge because that is what the caller wants anyway.
parent c5c0a0e3
...@@ -124,7 +124,7 @@ static void del_br(struct net_bridge *br) ...@@ -124,7 +124,7 @@ static void del_br(struct net_bridge *br)
unregister_netdevice(br->dev); unregister_netdevice(br->dev);
} }
static struct net_bridge *new_nb(const char *name) static struct net_device *new_bridge_dev(const char *name)
{ {
struct net_bridge *br; struct net_bridge *br;
struct net_device *dev; struct net_device *dev;
...@@ -135,7 +135,7 @@ static struct net_bridge *new_nb(const char *name) ...@@ -135,7 +135,7 @@ static struct net_bridge *new_nb(const char *name)
if (!dev) if (!dev)
return NULL; return NULL;
br = dev->priv; br = netdev_priv(dev);
br->dev = dev; br->dev = dev;
br->lock = SPIN_LOCK_UNLOCKED; br->lock = SPIN_LOCK_UNLOCKED;
...@@ -160,7 +160,7 @@ static struct net_bridge *new_nb(const char *name) ...@@ -160,7 +160,7 @@ static struct net_bridge *new_nb(const char *name)
br_stp_timer_init(br); br_stp_timer_init(br);
return br; return dev;
} }
/* find an available port number */ /* find an available port number */
...@@ -218,15 +218,16 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, ...@@ -218,15 +218,16 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
int br_add_bridge(const char *name) int br_add_bridge(const char *name)
{ {
struct net_bridge *br; struct net_device *dev;
int ret; int ret;
if ((br = new_nb(name)) == NULL) dev = new_bridge_dev(name);
if (!dev)
return -ENOMEM; return -ENOMEM;
ret = register_netdev(br->dev); ret = register_netdev(dev);
if (ret) if (ret)
free_netdev(br->dev); free_netdev(dev);
return ret; return ret;
} }
...@@ -251,7 +252,7 @@ int br_del_bridge(const char *name) ...@@ -251,7 +252,7 @@ int br_del_bridge(const char *name)
} }
else else
del_br(dev->priv); del_br(netdev_priv(dev));
rtnl_unlock(); rtnl_unlock();
return ret; return ret;
......
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