From: Laura Abbott Date: Tue, 18 Apr 2017 18:27:04 +0000 (-0700) Subject: cma: Introduce cma_for_each_area X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e4231bcda72daef497af45e195a33daa0f9357d0;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git cma: Introduce cma_for_each_area 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/cma.h b/include/linux/cma.h index d41d1f8d1e28..3e8fbf5a5c73 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -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 diff --git a/mm/cma.c b/mm/cma.c index 43c1b2c1ac67..978b4a1441ef 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -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; +}