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>
This commit is contained in:
parent
3f9c10b0d4
commit
04486ed019
@ -1153,22 +1153,26 @@ static void free_unused_bufs(struct virtnet_info *vi)
|
|||||||
BUG_ON(vi->num != 0);
|
BUG_ON(vi->num != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __devexit virtnet_remove(struct virtio_device *vdev)
|
static void remove_vq_common(struct virtnet_info *vi)
|
||||||
{
|
{
|
||||||
struct virtnet_info *vi = vdev->priv;
|
vi->vdev->config->reset(vi->vdev);
|
||||||
|
|
||||||
/* Stop all the virtqueues. */
|
|
||||||
vdev->config->reset(vdev);
|
|
||||||
|
|
||||||
unregister_netdev(vi->dev);
|
|
||||||
|
|
||||||
/* Free unused buffers in both send and recv, if any. */
|
/* Free unused buffers in both send and recv, if any. */
|
||||||
free_unused_bufs(vi);
|
free_unused_bufs(vi);
|
||||||
|
|
||||||
vdev->config->del_vqs(vi->vdev);
|
vi->vdev->config->del_vqs(vi->vdev);
|
||||||
|
|
||||||
while (vi->pages)
|
while (vi->pages)
|
||||||
__free_pages(get_a_page(vi, GFP_KERNEL), 0);
|
__free_pages(get_a_page(vi, GFP_KERNEL), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __devexit virtnet_remove(struct virtio_device *vdev)
|
||||||
|
{
|
||||||
|
struct virtnet_info *vi = vdev->priv;
|
||||||
|
|
||||||
|
unregister_netdev(vi->dev);
|
||||||
|
|
||||||
|
remove_vq_common(vi);
|
||||||
|
|
||||||
free_percpu(vi->stats);
|
free_percpu(vi->stats);
|
||||||
free_netdev(vi->dev);
|
free_netdev(vi->dev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user