aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hw_random
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 16:24:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 16:24:37 -0400
commit95b18e69950ca7fd9acfa55964e929f58bec9379 (patch)
tree5168f81b49cdfa2bcf363e4bd86cbfd669493ebd /drivers/char/hw_random
parent6d8a97af63222c5cbc7fe63ae19345e74e153e90 (diff)
parent6a743897144500fb4c4566ced3a498d5180fbb5b (diff)
Merge tag 'virtio-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
Pull virtio update from Rusty Russell: "Virtio patches, mainly hotplugging fixes." * tag 'virtio-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: virtio-blk: return VIRTIO_BLK_F_FLUSH to header. virtio-blk: allow toggling host cache between writeback and writethrough virtio-blk: Use block layer provided spinlock virtio-blk: Reset device after blk_cleanup_queue() virtio-blk: Call del_gendisk() before disable guest kick virtio: rng: s3/s4 support virtio: rng: split out common code in probe / remove for s3/s4 ops virtio: rng: don't wait on host when module is going away virtio: rng: allow tasks to be killed that are waiting for rng input virtio ids: fix comment for virtio-rng
Diffstat (limited to 'drivers/char/hw_random')
-rw-r--r--drivers/char/hw_random/virtio-rng.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 723725bbb96b..5708299507d0 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -55,6 +55,7 @@ static void register_buffer(u8 *buf, size_t size)
55 55
56static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait) 56static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
57{ 57{
58 int ret;
58 59
59 if (!busy) { 60 if (!busy) {
60 busy = true; 61 busy = true;
@@ -65,7 +66,9 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
65 if (!wait) 66 if (!wait)
66 return 0; 67 return 0;
67 68
68 wait_for_completion(&have_data); 69 ret = wait_for_completion_killable(&have_data);
70 if (ret < 0)
71 return ret;
69 72
70 busy = false; 73 busy = false;
71 74
@@ -85,7 +88,7 @@ static struct hwrng virtio_hwrng = {
85 .read = virtio_read, 88 .read = virtio_read,
86}; 89};
87 90
88static int virtrng_probe(struct virtio_device *vdev) 91static int probe_common(struct virtio_device *vdev)
89{ 92{
90 int err; 93 int err;
91 94
@@ -103,13 +106,37 @@ static int virtrng_probe(struct virtio_device *vdev)
103 return 0; 106 return 0;
104} 107}
105 108
106static void __devexit virtrng_remove(struct virtio_device *vdev) 109static void remove_common(struct virtio_device *vdev)
107{ 110{
108 vdev->config->reset(vdev); 111 vdev->config->reset(vdev);
112 busy = false;
109 hwrng_unregister(&virtio_hwrng); 113 hwrng_unregister(&virtio_hwrng);
110 vdev->config->del_vqs(vdev); 114 vdev->config->del_vqs(vdev);
111} 115}
112 116
117static int virtrng_probe(struct virtio_device *vdev)
118{
119 return probe_common(vdev);
120}
121
122static void __devexit virtrng_remove(struct virtio_device *vdev)
123{
124 remove_common(vdev);
125}
126
127#ifdef CONFIG_PM
128static int virtrng_freeze(struct virtio_device *vdev)
129{
130 remove_common(vdev);
131 return 0;
132}
133
134static int virtrng_restore(struct virtio_device *vdev)
135{
136 return probe_common(vdev);
137}
138#endif
139
113static struct virtio_device_id id_table[] = { 140static struct virtio_device_id id_table[] = {
114 { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID }, 141 { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID },
115 { 0 }, 142 { 0 },
@@ -121,6 +148,10 @@ static struct virtio_driver virtio_rng_driver = {
121 .id_table = id_table, 148 .id_table = id_table,
122 .probe = virtrng_probe, 149 .probe = virtrng_probe,
123 .remove = __devexit_p(virtrng_remove), 150 .remove = __devexit_p(virtrng_remove),
151#ifdef CONFIG_PM
152 .freeze = virtrng_freeze,
153 .restore = virtrng_restore,
154#endif
124}; 155};
125 156
126static int __init init(void) 157static int __init init(void)