From patchwork Tue May 31 15:14:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 68945 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2013676qge; Tue, 31 May 2016 08:16:06 -0700 (PDT) X-Received: by 10.98.65.92 with SMTP id o89mr55012430pfa.72.1464707766894; Tue, 31 May 2016 08:16:06 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id b6si9260283pay.99.2016.05.31.08.16.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 May 2016 08:16:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7lNk-0004dK-WE; Tue, 31 May 2016 15:15:01 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7lNi-0004a3-Bc for linux-arm-kernel@lists.infradead.org; Tue, 31 May 2016 15:14:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B25694C; Tue, 31 May 2016 08:15:07 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DC9053F246; Tue, 31 May 2016 08:14:37 -0700 (PDT) From: Catalin Marinas To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] efi: Introduce *_continue efi_memory_desc iterators Date: Tue, 31 May 2016 16:14:30 +0100 Message-Id: <1464707672-21882-2-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464707672-21882-1-git-send-email-catalin.marinas@arm.com> References: <1464707672-21882-1-git-send-email-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160531_081458_424002_8653DEA1 X-CRM114-Status: UNSURE ( 9.43 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -8.3 (--------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-8.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matt Fleming , Mark Rutland , linux-efi@vger.kernel.org, Will Deacon , Jeremy Linton MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The for_each_efi_memory_desc_continue() macro and corresponding "_in_map" allow iterating over an efi_memory_map from a given position. For code reuse between the existing iterator and the _continue variant, this patch also introduces efi_memory_desc_next_entry_map(). Cc: Matt Fleming Signed-off-by: Catalin Marinas --- include/linux/efi.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/include/linux/efi.h b/include/linux/efi.h index c2db3ca22217..4b0d880f1cd7 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1002,11 +1002,16 @@ extern int efi_memattr_init(void); extern int efi_memattr_apply_permissions(struct mm_struct *mm, efi_memattr_perm_setter fn); +/* Find next entry in an efi_memory_map or NULL if md is last */ +#define efi_memory_desc_next_entry_map(m, md) \ + ((md) == (efi_memory_desc_t *)((m)->map_end - (m)->desc_size) \ + ? NULL : (void *)(md) + (m)->desc_size) + /* Iterate through an efi_memory_map */ #define for_each_efi_memory_desc_in_map(m, md) \ for ((md) = (m)->map; \ - (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \ - (md) = (void *)(md) + (m)->desc_size) + (md); \ + (md) = efi_memory_desc_next_entry_map(m, md)) /** * for_each_efi_memory_desc - iterate over descriptors in efi.memmap @@ -1017,6 +1022,16 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm, #define for_each_efi_memory_desc(md) \ for_each_efi_memory_desc_in_map(&efi.memmap, md) +/* Continue iterating through an efi_memory_map */ +#define for_each_efi_memory_desc_in_map_continue(m, md) \ + for ((md) = efi_memory_desc_next_entry_map(m, md); \ + (md); \ + (md) = efi_memory_desc_next_entry_map(m, md)) + +/* Continue iterating through efi.memmap */ +#define for_each_efi_memory_desc_continue(md) \ + for_each_efi_memory_desc_in_map_continue(&efi.memmap, md) + /* * Format an EFI memory descriptor's type and attributes to a user-provided * character buffer, as per snprintf(), and return the buffer.