diff options
author | Hiroaki SHIMODA <shimoda.hiroaki@gmail.com> | 2012-04-15 09:26:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-16 23:56:36 -0400 |
commit | 890fdf2a0cb88202d1427589db2cf29c1bdd3c1d (patch) | |
tree | 554bcbfda7fccf220b41dfaf030ac1b2d3f550a8 /drivers/net | |
parent | a99ff7d0123b19ecad3b589480b6542716ab6b52 (diff) |
dummy: Add ndo_uninit().
In register_netdevice(), when ndo_init() is successful and later
some error occurred, ndo_uninit() will be called.
So dummy deivce is desirable to implement ndo_uninit() method
to free percpu stats for this case.
And, ndo_uninit() is also called along with dev->destructor() when
device is unregistered, so in order to prevent dev->dstats from
being freed twice, dev->destructor is modified to free_netdev().
Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/dummy.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index d5c6d92f1ee7..442d91a2747b 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c | |||
@@ -107,14 +107,14 @@ static int dummy_dev_init(struct net_device *dev) | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static void dummy_dev_free(struct net_device *dev) | 110 | static void dummy_dev_uninit(struct net_device *dev) |
111 | { | 111 | { |
112 | free_percpu(dev->dstats); | 112 | free_percpu(dev->dstats); |
113 | free_netdev(dev); | ||
114 | } | 113 | } |
115 | 114 | ||
116 | static const struct net_device_ops dummy_netdev_ops = { | 115 | static const struct net_device_ops dummy_netdev_ops = { |
117 | .ndo_init = dummy_dev_init, | 116 | .ndo_init = dummy_dev_init, |
117 | .ndo_uninit = dummy_dev_uninit, | ||
118 | .ndo_start_xmit = dummy_xmit, | 118 | .ndo_start_xmit = dummy_xmit, |
119 | .ndo_validate_addr = eth_validate_addr, | 119 | .ndo_validate_addr = eth_validate_addr, |
120 | .ndo_set_rx_mode = set_multicast_list, | 120 | .ndo_set_rx_mode = set_multicast_list, |
@@ -128,7 +128,7 @@ static void dummy_setup(struct net_device *dev) | |||
128 | 128 | ||
129 | /* Initialize the device structure. */ | 129 | /* Initialize the device structure. */ |
130 | dev->netdev_ops = &dummy_netdev_ops; | 130 | dev->netdev_ops = &dummy_netdev_ops; |
131 | dev->destructor = dummy_dev_free; | 131 | dev->destructor = free_netdev; |
132 | 132 | ||
133 | /* Fill in device structure with ethernet-generic values. */ | 133 | /* Fill in device structure with ethernet-generic values. */ |
134 | dev->tx_queue_len = 0; | 134 | dev->tx_queue_len = 0; |