From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: [PATCH 1/5] kvm: qemu: virtio: move virtqueue_next_desc() around Date: Wed, 26 Nov 2008 14:50:34 +0000 Message-ID: <1227711038-21942-2-git-send-email-markmc@redhat.com> References: <1223991840.11098.29.camel@blaa> <1227711038-21942-1-git-send-email-markmc@redhat.com> Cc: kvm@vger.kernel.org, Rusty Russell , Herbert Xu , Anthony Liguori , Mark McLoughlin To: Avi Kivity Return-path: Received: from mail05.svc.cra.dublin.eircom.net ([159.134.118.21]:40021 "HELO mail05.svc.cra.dublin.eircom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752403AbYKZOvy (ORCPT ); Wed, 26 Nov 2008 09:51:54 -0500 In-Reply-To: <1227711038-21942-1-git-send-email-markmc@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: virtio_next_desc() is only used in virtqueue_pop(), so move them alongside one another. Signed-off-by: Mark McLoughlin --- qemu/hw/virtio.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) diff --git a/qemu/hw/virtio.c b/qemu/hw/virtio.c index 8fac354..fe0a120 100644 --- a/qemu/hw/virtio.c +++ b/qemu/hw/virtio.c @@ -107,6 +107,21 @@ static void virtqueue_init(VirtQueue *vq, void *p) vq->vring.used = (void *)TARGET_PAGE_ALIGN((unsigned long)&vq->vring.avail->ring[vq->vring.num]); } +void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, + unsigned int len) +{ + VRingUsedElem *used; + + /* Get a pointer to the next entry in the used ring. */ + used = &vq->vring.used->ring[vq->vring.used->idx % vq->vring.num]; + used->id = elem->index; + used->len = len; + /* Make sure buffer is written before we update index. */ + wmb(); + vq->vring.used->idx++; + vq->inuse--; +} + static unsigned virtqueue_next_desc(VirtQueue *vq, unsigned int i) { unsigned int next; @@ -126,21 +141,6 @@ static unsigned virtqueue_next_desc(VirtQueue *vq, unsigned int i) return next; } -void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, - unsigned int len) -{ - VRingUsedElem *used; - - /* Get a pointer to the next entry in the used ring. */ - used = &vq->vring.used->ring[vq->vring.used->idx % vq->vring.num]; - used->id = elem->index; - used->len = len; - /* Make sure buffer is written before we update index. */ - wmb(); - vq->vring.used->idx++; - vq->inuse--; -} - int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) { unsigned int i, head; -- 1.5.4.3