From: Liu Yuan <tailai.ly@xxxxxxxxxx> Signed-off-by: Liu Yuan <tailai.ly@xxxxxxxxxx> --- include/linux/virtio_ring.h | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index e4d144b..6299050 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -99,15 +99,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p, vr->num = num; vr->desc = p; vr->avail = p + num*sizeof(struct vring_desc); - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1) - & ~(align - 1)); + vr->used = (void *)PTR_ALIGN(&vr->avail->ring[num], align); } static inline unsigned vring_size(unsigned int num, unsigned long align) { - return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) - + align - 1) & ~(align - 1)) - + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num; + return ((sizeof(struct vring_desc) * num + ALIGN(sizeof(__u16) * (2 + num), align)) + + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num); } #ifdef __KERNEL__ -- 1.7.1 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/virtualization