aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2011-04-29 21:21:32 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-05 13:57:45 -0400
commit1c5cae815d19ffe02bdfda1260949ef2b1806171 (patch)
treed47a73c05afacd21985abb8df9862136385c58f0 /drivers/net
parente8920674979705392abc4db4ebbe78feb68a4da1 (diff)
net: call dev_alloc_name from register_netdevice
Force dev_alloc_name() to be called from register_netdevice() by dev_get_valid_name(). That allows to remove multiple explicit dev_alloc_name() calls. The possibility to call dev_alloc_name in advance remains. This also fixes veth creation regresion caused by 84c49d8c3e4abefb0a41a77b25aa37ebe8d6b743 Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_main.c21
-rw-r--r--drivers/net/dummy.c4
-rw-r--r--drivers/net/hamradio/bpqether.c4
-rw-r--r--drivers/net/ifb.c4
-rw-r--r--drivers/net/tun.c6
-rw-r--r--drivers/net/wan/dlci.c4
-rw-r--r--drivers/net/wan/hdlc_fr.c9
-rw-r--r--drivers/net/wan/lapbether.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c7
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c11
-rw-r--r--drivers/net/wireless/mwifiex/main.c4
11 files changed, 6 insertions, 72 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 22bd03bd1d35..9a5feaf4bab9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4917,8 +4917,9 @@ int bond_create(struct net *net, const char *name)
4917 4917
4918 rtnl_lock(); 4918 rtnl_lock();
4919 4919
4920 bond_dev = alloc_netdev_mq(sizeof(struct bonding), name ? name : "", 4920 bond_dev = alloc_netdev_mq(sizeof(struct bonding),
4921 bond_setup, tx_queues); 4921 name ? name : "bond%d",
4922 bond_setup, tx_queues);
4922 if (!bond_dev) { 4923 if (!bond_dev) {
4923 pr_err("%s: eek! can't alloc netdev!\n", name); 4924 pr_err("%s: eek! can't alloc netdev!\n", name);
4924 rtnl_unlock(); 4925 rtnl_unlock();
@@ -4928,26 +4929,10 @@ int bond_create(struct net *net, const char *name)
4928 dev_net_set(bond_dev, net); 4929 dev_net_set(bond_dev, net);
4929 bond_dev->rtnl_link_ops = &bond_link_ops; 4930 bond_dev->rtnl_link_ops = &bond_link_ops;
4930 4931
4931 if (!name) {
4932 res = dev_alloc_name(bond_dev, "bond%d");
4933 if (res < 0)
4934 goto out;
4935 } else {
4936 /*
4937 * If we're given a name to register
4938 * we need to ensure that its not already
4939 * registered
4940 */
4941 res = -EEXIST;
4942 if (__dev_get_by_name(net, name) != NULL)
4943 goto out;
4944 }
4945
4946 res = register_netdevice(bond_dev); 4932 res = register_netdevice(bond_dev);
4947 4933
4948 netif_carrier_off(bond_dev); 4934 netif_carrier_off(bond_dev);
4949 4935
4950out:
4951 rtnl_unlock(); 4936 rtnl_unlock();
4952 if (res < 0) 4937 if (res < 0)
4953 bond_destructor(bond_dev); 4938 bond_destructor(bond_dev);
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index ff2d29b17858..39cf9b9bd673 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -168,10 +168,6 @@ static int __init dummy_init_one(void)
168 if (!dev_dummy) 168 if (!dev_dummy)
169 return -ENOMEM; 169 return -ENOMEM;
170 170
171 err = dev_alloc_name(dev_dummy, dev_dummy->name);
172 if (err < 0)
173 goto err;
174
175 dev_dummy->rtnl_link_ops = &dummy_link_ops; 171 dev_dummy->rtnl_link_ops = &dummy_link_ops;
176 err = register_netdevice(dev_dummy); 172 err = register_netdevice(dev_dummy);
177 if (err < 0) 173 if (err < 0)
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 8931168d3e74..18d8affecd1b 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -516,10 +516,6 @@ static int bpq_new_device(struct net_device *edev)
516 memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr)); 516 memcpy(bpq->dest_addr, bcast_addr, sizeof(bpq_eth_addr));
517 memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr)); 517 memcpy(bpq->acpt_addr, bcast_addr, sizeof(bpq_eth_addr));
518 518
519 err = dev_alloc_name(ndev, ndev->name);
520 if (err < 0)
521 goto error;
522
523 err = register_netdevice(ndev); 519 err = register_netdevice(ndev);
524 if (err) 520 if (err)
525 goto error; 521 goto error;
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index e07d487f015a..4fecaed67fc4 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -233,10 +233,6 @@ static int __init ifb_init_one(int index)
233 if (!dev_ifb) 233 if (!dev_ifb)
234 return -ENOMEM; 234 return -ENOMEM;
235 235
236 err = dev_alloc_name(dev_ifb, dev_ifb->name);
237 if (err < 0)
238 goto err;
239
240 dev_ifb->rtnl_link_ops = &ifb_link_ops; 236 dev_ifb->rtnl_link_ops = &ifb_link_ops;
241 err = register_netdevice(dev_ifb); 237 err = register_netdevice(dev_ifb);
242 if (err < 0) 238 if (err < 0)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 0636f7040325..74e94054ab1a 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1099,12 +1099,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1099 1099
1100 tun_net_init(dev); 1100 tun_net_init(dev);
1101 1101
1102 if (strchr(dev->name, '%')) {
1103 err = dev_alloc_name(dev, dev->name);
1104 if (err < 0)
1105 goto err_free_sk;
1106 }
1107
1108 dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | 1102 dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
1109 TUN_USER_FEATURES; 1103 TUN_USER_FEATURES;
1110 dev->features = dev->hw_features; 1104 dev->features = dev->hw_features;
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index 1481a446fefb..21b104db5a90 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -341,10 +341,6 @@ static int dlci_add(struct dlci_add *dlci)
341 } 341 }
342 } 342 }
343 343
344 err = dev_alloc_name(master, master->name);
345 if (err < 0)
346 goto err2;
347
348 *(short *)(master->dev_addr) = dlci->dlci; 344 *(short *)(master->dev_addr) = dlci->dlci;
349 345
350 dlp = netdev_priv(master); 346 dlp = netdev_priv(master);
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 0edb535bb2b5..fc433f28c047 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -1070,7 +1070,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1070 hdlc_device *hdlc = dev_to_hdlc(frad); 1070 hdlc_device *hdlc = dev_to_hdlc(frad);
1071 pvc_device *pvc; 1071 pvc_device *pvc;
1072 struct net_device *dev; 1072 struct net_device *dev;
1073 int result, used; 1073 int used;
1074 1074
1075 if ((pvc = add_pvc(frad, dlci)) == NULL) { 1075 if ((pvc = add_pvc(frad, dlci)) == NULL) {
1076 printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n", 1076 printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n",
@@ -1106,13 +1106,6 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1106 dev->tx_queue_len = 0; 1106 dev->tx_queue_len = 0;
1107 dev->ml_priv = pvc; 1107 dev->ml_priv = pvc;
1108 1108
1109 result = dev_alloc_name(dev, dev->name);
1110 if (result < 0) {
1111 free_netdev(dev);
1112 delete_unused_pvcs(hdlc);
1113 return result;
1114 }
1115
1116 if (register_netdevice(dev) != 0) { 1109 if (register_netdevice(dev) != 0) {
1117 free_netdev(dev); 1110 free_netdev(dev);
1118 delete_unused_pvcs(hdlc); 1111 delete_unused_pvcs(hdlc);
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index 7f5bb913c8b9..eec463f99c09 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -338,10 +338,6 @@ static int lapbeth_new_device(struct net_device *dev)
338 dev_hold(dev); 338 dev_hold(dev);
339 lapbeth->ethdev = dev; 339 lapbeth->ethdev = dev;
340 340
341 rc = dev_alloc_name(ndev, ndev->name);
342 if (rc < 0)
343 goto fail;
344
345 rc = -EIO; 341 rc = -EIO;
346 if (register_netdevice(ndev)) 342 if (register_netdevice(ndev))
347 goto fail; 343 goto fail;
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 1d9aed645723..d5084829c9e5 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -79,13 +79,8 @@ struct net_device * hostap_add_interface(struct local_info *local,
79 if (!rtnl_locked) 79 if (!rtnl_locked)
80 rtnl_lock(); 80 rtnl_lock();
81 81
82 ret = 0;
83 if (strchr(dev->name, '%'))
84 ret = dev_alloc_name(dev, dev->name);
85
86 SET_NETDEV_DEV(dev, mdev->dev.parent); 82 SET_NETDEV_DEV(dev, mdev->dev.parent);
87 if (ret >= 0) 83 ret = register_netdevice(dev);
88 ret = register_netdevice(dev);
89 84
90 if (!rtnl_locked) 85 if (!rtnl_locked)
91 rtnl_unlock(); 86 rtnl_unlock();
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index f4f4257a9d67..9d4a40ee16c4 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1515,19 +1515,10 @@ static int __init init_mac80211_hwsim(void)
1515 if (hwsim_mon == NULL) 1515 if (hwsim_mon == NULL)
1516 goto failed; 1516 goto failed;
1517 1517
1518 rtnl_lock(); 1518 err = register_netdev(hwsim_mon);
1519
1520 err = dev_alloc_name(hwsim_mon, hwsim_mon->name);
1521 if (err < 0) 1519 if (err < 0)
1522 goto failed_mon; 1520 goto failed_mon;
1523 1521
1524
1525 err = register_netdevice(hwsim_mon);
1526 if (err < 0)
1527 goto failed_mon;
1528
1529 rtnl_unlock();
1530
1531 return 0; 1522 return 0;
1532 1523
1533failed_mon: 1524failed_mon:
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index c5971880e7b3..d16cea770fa3 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -706,10 +706,6 @@ static struct mwifiex_private *mwifiex_add_interface(
706 dev_err(adapter->dev, "no memory available for netdevice\n"); 706 dev_err(adapter->dev, "no memory available for netdevice\n");
707 goto error; 707 goto error;
708 } 708 }
709 if (dev_alloc_name(dev, dev->name)) {
710 dev_err(adapter->dev, "unable to alloc name for netdevice\n");
711 goto error;
712 }
713 709
714 if (mwifiex_register_cfg80211(dev, adapter->priv[bss_index]->curr_addr, 710 if (mwifiex_register_cfg80211(dev, adapter->priv[bss_index]->curr_addr,
715 adapter->priv[bss_index]) != 0) { 711 adapter->priv[bss_index]) != 0) {