Skip to content

Commit

Permalink
cma: Introduce cma_for_each_area
Browse files Browse the repository at this point in the history
Frameworks (e.g. Ion) may want to iterate over each possible CMA area to
allow for enumeration. Introduce a function to allow a callback.

Signed-off-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Laura Abbott authored and Greg Kroah-Hartman committed Apr 18, 2017
1 parent f318dd0 commit e4231bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/cma.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
gfp_t gfp_mask);
extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);

extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
#endif
14 changes: 14 additions & 0 deletions mm/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,17 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)

return true;
}

int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
{
int i;

for (i = 0; i < cma_area_count; i++) {
int ret = it(&cma_areas[i], data);

if (ret)
return ret;
}

return 0;
}

0 comments on commit e4231bc

Please sign in to comment.