aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWang Sheng-Hui <shhuiw@gmail.com>2011-08-29 03:55:59 -0400
committerRusty Russell <rusty@rustcorp.com.au>2011-11-01 21:10:59 -0400
commit00b894e874581f6b388c5817d4d5546c22cf9640 (patch)
tree18cf5e1b2067986b36996dc75321cea7c9935ac2 /include
parent5f41f8bfc95e84536207b2af8918f2e674164a42 (diff)
virtio: modify vring_init and vring_size to take account of the layout containing *_event_idx
Based on the layout description in the comments, take account of the *_event_idx in functions vring_init and vring_size. Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include')
-rw-r--r--include/linux/virtio_ring.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 4a32cb6da425..36be0f6e18a9 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -135,13 +135,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
135 vr->num = num; 135 vr->num = num;
136 vr->desc = p; 136 vr->desc = p;
137 vr->avail = p + num*sizeof(struct vring_desc); 137 vr->avail = p + num*sizeof(struct vring_desc);
138 vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1) 138 vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__u16)
139 & ~(align - 1)); 139 + align-1) & ~(align - 1));
140} 140}
141 141
142static inline unsigned vring_size(unsigned int num, unsigned long align) 142static inline unsigned vring_size(unsigned int num, unsigned long align)
143{ 143{
144 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) 144 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
145 + align - 1) & ~(align - 1)) 145 + align - 1) & ~(align - 1))
146 + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num; 146 + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
147} 147}