Commit de752cfc authored by Stephen Hemminger's avatar Stephen Hemminger

[NET]: free_netdev - destructors.

Drivers that use kfree in destructor are easily converted
to use free_netdev.
parent cf6d915d
...@@ -482,7 +482,7 @@ static void bpq_setup(struct net_device *dev) ...@@ -482,7 +482,7 @@ static void bpq_setup(struct net_device *dev)
dev->set_mac_address = bpq_set_mac_address; dev->set_mac_address = bpq_set_mac_address;
dev->get_stats = bpq_get_stats; dev->get_stats = bpq_get_stats;
dev->do_ioctl = bpq_ioctl; dev->do_ioctl = bpq_ioctl;
dev->destructor = (void (*)(struct net_device *)) kfree; dev->destructor = free_netdev;
memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN); memcpy(dev->broadcast, ax25_bcast, AX25_ADDR_LEN);
memcpy(dev->dev_addr, ax25_defaddr, AX25_ADDR_LEN); memcpy(dev->dev_addr, ax25_defaddr, AX25_ADDR_LEN);
......
...@@ -2256,11 +2256,6 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) ...@@ -2256,11 +2256,6 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
* and for initialization. * and for initialization.
*/ */
static void ppp_device_destructor(struct net_device *dev)
{
kfree(dev);
}
/* /*
* Create a new ppp interface unit. Fails if it can't allocate memory * Create a new ppp interface unit. Fails if it can't allocate memory
* or if there is already a unit with the requested number. * or if there is already a unit with the requested number.
...@@ -2309,7 +2304,7 @@ ppp_create_interface(int unit, int *retp) ...@@ -2309,7 +2304,7 @@ ppp_create_interface(int unit, int *retp)
dev->init = ppp_net_init; dev->init = ppp_net_init;
sprintf(dev->name, "ppp%d", unit); sprintf(dev->name, "ppp%d", unit);
dev->priv = ppp; dev->priv = ppp;
dev->destructor = ppp_device_destructor; dev->destructor = free_netdev;
rtnl_lock(); rtnl_lock();
ret = register_netdevice(dev); ret = register_netdevice(dev);
......
...@@ -642,7 +642,7 @@ static void __init shaper_setup(struct net_device *dev) ...@@ -642,7 +642,7 @@ static void __init shaper_setup(struct net_device *dev)
dev->open = shaper_open; dev->open = shaper_open;
dev->stop = shaper_close; dev->stop = shaper_close;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
dev->hard_start_xmit = shaper_start_xmit; dev->hard_start_xmit = shaper_start_xmit;
dev->get_stats = shaper_get_stats; dev->get_stats = shaper_get_stats;
dev->set_multicast_list = NULL; dev->set_multicast_list = NULL;
......
...@@ -640,7 +640,7 @@ static void sl_setup(struct net_device *dev) ...@@ -640,7 +640,7 @@ static void sl_setup(struct net_device *dev)
dev->init = sl_init; dev->init = sl_init;
dev->uninit = sl_uninit; dev->uninit = sl_uninit;
dev->open = sl_open; dev->open = sl_open;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
dev->stop = sl_close; dev->stop = sl_close;
dev->get_stats = sl_get_stats; dev->get_stats = sl_get_stats;
dev->change_mtu = sl_change_mtu; dev->change_mtu = sl_change_mtu;
......
...@@ -358,7 +358,7 @@ static void tun_setup(struct net_device *dev) ...@@ -358,7 +358,7 @@ static void tun_setup(struct net_device *dev)
dev->hard_start_xmit = tun_net_xmit; dev->hard_start_xmit = tun_net_xmit;
dev->stop = tun_net_close; dev->stop = tun_net_close;
dev->get_stats = tun_net_stats; dev->get_stats = tun_net_stats;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
} }
static struct tun_struct *tun_get_by_name(const char *name) static struct tun_struct *tun_get_by_name(const char *name)
......
...@@ -1055,7 +1055,7 @@ static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type) ...@@ -1055,7 +1055,7 @@ static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
return -EIO; return -EIO;
} }
dev->destructor = (void (*)(struct net_device *)) kfree; dev->destructor = free_netdev;
*get_dev_p(pvc, type) = dev; *get_dev_p(pvc, type) = dev;
if (!used) { if (!used) {
hdlc->state.fr.dce_changed = 1; hdlc->state.fr.dce_changed = 1;
......
...@@ -324,7 +324,7 @@ static void lapbeth_setup(struct net_device *dev) ...@@ -324,7 +324,7 @@ static void lapbeth_setup(struct net_device *dev)
dev->hard_start_xmit = lapbeth_xmit; dev->hard_start_xmit = lapbeth_xmit;
dev->open = lapbeth_open; dev->open = lapbeth_open;
dev->stop = lapbeth_close; dev->stop = lapbeth_close;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
dev->set_mac_address = lapbeth_set_mac_address; dev->set_mac_address = lapbeth_set_mac_address;
dev->get_stats = lapbeth_get_stats; dev->get_stats = lapbeth_get_stats;
dev->type = ARPHRD_X25; dev->type = ARPHRD_X25;
......
...@@ -358,7 +358,7 @@ static void vlan_setup(struct net_device *new_dev) ...@@ -358,7 +358,7 @@ static void vlan_setup(struct net_device *new_dev)
new_dev->stop = vlan_dev_stop; new_dev->stop = vlan_dev_stop;
new_dev->set_mac_address = vlan_dev_set_mac_address; new_dev->set_mac_address = vlan_dev_set_mac_address;
new_dev->set_multicast_list = vlan_dev_set_multicast_list; new_dev->set_multicast_list = vlan_dev_set_multicast_list;
new_dev->destructor = (void (*)(struct net_device *)) kfree; new_dev->destructor = free_netdev;
} }
/* Attach a VLAN device to a mac address (ie Ethernet Card). /* Attach a VLAN device to a mac address (ie Ethernet Card).
......
...@@ -110,22 +110,6 @@ static int br_dev_accept_fastpath(struct net_device *dev, struct dst_entry *dst) ...@@ -110,22 +110,6 @@ static int br_dev_accept_fastpath(struct net_device *dev, struct dst_entry *dst)
return -1; return -1;
} }
/* convert later to direct kfree */
static void br_dev_free(struct net_device *dev)
{
struct net_bridge *br = dev->priv;
WARN_ON(!list_empty(&br->port_list));
WARN_ON(!list_empty(&br->age_list));
BUG_ON(timer_pending(&br->hello_timer));
BUG_ON(timer_pending(&br->tcn_timer));
BUG_ON(timer_pending(&br->topology_change_timer));
BUG_ON(timer_pending(&br->gc_timer));
kfree(dev);
}
void br_dev_setup(struct net_device *dev) void br_dev_setup(struct net_device *dev)
{ {
memset(dev->dev_addr, 0, ETH_ALEN); memset(dev->dev_addr, 0, ETH_ALEN);
...@@ -137,7 +121,7 @@ void br_dev_setup(struct net_device *dev) ...@@ -137,7 +121,7 @@ void br_dev_setup(struct net_device *dev)
dev->hard_start_xmit = br_dev_xmit; dev->hard_start_xmit = br_dev_xmit;
dev->open = br_dev_open; dev->open = br_dev_open;
dev->set_multicast_list = br_dev_set_multicast_list; dev->set_multicast_list = br_dev_set_multicast_list;
dev->destructor = br_dev_free; dev->destructor = free_netdev;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->stop = br_dev_stop; dev->stop = br_dev_stop;
dev->accept_fastpath = br_dev_accept_fastpath; dev->accept_fastpath = br_dev_accept_fastpath;
......
...@@ -1128,7 +1128,7 @@ static void ipgre_tunnel_setup(struct net_device *dev) ...@@ -1128,7 +1128,7 @@ static void ipgre_tunnel_setup(struct net_device *dev)
{ {
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->uninit = ipgre_tunnel_uninit; dev->uninit = ipgre_tunnel_uninit;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
dev->hard_start_xmit = ipgre_tunnel_xmit; dev->hard_start_xmit = ipgre_tunnel_xmit;
dev->get_stats = ipgre_tunnel_get_stats; dev->get_stats = ipgre_tunnel_get_stats;
dev->do_ioctl = ipgre_tunnel_ioctl; dev->do_ioctl = ipgre_tunnel_ioctl;
......
...@@ -246,7 +246,7 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c ...@@ -246,7 +246,7 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
nt = dev->priv; nt = dev->priv;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->init = ipip_tunnel_init; dev->init = ipip_tunnel_init;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
nt->parms = *parms; nt->parms = *parms;
if (register_netdevice(dev) < 0) { if (register_netdevice(dev) < 0) {
......
...@@ -193,7 +193,7 @@ static void reg_vif_setup(struct net_device *dev) ...@@ -193,7 +193,7 @@ static void reg_vif_setup(struct net_device *dev)
dev->flags = IFF_NOARP; dev->flags = IFF_NOARP;
dev->hard_start_xmit = reg_vif_xmit; dev->hard_start_xmit = reg_vif_xmit;
dev->get_stats = reg_vif_get_stats; dev->get_stats = reg_vif_get_stats;
dev->destructor = (void (*)(struct net_device *)) kfree; dev->destructor = free_netdev;
} }
static struct net_device *ipmr_reg_vif(void) static struct net_device *ipmr_reg_vif(void)
......
...@@ -722,7 +722,7 @@ static void ipip6_tunnel_setup(struct net_device *dev) ...@@ -722,7 +722,7 @@ static void ipip6_tunnel_setup(struct net_device *dev)
{ {
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->uninit = ipip6_tunnel_uninit; dev->uninit = ipip6_tunnel_uninit;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
dev->hard_start_xmit = ipip6_tunnel_xmit; dev->hard_start_xmit = ipip6_tunnel_xmit;
dev->get_stats = ipip6_tunnel_get_stats; dev->get_stats = ipip6_tunnel_get_stats;
dev->do_ioctl = ipip6_tunnel_ioctl; dev->do_ioctl = ipip6_tunnel_ioctl;
......
...@@ -372,11 +372,6 @@ static void irda_task_timer_expired(void *data) ...@@ -372,11 +372,6 @@ static void irda_task_timer_expired(void *data)
irda_task_kick(task); irda_task_kick(task);
} }
static void irda_device_destructor(struct net_device *dev)
{
kfree(dev);
}
/* /*
* Function irda_device_setup (dev) * Function irda_device_setup (dev)
* *
...@@ -388,7 +383,7 @@ void irda_device_setup(struct net_device *dev) ...@@ -388,7 +383,7 @@ void irda_device_setup(struct net_device *dev)
dev->hard_header_len = 0; dev->hard_header_len = 0;
dev->addr_len = 0; dev->addr_len = 0;
dev->destructor = irda_device_destructor; dev->destructor = free_netdev;
dev->type = ARPHRD_IRDA; dev->type = ARPHRD_IRDA;
dev->tx_queue_len = 8; /* Window size + 1 s-frame */ dev->tx_queue_len = 8; /* Window size + 1 s-frame */
......
...@@ -204,7 +204,7 @@ void nr_setup(struct net_device *dev) ...@@ -204,7 +204,7 @@ void nr_setup(struct net_device *dev)
dev->hard_start_xmit = nr_xmit; dev->hard_start_xmit = nr_xmit;
dev->open = nr_open; dev->open = nr_open;
dev->stop = nr_close; dev->stop = nr_close;
dev->destructor = (void (*)(struct net_device *))kfree; dev->destructor = free_netdev;
dev->hard_header = nr_header; dev->hard_header = nr_header;
dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN; dev->hard_header_len = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
......
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