aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-04-12 09:19:07 -0400
committerRusty Russell <rusty@rustcorp.com.au>2010-05-19 08:45:43 -0400
commit7c5e9ed0c84e7d70d887878574590638d5572659 (patch)
treec929c367c6854f021b787fa99fc56d37f64d9bc0 /drivers/virtio
parent1915a712f210f0b63d10bc4f875e8e66aac7a2c4 (diff)
virtio_ring: remove a level of indirection
We have a single virtqueue_ops implementation, and it seems unlikely we'll get another one at this point. So let's remove an unnecessary level of indirection: it would be very easy to re-add it if another implementation surfaces. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_ring.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 0f90634bcb85..0717b5b000bb 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -155,11 +155,11 @@ static int vring_add_indirect(struct vring_virtqueue *vq,
155 return head; 155 return head;
156} 156}
157 157
158static int vring_add_buf(struct virtqueue *_vq, 158int virtqueue_add_buf(struct virtqueue *_vq,
159 struct scatterlist sg[], 159 struct scatterlist sg[],
160 unsigned int out, 160 unsigned int out,
161 unsigned int in, 161 unsigned int in,
162 void *data) 162 void *data)
163{ 163{
164 struct vring_virtqueue *vq = to_vvq(_vq); 164 struct vring_virtqueue *vq = to_vvq(_vq);
165 unsigned int i, avail, head, uninitialized_var(prev); 165 unsigned int i, avail, head, uninitialized_var(prev);
@@ -232,8 +232,9 @@ add_head:
232 return vq->num_free ? vq->vring.num : 0; 232 return vq->num_free ? vq->vring.num : 0;
233 return vq->num_free; 233 return vq->num_free;
234} 234}
235EXPORT_SYMBOL_GPL(virtqueue_add_buf);
235 236
236static void vring_kick(struct virtqueue *_vq) 237void virtqueue_kick(struct virtqueue *_vq)
237{ 238{
238 struct vring_virtqueue *vq = to_vvq(_vq); 239 struct vring_virtqueue *vq = to_vvq(_vq);
239 START_USE(vq); 240 START_USE(vq);
@@ -253,6 +254,7 @@ static void vring_kick(struct virtqueue *_vq)
253 254
254 END_USE(vq); 255 END_USE(vq);
255} 256}
257EXPORT_SYMBOL_GPL(virtqueue_kick);
256 258
257static void detach_buf(struct vring_virtqueue *vq, unsigned int head) 259static void detach_buf(struct vring_virtqueue *vq, unsigned int head)
258{ 260{
@@ -284,7 +286,7 @@ static inline bool more_used(const struct vring_virtqueue *vq)
284 return vq->last_used_idx != vq->vring.used->idx; 286 return vq->last_used_idx != vq->vring.used->idx;
285} 287}
286 288
287static void *vring_get_buf(struct virtqueue *_vq, unsigned int *len) 289void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len)
288{ 290{
289 struct vring_virtqueue *vq = to_vvq(_vq); 291 struct vring_virtqueue *vq = to_vvq(_vq);
290 void *ret; 292 void *ret;
@@ -325,15 +327,17 @@ static void *vring_get_buf(struct virtqueue *_vq, unsigned int *len)
325 END_USE(vq); 327 END_USE(vq);
326 return ret; 328 return ret;
327} 329}
330EXPORT_SYMBOL_GPL(virtqueue_get_buf);
328 331
329static void vring_disable_cb(struct virtqueue *_vq) 332void virtqueue_disable_cb(struct virtqueue *_vq)
330{ 333{
331 struct vring_virtqueue *vq = to_vvq(_vq); 334 struct vring_virtqueue *vq = to_vvq(_vq);
332 335
333 vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; 336 vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
334} 337}
338EXPORT_SYMBOL_GPL(virtqueue_disable_cb);
335 339
336static bool vring_enable_cb(struct virtqueue *_vq) 340bool virtqueue_enable_cb(struct virtqueue *_vq)
337{ 341{
338 struct vring_virtqueue *vq = to_vvq(_vq); 342 struct vring_virtqueue *vq = to_vvq(_vq);
339 343
@@ -351,8 +355,9 @@ static bool vring_enable_cb(struct virtqueue *_vq)
351 END_USE(vq); 355 END_USE(vq);
352 return true; 356 return true;
353} 357}
358EXPORT_SYMBOL_GPL(virtqueue_enable_cb);
354 359
355static void *vring_detach_unused_buf(struct virtqueue *_vq) 360void *virtqueue_detach_unused_buf(struct virtqueue *_vq)
356{ 361{
357 struct vring_virtqueue *vq = to_vvq(_vq); 362 struct vring_virtqueue *vq = to_vvq(_vq);
358 unsigned int i; 363 unsigned int i;
@@ -375,6 +380,7 @@ static void *vring_detach_unused_buf(struct virtqueue *_vq)
375 END_USE(vq); 380 END_USE(vq);
376 return NULL; 381 return NULL;
377} 382}
383EXPORT_SYMBOL_GPL(virtqueue_detach_unused_buf);
378 384
379irqreturn_t vring_interrupt(int irq, void *_vq) 385irqreturn_t vring_interrupt(int irq, void *_vq)
380{ 386{
@@ -396,15 +402,6 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
396} 402}
397EXPORT_SYMBOL_GPL(vring_interrupt); 403EXPORT_SYMBOL_GPL(vring_interrupt);
398 404
399static struct virtqueue_ops vring_vq_ops = {
400 .add_buf = vring_add_buf,
401 .get_buf = vring_get_buf,
402 .kick = vring_kick,
403 .disable_cb = vring_disable_cb,
404 .enable_cb = vring_enable_cb,
405 .detach_unused_buf = vring_detach_unused_buf,
406};
407
408struct virtqueue *vring_new_virtqueue(unsigned int num, 405struct virtqueue *vring_new_virtqueue(unsigned int num,
409 unsigned int vring_align, 406 unsigned int vring_align,
410 struct virtio_device *vdev, 407 struct virtio_device *vdev,
@@ -429,7 +426,6 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
429 vring_init(&vq->vring, num, pages, vring_align); 426 vring_init(&vq->vring, num, pages, vring_align);
430 vq->vq.callback = callback; 427 vq->vq.callback = callback;
431 vq->vq.vdev = vdev; 428 vq->vq.vdev = vdev;
432 vq->vq.vq_ops = &vring_vq_ops;
433 vq->vq.name = name; 429 vq->vq.name = name;
434 vq->notify = notify; 430 vq->notify = notify;
435 vq->broken = false; 431 vq->broken = false;