diff options
author | Amit Shah <amit.shah@redhat.com> | 2012-04-26 15:15:57 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-05-21 22:46:11 -0400 |
commit | c877bab5072c8f461397949babbac10e348ae70d (patch) | |
tree | 65d5850e949fd6b1f304f28af51cc8ca0ae84d64 /drivers/virtio | |
parent | c45b4166d9eaed612fa29acb041662aa4ceb2712 (diff) |
virtio: balloon: separate out common code between remove and freeze functions
The remove and freeze functions have a lot of shared code; put it into a
common function that gets called by both.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 04baad647403..bfbc15ca38dd 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -381,21 +381,25 @@ out: | |||
381 | return err; | 381 | return err; |
382 | } | 382 | } |
383 | 383 | ||
384 | static void __devexit virtballoon_remove(struct virtio_device *vdev) | 384 | static void remove_common(struct virtio_balloon *vb) |
385 | { | 385 | { |
386 | struct virtio_balloon *vb = vdev->priv; | ||
387 | |||
388 | kthread_stop(vb->thread); | ||
389 | |||
390 | /* There might be pages left in the balloon: free them. */ | 386 | /* There might be pages left in the balloon: free them. */ |
391 | while (vb->num_pages) | 387 | while (vb->num_pages) |
392 | leak_balloon(vb, vb->num_pages); | 388 | leak_balloon(vb, vb->num_pages); |
393 | update_balloon_size(vb); | 389 | update_balloon_size(vb); |
394 | 390 | ||
395 | /* Now we reset the device so we can clean up the queues. */ | 391 | /* Now we reset the device so we can clean up the queues. */ |
396 | vdev->config->reset(vdev); | 392 | vb->vdev->config->reset(vb->vdev); |
397 | 393 | ||
398 | vdev->config->del_vqs(vdev); | 394 | vb->vdev->config->del_vqs(vb->vdev); |
395 | } | ||
396 | |||
397 | static void __devexit virtballoon_remove(struct virtio_device *vdev) | ||
398 | { | ||
399 | struct virtio_balloon *vb = vdev->priv; | ||
400 | |||
401 | kthread_stop(vb->thread); | ||
402 | remove_common(vb); | ||
399 | kfree(vb); | 403 | kfree(vb); |
400 | } | 404 | } |
401 | 405 | ||
@@ -409,13 +413,7 @@ static int virtballoon_freeze(struct virtio_device *vdev) | |||
409 | * function is called. | 413 | * function is called. |
410 | */ | 414 | */ |
411 | 415 | ||
412 | while (vb->num_pages) | 416 | remove_common(vb); |
413 | leak_balloon(vb, vb->num_pages); | ||
414 | update_balloon_size(vb); | ||
415 | |||
416 | /* Ensure we don't get any more requests from the host */ | ||
417 | vdev->config->reset(vdev); | ||
418 | vdev->config->del_vqs(vdev); | ||
419 | return 0; | 417 | return 0; |
420 | } | 418 | } |
421 | 419 | ||