aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/dmapool.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/mm/dmapool.c b/mm/dmapool.c
index b5ff9ce8765..744d541df86 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -106,17 +106,18 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
{
struct dma_pool *retval;
- if (align == 0)
+ if (align == 0) {
align = 1;
- if (size == 0)
+ } else if (align & (align - 1)) {
return NULL;
- else if (size < align)
- size = align;
- else if ((size % align) != 0) {
- size += align + 1;
- size &= ~(align - 1);
}
+ if (size == 0)
+ return NULL;
+
+ if ((size % align) != 0)
+ size = ALIGN(size, align);
+
if (allocation == 0) {
if (PAGE_SIZE < size)
allocation = size;