]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/cma.c
mm/memory-hotplug: switch locking to a percpu rwsem
[karo-tx-linux.git] / mm / cma.c
index 978b4a1441ef7120678e1fc7973b38c8ccf4dd5a..c0da318c020e6c6d666ac8cf7cb92b2d4a47ceae 100644 (file)
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -59,7 +59,7 @@ const char *cma_get_name(const struct cma *cma)
 }
 
 static unsigned long cma_bitmap_aligned_mask(const struct cma *cma,
-                                            int align_order)
+                                            unsigned int align_order)
 {
        if (align_order <= cma->order_per_bit)
                return 0;
@@ -67,17 +67,14 @@ static unsigned long cma_bitmap_aligned_mask(const struct cma *cma,
 }
 
 /*
- * Find a PFN aligned to the specified order and return an offset represented in
- * order_per_bits.
+ * Find the offset of the base PFN from the specified align_order.
+ * The value returned is represented in order_per_bits.
  */
 static unsigned long cma_bitmap_aligned_offset(const struct cma *cma,
-                                              int align_order)
+                                              unsigned int align_order)
 {
-       if (align_order <= cma->order_per_bit)
-               return 0;
-
-       return (ALIGN(cma->base_pfn, (1UL << align_order))
-               - cma->base_pfn) >> cma->order_per_bit;
+       return (cma->base_pfn & ((1UL << align_order) - 1))
+               >> cma->order_per_bit;
 }
 
 static unsigned long cma_bitmap_pages_to_bits(const struct cma *cma,
@@ -127,7 +124,7 @@ static int __init cma_activate_area(struct cma *cma)
                         * to be in the same zone.
                         */
                        if (page_zone(pfn_to_page(pfn)) != zone)
-                               goto err;
+                               goto not_in_zone;
                }
                init_cma_reserved_pageblock(pfn_to_page(base_pfn));
        } while (--i);
@@ -141,7 +138,8 @@ static int __init cma_activate_area(struct cma *cma)
 
        return 0;
 
-err:
+not_in_zone:
+       pr_err("CMA area %s could not be activated\n", cma->name);
        kfree(cma->bitmap);
        cma->count = 0;
        return -EINVAL;