From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id E7C7B6B0392 for ; Thu, 2 Mar 2017 16:45:21 -0500 (EST) Received: by mail-qk0-f198.google.com with SMTP id j127so19062210qke.2 for ; Thu, 02 Mar 2017 13:45:21 -0800 (PST) Received: from mail-qk0-f170.google.com (mail-qk0-f170.google.com. [209.85.220.170]) by mx.google.com with ESMTPS id y14si7917516qka.150.2017.03.02.13.45.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 13:45:21 -0800 (PST) Received: by mail-qk0-f170.google.com with SMTP id s186so146630516qkb.1 for ; Thu, 02 Mar 2017 13:45:21 -0800 (PST) From: Laura Abbott Subject: [RFC PATCH 09/12] cma: Introduce cma_for_each_area Date: Thu, 2 Mar 2017 13:44:41 -0800 Message-Id: <1488491084-17252-10-git-send-email-labbott@redhat.com> In-Reply-To: <1488491084-17252-1-git-send-email-labbott@redhat.com> References: <1488491084-17252-1-git-send-email-labbott@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Sumit Semwal , Riley Andrews , arve@android.com Cc: Laura Abbott , romlem@google.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, Brian Starkey , Daniel Vetter , Mark Brown , Benjamin Gaignard , linux-mm@kvack.org 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 --- include/linux/cma.h | 2 ++ mm/cma.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/cma.h b/include/linux/cma.h index 49f98ea..b521e3c 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -33,4 +33,6 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, struct cma **res_cma); extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align); 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 4a93d2b..a430df0 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -464,3 +464,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; +} -- 2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org