Skip to content

Commit

Permalink
mm/vmalloc: use offset_in_page macro
Browse files Browse the repository at this point in the history
linux/mm.h provides offset_in_page() macro.  Let's use already predefined
macro instead of (addr & ~PAGE_MASK).

Signed-off-by: Alexander Kuleshov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
0xAX authored and torvalds committed Nov 6, 2015
1 parent 8fd9e48 commit 891c49a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mm/vmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
struct vmap_area *first;

BUG_ON(!size);
BUG_ON(size & ~PAGE_MASK);
BUG_ON(offset_in_page(size));
BUG_ON(!is_power_of_2(align));

va = kmalloc_node(sizeof(struct vmap_area),
Expand Down Expand Up @@ -936,7 +936,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
void *vaddr = NULL;
unsigned int order;

BUG_ON(size & ~PAGE_MASK);
BUG_ON(offset_in_page(size));
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
if (WARN_ON(size == 0)) {
/*
Expand Down Expand Up @@ -989,7 +989,7 @@ static void vb_free(const void *addr, unsigned long size)
unsigned int order;
struct vmap_block *vb;

BUG_ON(size & ~PAGE_MASK);
BUG_ON(offset_in_page(size));
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);

flush_cache_vunmap((unsigned long)addr, (unsigned long)addr + size);
Expand Down Expand Up @@ -1902,7 +1902,7 @@ static int aligned_vread(char *buf, char *addr, unsigned long count)
while (count) {
unsigned long offset, length;

offset = (unsigned long)addr & ~PAGE_MASK;
offset = offset_in_page(addr);
length = PAGE_SIZE - offset;
if (length > count)
length = count;
Expand Down Expand Up @@ -1941,7 +1941,7 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count)
while (count) {
unsigned long offset, length;

offset = (unsigned long)addr & ~PAGE_MASK;
offset = offset_in_page(addr);
length = PAGE_SIZE - offset;
if (length > count)
length = count;
Expand Down Expand Up @@ -2392,7 +2392,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
bool purged = false;

/* verify parameters and allocate data structures */
BUG_ON(align & ~PAGE_MASK || !is_power_of_2(align));
BUG_ON(offset_in_page(align) || !is_power_of_2(align));
for (last_area = 0, area = 0; area < nr_vms; area++) {
start = offsets[area];
end = start + sizes[area];
Expand Down

0 comments on commit 891c49a

Please sign in to comment.