diff options
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 14 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci.c | 74 | ||||
-rw-r--r-- | include/linux/virtio.h | 1 |
3 files changed, 8 insertions, 81 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 958e5129c601..05f0a80818a2 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -398,21 +398,8 @@ static int restore_common(struct virtio_device *vdev) | |||
398 | return 0; | 398 | return 0; |
399 | } | 399 | } |
400 | 400 | ||
401 | static int virtballoon_thaw(struct virtio_device *vdev) | ||
402 | { | ||
403 | return restore_common(vdev); | ||
404 | } | ||
405 | |||
406 | static int virtballoon_restore(struct virtio_device *vdev) | 401 | static int virtballoon_restore(struct virtio_device *vdev) |
407 | { | 402 | { |
408 | struct virtio_balloon *vb = vdev->priv; | ||
409 | |||
410 | /* | ||
411 | * If a request wasn't complete at the time of freezing, this | ||
412 | * could have been set. | ||
413 | */ | ||
414 | vb->need_stats_update = 0; | ||
415 | |||
416 | return restore_common(vdev); | 403 | return restore_common(vdev); |
417 | } | 404 | } |
418 | #endif | 405 | #endif |
@@ -434,7 +421,6 @@ static struct virtio_driver virtio_balloon_driver = { | |||
434 | #ifdef CONFIG_PM | 421 | #ifdef CONFIG_PM |
435 | .freeze = virtballoon_freeze, | 422 | .freeze = virtballoon_freeze, |
436 | .restore = virtballoon_restore, | 423 | .restore = virtballoon_restore, |
437 | .thaw = virtballoon_thaw, | ||
438 | #endif | 424 | #endif |
439 | }; | 425 | }; |
440 | 426 | ||
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index 635e1efb3792..2e03d416b9af 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -720,24 +720,6 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev) | |||
720 | } | 720 | } |
721 | 721 | ||
722 | #ifdef CONFIG_PM | 722 | #ifdef CONFIG_PM |
723 | static int virtio_pci_suspend(struct device *dev) | ||
724 | { | ||
725 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
726 | |||
727 | pci_save_state(pci_dev); | ||
728 | pci_set_power_state(pci_dev, PCI_D3hot); | ||
729 | return 0; | ||
730 | } | ||
731 | |||
732 | static int virtio_pci_resume(struct device *dev) | ||
733 | { | ||
734 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
735 | |||
736 | pci_restore_state(pci_dev); | ||
737 | pci_set_power_state(pci_dev, PCI_D0); | ||
738 | return 0; | ||
739 | } | ||
740 | |||
741 | static int virtio_pci_freeze(struct device *dev) | 723 | static int virtio_pci_freeze(struct device *dev) |
742 | { | 724 | { |
743 | struct pci_dev *pci_dev = to_pci_dev(dev); | 725 | struct pci_dev *pci_dev = to_pci_dev(dev); |
@@ -758,59 +740,24 @@ static int virtio_pci_freeze(struct device *dev) | |||
758 | return ret; | 740 | return ret; |
759 | } | 741 | } |
760 | 742 | ||
761 | static int restore_common(struct device *dev) | 743 | static int virtio_pci_restore(struct device *dev) |
762 | { | ||
763 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
764 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); | ||
765 | int ret; | ||
766 | |||
767 | ret = pci_enable_device(pci_dev); | ||
768 | if (ret) | ||
769 | return ret; | ||
770 | pci_set_master(pci_dev); | ||
771 | vp_finalize_features(&vp_dev->vdev); | ||
772 | |||
773 | return ret; | ||
774 | } | ||
775 | |||
776 | static int virtio_pci_thaw(struct device *dev) | ||
777 | { | 744 | { |
778 | struct pci_dev *pci_dev = to_pci_dev(dev); | 745 | struct pci_dev *pci_dev = to_pci_dev(dev); |
779 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); | 746 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); |
780 | struct virtio_driver *drv; | 747 | struct virtio_driver *drv; |
781 | int ret; | 748 | int ret; |
782 | 749 | ||
783 | ret = restore_common(dev); | ||
784 | if (ret) | ||
785 | return ret; | ||
786 | |||
787 | drv = container_of(vp_dev->vdev.dev.driver, | 750 | drv = container_of(vp_dev->vdev.dev.driver, |
788 | struct virtio_driver, driver); | 751 | struct virtio_driver, driver); |
789 | 752 | ||
790 | if (drv && drv->thaw) | 753 | ret = pci_enable_device(pci_dev); |
791 | ret = drv->thaw(&vp_dev->vdev); | 754 | if (ret) |
792 | else if (drv && drv->restore) | 755 | return ret; |
793 | ret = drv->restore(&vp_dev->vdev); | ||
794 | |||
795 | /* Finally, tell the device we're all set */ | ||
796 | if (!ret) | ||
797 | vp_set_status(&vp_dev->vdev, vp_dev->saved_status); | ||
798 | |||
799 | return ret; | ||
800 | } | ||
801 | |||
802 | static int virtio_pci_restore(struct device *dev) | ||
803 | { | ||
804 | struct pci_dev *pci_dev = to_pci_dev(dev); | ||
805 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); | ||
806 | struct virtio_driver *drv; | ||
807 | int ret; | ||
808 | 756 | ||
809 | drv = container_of(vp_dev->vdev.dev.driver, | 757 | pci_set_master(pci_dev); |
810 | struct virtio_driver, driver); | 758 | vp_finalize_features(&vp_dev->vdev); |
811 | 759 | ||
812 | ret = restore_common(dev); | 760 | if (drv && drv->restore) |
813 | if (!ret && drv && drv->restore) | ||
814 | ret = drv->restore(&vp_dev->vdev); | 761 | ret = drv->restore(&vp_dev->vdev); |
815 | 762 | ||
816 | /* Finally, tell the device we're all set */ | 763 | /* Finally, tell the device we're all set */ |
@@ -821,12 +768,7 @@ static int virtio_pci_restore(struct device *dev) | |||
821 | } | 768 | } |
822 | 769 | ||
823 | static const struct dev_pm_ops virtio_pci_pm_ops = { | 770 | static const struct dev_pm_ops virtio_pci_pm_ops = { |
824 | .suspend = virtio_pci_suspend, | 771 | SET_SYSTEM_SLEEP_PM_OPS(virtio_pci_freeze, virtio_pci_restore) |
825 | .resume = virtio_pci_resume, | ||
826 | .freeze = virtio_pci_freeze, | ||
827 | .thaw = virtio_pci_thaw, | ||
828 | .restore = virtio_pci_restore, | ||
829 | .poweroff = virtio_pci_suspend, | ||
830 | }; | 772 | }; |
831 | #endif | 773 | #endif |
832 | 774 | ||
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index d0018d27c281..8efd28ae5597 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
@@ -96,7 +96,6 @@ struct virtio_driver { | |||
96 | void (*config_changed)(struct virtio_device *dev); | 96 | void (*config_changed)(struct virtio_device *dev); |
97 | #ifdef CONFIG_PM | 97 | #ifdef CONFIG_PM |
98 | int (*freeze)(struct virtio_device *dev); | 98 | int (*freeze)(struct virtio_device *dev); |
99 | int (*thaw)(struct virtio_device *dev); | ||
100 | int (*restore)(struct virtio_device *dev); | 99 | int (*restore)(struct virtio_device *dev); |
101 | #endif | 100 | #endif |
102 | }; | 101 | }; |