From patchwork Tue Apr 18 18:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9686043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EBA9601C2 for ; Tue, 18 Apr 2017 18:30:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84F5324DA2 for ; Tue, 18 Apr 2017 18:30:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 791C02838E; Tue, 18 Apr 2017 18:30:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 305DD24DA2 for ; Tue, 18 Apr 2017 18:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753472AbdDRSao (ORCPT ); Tue, 18 Apr 2017 14:30:44 -0400 Received: from mail-qk0-f176.google.com ([209.85.220.176]:35564 "EHLO mail-qk0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756203AbdDRS1c (ORCPT ); Tue, 18 Apr 2017 14:27:32 -0400 Received: by mail-qk0-f176.google.com with SMTP id f133so1183540qke.2 for ; Tue, 18 Apr 2017 11:27:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u4DoFJJI4AfDMMvX7FVu5xXVhMrTyMwU15pfIegY2wY=; b=ZoZfiGr/nj6fPwSwpphN+L/1am8WiGPfv2rLRz/a7dP2qlR1EGIlolKag7LyhFaL1C Il3gb31GbiYs8b8E0MsYp6SsmQeWTTLbH6WsONNcWDx7NorGHdDHYorQORzBHZwx2gT7 jhs9npcChtvwYAIGSutshUrBOFO8KXNy8gs4aD/Tr2M3iIxz5PeFHg2VojsJ5JSO95UY wk91P9rMX+J30cEILSN9KICR+kfEdK23s8q1NdMWQmzeZx85AIXGjKcF91KbvyQddcbw phYLY41xLw4rEmUtLZfO7kNPzKgQWZTWFco39SAIAZ9eXmiSOVMFZrv36CSWcizGo48c s2Mg== X-Gm-Message-State: AN3rC/7PMpfscMnZNwh7fqp9tIzByCtbwHX3pGFGWkzI0W3vJ3UdMf2L qOys0rZdzMVSu8wX X-Received: by 10.55.75.68 with SMTP id y65mr13636849qka.2.1492540046833; Tue, 18 Apr 2017 11:27:26 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc::159c]) by smtp.gmail.com with ESMTPSA id q66sm10142381qkd.69.2017.04.18.11.27.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 11:27:25 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , Riley Andrews , arve@android.com, Greg Kroah-Hartman Cc: Laura Abbott , romlem@google.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, 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, Laurent Pinchart Subject: [PATCHv4 02/12] cma: Introduce cma_for_each_area Date: Tue, 18 Apr 2017 11:27:04 -0700 Message-Id: <1492540034-5466-3-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492540034-5466-1-git-send-email-labbott@redhat.com> References: <1492540034-5466-1-git-send-email-labbott@redhat.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 d41d1f8..3e8fbf5 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 43c1b2c..978b4a1 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; +}