[PATCH] virtio, ring: Use ALIGN macros in virtio_ring.h
From: Liu Yuan
Date: Tue Apr 26 2011 - 00:11:31 EST
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/