[PATCH 08/11] virtio: net: Move out vq and vq buf removal into separate function

From: Amit Shah
Date: Thu Sep 29 2011 - 11:26:54 EST


The remove and PM freeze functions will share this code.

Signed-off-by: Amit Shah <amit.shah@xxxxxxxxxx>
---
drivers/net/virtio_net.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index da4c51a..dcd4b01 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1103,24 +1103,29 @@ static void free_unused_bufs(struct virtnet_info *vi)
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;
-
- /* Stop all the virtqueues. */
- vdev->config->reset(vdev);
-
-
- unregister_netdev(vi->dev);
cancel_delayed_work_sync(&vi->refill);

/* Free unused buffers in both send and recv, if any. */
free_unused_bufs(vi);

- vdev->config->del_vqs(vi->vdev);
+ vi->vdev->config->del_vqs(vi->vdev);

while (vi->pages)
__free_pages(get_a_page(vi, GFP_KERNEL), 0);
+}
+
+static void __devexit virtnet_remove(struct virtio_device *vdev)
+{
+ struct virtnet_info *vi = vdev->priv;
+
+ /* Stop all the virtqueues. */
+ vdev->config->reset(vdev);
+
+ unregister_netdev(vi->dev);
+
+ remove_vq_common(vi);

free_percpu(vi->stats);
free_netdev(vi->dev);
--
1.7.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/