diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2009-06-13 00:16:36 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-06-12 08:46:36 -0400 |
commit | d2a7ddda9ffb1c8961abff6714b0f1eb925c120f (patch) | |
tree | 1090884fd260d042255255467367e4e6b6193e5d /drivers/char | |
parent | 9499f5e7ed5224c40706f0cec6542a9916bc7606 (diff) |
virtio: find_vqs/del_vqs virtio operations
This replaces find_vq/del_vq with find_vqs/del_vqs virtio operations,
and updates all drivers. This is needed for MSI support, because MSI
needs to know the total number of vectors upfront.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (+ lguest/9p compile fixes)
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 6 | ||||
-rw-r--r-- | drivers/char/virtio_console.c | 26 |
2 files changed, 14 insertions, 18 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 2aeafcea95fe..f2041fede822 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c | |||
@@ -94,13 +94,13 @@ static int virtrng_probe(struct virtio_device *vdev) | |||
94 | int err; | 94 | int err; |
95 | 95 | ||
96 | /* We expect a single virtqueue. */ | 96 | /* We expect a single virtqueue. */ |
97 | vq = vdev->config->find_vq(vdev, 0, random_recv_done, "input"); | 97 | vq = virtio_find_single_vq(vdev, random_recv_done, "input"); |
98 | if (IS_ERR(vq)) | 98 | if (IS_ERR(vq)) |
99 | return PTR_ERR(vq); | 99 | return PTR_ERR(vq); |
100 | 100 | ||
101 | err = hwrng_register(&virtio_hwrng); | 101 | err = hwrng_register(&virtio_hwrng); |
102 | if (err) { | 102 | if (err) { |
103 | vdev->config->del_vq(vq); | 103 | vdev->config->del_vqs(vdev); |
104 | return err; | 104 | return err; |
105 | } | 105 | } |
106 | 106 | ||
@@ -112,7 +112,7 @@ static void virtrng_remove(struct virtio_device *vdev) | |||
112 | { | 112 | { |
113 | vdev->config->reset(vdev); | 113 | vdev->config->reset(vdev); |
114 | hwrng_unregister(&virtio_hwrng); | 114 | hwrng_unregister(&virtio_hwrng); |
115 | vdev->config->del_vq(vq); | 115 | vdev->config->del_vqs(vdev); |
116 | } | 116 | } |
117 | 117 | ||
118 | static struct virtio_device_id id_table[] = { | 118 | static struct virtio_device_id id_table[] = { |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 58684e4a0814..c74dacfa6795 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -188,6 +188,9 @@ static void hvc_handle_input(struct virtqueue *vq) | |||
188 | * Finally we put our input buffer in the input queue, ready to receive. */ | 188 | * Finally we put our input buffer in the input queue, ready to receive. */ |
189 | static int __devinit virtcons_probe(struct virtio_device *dev) | 189 | static int __devinit virtcons_probe(struct virtio_device *dev) |
190 | { | 190 | { |
191 | vq_callback_t *callbacks[] = { hvc_handle_input, NULL}; | ||
192 | const char *names[] = { "input", "output" }; | ||
193 | struct virtqueue *vqs[2]; | ||
191 | int err; | 194 | int err; |
192 | 195 | ||
193 | vdev = dev; | 196 | vdev = dev; |
@@ -199,20 +202,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev) | |||
199 | goto fail; | 202 | goto fail; |
200 | } | 203 | } |
201 | 204 | ||
202 | /* Find the input queue. */ | 205 | /* Find the queues. */ |
203 | /* FIXME: This is why we want to wean off hvc: we do nothing | 206 | /* FIXME: This is why we want to wean off hvc: we do nothing |
204 | * when input comes in. */ | 207 | * when input comes in. */ |
205 | in_vq = vdev->config->find_vq(vdev, 0, hvc_handle_input, "input"); | 208 | err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names); |
206 | if (IS_ERR(in_vq)) { | 209 | if (err) |
207 | err = PTR_ERR(in_vq); | ||
208 | goto free; | 210 | goto free; |
209 | } | ||
210 | 211 | ||
211 | out_vq = vdev->config->find_vq(vdev, 1, NULL, "output"); | 212 | in_vq = vqs[0]; |
212 | if (IS_ERR(out_vq)) { | 213 | out_vq = vqs[1]; |
213 | err = PTR_ERR(out_vq); | ||
214 | goto free_in_vq; | ||
215 | } | ||
216 | 214 | ||
217 | /* Start using the new console output. */ | 215 | /* Start using the new console output. */ |
218 | virtio_cons.get_chars = get_chars; | 216 | virtio_cons.get_chars = get_chars; |
@@ -233,17 +231,15 @@ static int __devinit virtcons_probe(struct virtio_device *dev) | |||
233 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); | 231 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); |
234 | if (IS_ERR(hvc)) { | 232 | if (IS_ERR(hvc)) { |
235 | err = PTR_ERR(hvc); | 233 | err = PTR_ERR(hvc); |
236 | goto free_out_vq; | 234 | goto free_vqs; |
237 | } | 235 | } |
238 | 236 | ||
239 | /* Register the input buffer the first time. */ | 237 | /* Register the input buffer the first time. */ |
240 | add_inbuf(); | 238 | add_inbuf(); |
241 | return 0; | 239 | return 0; |
242 | 240 | ||
243 | free_out_vq: | 241 | free_vqs: |
244 | vdev->config->del_vq(out_vq); | 242 | vdev->config->del_vqs(vdev); |
245 | free_in_vq: | ||
246 | vdev->config->del_vq(in_vq); | ||
247 | free: | 243 | free: |
248 | kfree(inbuf); | 244 | kfree(inbuf); |
249 | fail: | 245 | fail: |