diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-12-22 06:28:32 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-01-12 00:14:46 -0500 |
commit | 04486ed019d249249c00546704af12498a432c15 (patch) | |
tree | 13c2d4e7a02dffbd75c9476bde3ef4dcfcf8cd8a | |
parent | 3f9c10b0d478a3b7c3dde555edae79fecef496e5 (diff) |
virtio: net: Move vq and vq buf removal into separate function
The remove and PM freeze functions will share this code.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | drivers/net/virtio_net.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 70a9c4b1252d..59109c1b6b87 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -1153,22 +1153,26 @@ static void free_unused_bufs(struct virtnet_info *vi) | |||
1153 | BUG_ON(vi->num != 0); | 1153 | BUG_ON(vi->num != 0); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | static void __devexit virtnet_remove(struct virtio_device *vdev) | 1156 | static void remove_vq_common(struct virtnet_info *vi) |
1157 | { | 1157 | { |
1158 | struct virtnet_info *vi = vdev->priv; | 1158 | vi->vdev->config->reset(vi->vdev); |
1159 | |||
1160 | /* Stop all the virtqueues. */ | ||
1161 | vdev->config->reset(vdev); | ||
1162 | |||
1163 | unregister_netdev(vi->dev); | ||
1164 | 1159 | ||
1165 | /* Free unused buffers in both send and recv, if any. */ | 1160 | /* Free unused buffers in both send and recv, if any. */ |
1166 | free_unused_bufs(vi); | 1161 | free_unused_bufs(vi); |
1167 | 1162 | ||
1168 | vdev->config->del_vqs(vi->vdev); | 1163 | vi->vdev->config->del_vqs(vi->vdev); |
1169 | 1164 | ||
1170 | while (vi->pages) | 1165 | while (vi->pages) |
1171 | __free_pages(get_a_page(vi, GFP_KERNEL), 0); | 1166 | __free_pages(get_a_page(vi, GFP_KERNEL), 0); |
1167 | } | ||
1168 | |||
1169 | static void __devexit virtnet_remove(struct virtio_device *vdev) | ||
1170 | { | ||
1171 | struct virtnet_info *vi = vdev->priv; | ||
1172 | |||
1173 | unregister_netdev(vi->dev); | ||
1174 | |||
1175 | remove_vq_common(vi); | ||
1172 | 1176 | ||
1173 | free_percpu(vi->stats); | 1177 | free_percpu(vi->stats); |
1174 | free_netdev(vi->dev); | 1178 | free_netdev(vi->dev); |