Skip to content

Commit

Permalink
net: set name_assign_type in alloc_netdev()
Browse files Browse the repository at this point in the history
Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
all users to pass NET_NAME_UNKNOWN.

Coccinelle patch:

@@
expression sizeof_priv, name, setup, txqs, rxqs, count;
@@

(
-alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
+alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
|
-alloc_netdev_mq(sizeof_priv, name, setup, count)
+alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
|
-alloc_netdev(sizeof_priv, name, setup)
+alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
)

v9: move comments here from the wrong commit

Signed-off-by: Tom Gundersen <[email protected]>
Reviewed-by: David Herrmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
teg authored and davem330 committed Jul 15, 2014
1 parent 238fa36 commit c835a67
Show file tree
Hide file tree
Showing 97 changed files with 185 additions and 133 deletions.
3 changes: 2 additions & 1 deletion drivers/firewire/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,8 @@ static int fwnet_probe(struct fw_unit *unit,
goto have_dev;
}

net = alloc_netdev(sizeof(*dev), "firewire%d", fwnet_init_dev);
net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
fwnet_init_dev);
if (net == NULL) {
mutex_unlock(&fwnet_device_mutex);
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/hsi/clients/ssi_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ static int ssi_protocol_probe(struct device *dev)
goto out;
}

ssi->netdev = alloc_netdev(0, ifname, ssip_pn_setup);
ssi->netdev = alloc_netdev(0, ifname, NET_NAME_UNKNOWN, ssip_pn_setup);
if (!ssi->netdev) {
dev_err(dev, "No memory for netdev\n");
err = -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/amso1100/c2_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
/* change ethxxx to iwxxx */
strcpy(name, "iw");
strcat(name, &c2dev->netdev->name[3]);
netdev = alloc_netdev(0, name, setup);
netdev = alloc_netdev(0, name, NET_NAME_UNKNOWN, setup);
if (!netdev) {
printk(KERN_ERR PFX "%s - etherdev alloc failed",
__func__);
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/ulp/ipoib/ipoib_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,8 +1394,8 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
{
struct net_device *dev;

dev = alloc_netdev((int) sizeof (struct ipoib_dev_priv), name,
ipoib_setup);
dev = alloc_netdev((int)sizeof(struct ipoib_dev_priv), name,
NET_NAME_UNKNOWN, ipoib_setup);
if (!dev)
return NULL;

Expand Down
3 changes: 2 additions & 1 deletion drivers/isdn/i4l/isdn_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,8 @@ isdn_net_new(char *name, struct net_device *master)
printk(KERN_WARNING "isdn_net: Could not allocate net-device\n");
return NULL;
}
netdev->dev = alloc_netdev(sizeof(isdn_net_local), name, _isdn_setup);
netdev->dev = alloc_netdev(sizeof(isdn_net_local), name,
NET_NAME_UNKNOWN, _isdn_setup);
if (!netdev->dev) {
printk(KERN_WARNING "isdn_net: Could not allocate network device\n");
kfree(netdev);
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/dvb-core/dvb_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,8 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
if ((if_num = get_if(dvbnet)) < 0)
return -EINVAL;

net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup);
net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb",
NET_NAME_UNKNOWN, dvb_net_setup);
if (!net)
return -ENOMEM;

Expand Down
3 changes: 2 additions & 1 deletion drivers/misc/sgi-xp/xpnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ xpnet_init(void)
* use ether_setup() to init the majority of our device
* structure and then override the necessary pieces.
*/
xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, ether_setup);
xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, NET_NAME_UNKNOWN,
ether_setup);
if (xpnet_device == NULL) {
kfree(xpnet_broadcast_partitions);
return -ENOMEM;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/arcnet/arcnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ struct net_device *alloc_arcdev(const char *name)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct arcnet_local),
name && *name ? name : "arc%d", arcdev_setup);
name && *name ? name : "arc%d", NET_NAME_UNKNOWN,
arcdev_setup);
if(dev) {
struct arcnet_local *lp = netdev_priv(dev);
spin_lock_init(&lp->lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4420,7 +4420,7 @@ int bond_create(struct net *net, const char *name)
rtnl_lock();

bond_dev = alloc_netdev_mq(sizeof(struct bonding),
name ? name : "bond%d",
name ? name : "bond%d", NET_NAME_UNKNOWN,
bond_setup, tx_queues);
if (!bond_dev) {
pr_err("%s: eek! can't alloc netdev!\n", name);
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/caif/caif_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ static int ldisc_open(struct tty_struct *tty)
result = snprintf(name, sizeof(name), "cf%s", tty->name);
if (result >= IFNAMSIZ)
return -EINVAL;
dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
dev = alloc_netdev(sizeof(*ser), name, NET_NAME_UNKNOWN,
caifdev_setup);
if (!dev)
return -ENOMEM;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/caif/caif_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ int cfspi_spi_probe(struct platform_device *pdev)
int res;
dev = (struct cfspi_dev *)pdev->dev.platform_data;

ndev = alloc_netdev(sizeof(struct cfspi),
"cfspi%d", cfspi_setup);
ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
NET_NAME_UNKNOWN, cfspi_setup);
if (!dev)
return -ENODEV;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/caif/caif_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ static int cfv_probe(struct virtio_device *vdev)
int err = -EINVAL;

netdev = alloc_netdev(sizeof(struct cfv_info), cfv_netdev_name,
cfv_netdev_setup);
NET_NAME_UNKNOWN, cfv_netdev_setup);
if (!netdev)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max)
else
size = sizeof_priv;

dev = alloc_netdev(size, "can%d", can_setup);
dev = alloc_netdev(size, "can%d", NET_NAME_UNKNOWN, can_setup);
if (!dev)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/slcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static struct slcan *slc_alloc(dev_t line)
return NULL;

sprintf(name, "slcan%d", i);
dev = alloc_netdev(sizeof(*sl), name, slc_setup);
dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, slc_setup);
if (!dev)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static int __init dummy_init_one(void)
struct net_device *dev_dummy;
int err;

dev_dummy = alloc_netdev(0, "dummy%d", dummy_setup);
dev_dummy = alloc_netdev(0, "dummy%d", NET_NAME_UNKNOWN, dummy_setup);
if (!dev_dummy)
return -ENOMEM;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/eql.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ static int __init eql_init_module(void)

pr_info("%s\n", version);

dev_eql = alloc_netdev(sizeof(equalizer_t), "eql", eql_setup);
dev_eql = alloc_netdev(sizeof(equalizer_t), "eql", NET_NAME_UNKNOWN,
eql_setup);
if (!dev_eql)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/8390/lib8390.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ static void ethdev_setup(struct net_device *dev)
static struct net_device *____alloc_ei_netdev(int size)
{
return alloc_netdev(sizeof(struct ei_device) + size, "eth%d",
ethdev_setup);
NET_NAME_UNKNOWN, ethdev_setup);
}


Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/tile/tilegx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2201,8 +2201,8 @@ static void tile_net_dev_init(const char *name, const uint8_t *mac)
/* Allocate the device structure. Normally, "name" is a
* template, instantiated by register_netdev(), but not for us.
*/
dev = alloc_netdev_mqs(sizeof(*priv), name, tile_net_setup,
NR_CPUS, 1);
dev = alloc_netdev_mqs(sizeof(*priv), name, NET_NAME_UNKNOWN,
tile_net_setup, NR_CPUS, 1);
if (!dev) {
pr_err("alloc_netdev_mqs(%s) failed\n", name);
return;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/tile/tilepro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,8 @@ static struct net_device *tile_net_dev_init(const char *name)
* tile_net_setup(), and saves "name". Normally, "name" is a
* template, instantiated by register_netdev(), but not for us.
*/
dev = alloc_netdev(sizeof(*priv), name, tile_net_setup);
dev = alloc_netdev(sizeof(*priv), name, NET_NAME_UNKNOWN,
tile_net_setup);
if (!dev) {
pr_err("alloc_netdev(%s) failed\n", name);
return NULL;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/hamradio/6pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ static int sixpack_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;

dev = alloc_netdev(sizeof(struct sixpack), "sp%d", sp_setup);
dev = alloc_netdev(sizeof(struct sixpack), "sp%d", NET_NAME_UNKNOWN,
sp_setup);
if (!dev) {
err = -ENOMEM;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/hamradio/baycom_epp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ static int __init init_baycomepp(void)
struct net_device *dev;

dev = alloc_netdev(sizeof(struct baycom_state), "bce%d",
baycom_epp_dev_setup);
NET_NAME_UNKNOWN, baycom_epp_dev_setup);

if (!dev) {
printk(KERN_WARNING "bce%d : out of memory\n", i);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/hamradio/bpqether.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ static int bpq_new_device(struct net_device *edev)
struct net_device *ndev;
struct bpqdev *bpq;

ndev = alloc_netdev(sizeof(struct bpqdev), "bpq%d",
bpq_setup);
ndev = alloc_netdev(sizeof(struct bpqdev), "bpq%d", NET_NAME_UNKNOWN,
bpq_setup);
if (!ndev)
return -ENOMEM;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/hamradio/dmascc.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,15 @@ static int __init setup_adapter(int card_base, int type, int n)
if (!info)
goto out;

info->dev[0] = alloc_netdev(0, "", dev_setup);
info->dev[0] = alloc_netdev(0, "", NET_NAME_UNKNOWN, dev_setup);
if (!info->dev[0]) {
printk(KERN_ERR "dmascc: "
"could not allocate memory for %s at %#3x\n",
hw[type].name, card_base);
goto out1;
}

info->dev[1] = alloc_netdev(0, "", dev_setup);
info->dev[1] = alloc_netdev(0, "", NET_NAME_UNKNOWN, dev_setup);
if (!info->dev[1]) {
printk(KERN_ERR "dmascc: "
"could not allocate memory for %s at %#3x\n",
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/hamradio/hdlcdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
if (privsize < sizeof(struct hdlcdrv_state))
privsize = sizeof(struct hdlcdrv_state);

dev = alloc_netdev(privsize, ifname, hdlcdrv_setup);
dev = alloc_netdev(privsize, ifname, NET_NAME_UNKNOWN, hdlcdrv_setup);
if (!dev)
return ERR_PTR(-ENOMEM);

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/hamradio/mkiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ static int mkiss_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;

dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup);
dev = alloc_netdev(sizeof(struct mkiss), "ax%d", NET_NAME_UNKNOWN,
ax_setup);
if (!dev) {
err = -ENOMEM;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/hamradio/scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ static int scc_net_alloc(const char *name, struct scc_channel *scc)
int err;
struct net_device *dev;

dev = alloc_netdev(0, name, scc_net_setup);
dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, scc_net_setup);
if (!dev)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/hamradio/yam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ static int __init yam_init_driver(void)
sprintf(name, "yam%d", i);

dev = alloc_netdev(sizeof(struct yam_port), name,
yam_setup);
NET_NAME_UNKNOWN, yam_setup);
if (!dev) {
pr_err("yam: cannot allocate net device\n");
err = -ENOMEM;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ieee802154/fakehard.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ static int ieee802154fake_probe(struct platform_device *pdev)
if (!phy)
return -ENOMEM;

dev = alloc_netdev(sizeof(struct fakehard_priv), "hardwpan%d", ieee802154_fake_setup);
dev = alloc_netdev(sizeof(struct fakehard_priv), "hardwpan%d",
NET_NAME_UNKNOWN, ieee802154_fake_setup);
if (!dev) {
wpan_phy_free(phy);
return -ENOMEM;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ifb.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ static int __init ifb_init_one(int index)
struct ifb_private *dp;
int err;

dev_ifb = alloc_netdev(sizeof(struct ifb_private),
"ifb%d", ifb_setup);
dev_ifb = alloc_netdev(sizeof(struct ifb_private), "ifb%d",
NET_NAME_UNKNOWN, ifb_setup);

if (!dev_ifb)
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static __net_init int loopback_net_init(struct net *net)
int err;

err = -ENOMEM;
dev = alloc_netdev(0, "lo", loopback_setup);
dev = alloc_netdev(0, "lo", NET_NAME_UNKNOWN, loopback_setup);
if (!dev)
goto out;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ppp/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,8 @@ ppp_create_interface(struct net *net, int unit, int *retp)
int ret = -ENOMEM;
int i;

dev = alloc_netdev(sizeof(struct ppp), "", ppp_setup);
dev = alloc_netdev(sizeof(struct ppp), "", NET_NAME_UNKNOWN,
ppp_setup);
if (!dev)
goto out1;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/slip/slip.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ static struct slip *sl_alloc(dev_t line)
return NULL;

sprintf(name, "sl%d", i);
dev = alloc_netdev(sizeof(*sl), name, sl_setup);
dev = alloc_netdev(sizeof(*sl), name, NET_NAME_UNKNOWN, sl_setup);
if (!dev)
return NULL;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
name = ifr->ifr_name;

dev = alloc_netdev_mqs(sizeof(struct tun_struct), name,
tun_setup, queues, queues);
NET_NAME_UNKNOWN, tun_setup, queues,
queues);

if (!dev)
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/usb/cdc-phonet.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *i
return -EINVAL;

dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size,
ifname, usbpn_setup);
ifname, NET_NAME_UNKNOWN, usbpn_setup);
if (!dev)
return -ENOMEM;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,8 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,

/* allocate our network device, then we can put in our private data */
/* call hso_net_init to do the basic initialization */
net = alloc_netdev(sizeof(struct hso_net), "hso%d", hso_net_init);
net = alloc_netdev(sizeof(struct hso_net), "hso%d", NET_NAME_UNKNOWN,
hso_net_init);
if (!net) {
dev_err(&interface->dev, "Unable to create ethernet device\n");
goto exit;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wan/dlci.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ static int dlci_add(struct dlci_add *dlci)
goto err1;

/* create device name */
master = alloc_netdev( sizeof(struct dlci_local), "dlci%d",
dlci_setup);
master = alloc_netdev(sizeof(struct dlci_local), "dlci%d",
NET_NAME_UNKNOWN, dlci_setup);
if (!master) {
err = -ENOMEM;
goto err1;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wan/hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ static void hdlc_setup(struct net_device *dev)
struct net_device *alloc_hdlcdev(void *priv)
{
struct net_device *dev;
dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d", hdlc_setup);
dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d",
NET_NAME_UNKNOWN, hdlc_setup);
if (dev)
dev_to_hdlc(dev)->priv = priv;
return dev;
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wan/hdlc_fr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,10 +1075,11 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
used = pvc_is_used(pvc);

if (type == ARPHRD_ETHER) {
dev = alloc_netdev(0, "pvceth%d", ether_setup);
dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN,
ether_setup);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
} else
dev = alloc_netdev(0, "pvc%d", pvc_setup);
dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup);

if (!dev) {
netdev_warn(frad, "Memory squeeze on fr_pvc()\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wan/lapbether.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ static int lapbeth_new_device(struct net_device *dev)

ASSERT_RTNL();

ndev = alloc_netdev(sizeof(*lapbeth), "lapb%d",
lapbeth_setup);
ndev = alloc_netdev(sizeof(*lapbeth), "lapb%d", NET_NAME_UNKNOWN,
lapbeth_setup);
if (!ndev)
goto out;

Expand Down
Loading

0 comments on commit c835a67

Please sign in to comment.