virtio: make virtqueue_add_buf() returning 0 on success, not capacity.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 16 Oct 2012 13:26:15 +0000 (23:56 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 18 Dec 2012 04:50:34 +0000 (15:20 +1030)
Now noone relies on this behavior, we simplify virtqueue_add_buf() so it
return 0 or -errno.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_ring.c

index 33a4ce0..ffd7e7d 100644 (file)
@@ -188,10 +188,7 @@ static int vring_add_indirect(struct vring_virtqueue *vq,
  * Caller must ensure we don't call this with other virtqueue operations
  * at the same time (except where noted).
  *
- * Returns remaining capacity of queue or a negative error
- * (ie. ENOSPC).  Note that it only really makes sense to treat all
- * positive return values as "available": indirect buffers mean that
- * we can put an entire sg[] array inside a single queue entry.
+ * Returns zero or a negative error (ie. ENOSPC, ENOMEM).
  */
 int virtqueue_add_buf(struct virtqueue *_vq,
                      struct scatterlist sg[],
@@ -291,7 +288,7 @@ add_head:
        pr_debug("Added buffer head %i to %p\n", head, vq);
        END_USE(vq);
 
-       return vq->vq.num_free;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(virtqueue_add_buf);