virtio: rng: s3/s4 support
authorAmit Shah <amit.shah@redhat.com>
Mon, 28 May 2012 06:48:43 +0000 (12:18 +0530)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 30 Jul 2012 04:00:50 +0000 (13:30 +0930)
Unregister from the hwrng interface and remove the vq before entering
the S3 or S4 states.  Add the vq and re-register with hwrng on restore.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/hw_random/virtio-rng.c

index a9673a7..5708299 100644 (file)
@@ -124,6 +124,19 @@ static void __devexit virtrng_remove(struct virtio_device *vdev)
        remove_common(vdev);
 }
 
+#ifdef CONFIG_PM
+static int virtrng_freeze(struct virtio_device *vdev)
+{
+       remove_common(vdev);
+       return 0;
+}
+
+static int virtrng_restore(struct virtio_device *vdev)
+{
+       return probe_common(vdev);
+}
+#endif
+
 static struct virtio_device_id id_table[] = {
        { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID },
        { 0 },
@@ -135,6 +148,10 @@ static struct virtio_driver virtio_rng_driver = {
        .id_table =     id_table,
        .probe =        virtrng_probe,
        .remove =       __devexit_p(virtrng_remove),
+#ifdef CONFIG_PM
+       .freeze =       virtrng_freeze,
+       .restore =      virtrng_restore,
+#endif
 };
 
 static int __init init(void)