From patchwork Thu Mar 13 22:46:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 26236 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2BC18203AC for ; Thu, 13 Mar 2014 22:52:02 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id fb1sf4051139pad.0 for ; Thu, 13 Mar 2014 15:52:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=qQz7mcgVtMiIERG8yKftN6+hXwJkAwuxPylGu0E0L1o=; b=c8x4RsQcdAP4OalZ/vUjDpFmYd4JRZkTOxrXNh5TwerkTgu6tiYGUEx07YvnP/MGIK HKqynhPRmfQnborDQq7I1eRorX2R3ZRmQIy0WHM8mC3cLCrDOQcKNdtliuOHvmxHs+jk T6NHfsNsmZ+E459A+1cSGt46ywnNioRmXkMCUdi6xGa8yiEQ10vg/uwWdfobQdiuTU/4 Q56gBAf+ft7MGwTELOnmJrKtK/zOD3Xg+Q2QVf7fhVkLNiA9iTvhDYL6IUXbBQFRGDEp Li550NxBm/zyOM1qJzAORvhnYmmGUm2ScZronxgv5L+u8d2kHnnHskTGxUSwkhwuGnra 92lw== X-Gm-Message-State: ALoCoQkrMQkorsqMzWkm0SBPKFyPlTJjlytV+XnWtJq7p4EiHj54BcPRIzrZBz+A5n1UShVjYt9D X-Received: by 10.66.240.37 with SMTP id vx5mr1702202pac.8.1394751121456; Thu, 13 Mar 2014 15:52:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.233 with SMTP id l96ls461323qgl.90.gmail; Thu, 13 Mar 2014 15:52:01 -0700 (PDT) X-Received: by 10.220.103.141 with SMTP id k13mr3488510vco.25.1394751121332; Thu, 13 Mar 2014 15:52:01 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id rl1si1374285vcb.74.2014.03.13.15.52.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Mar 2014 15:52:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so1832510veb.8 for ; Thu, 13 Mar 2014 15:52:01 -0700 (PDT) X-Received: by 10.58.57.67 with SMTP id g3mr3485735veq.3.1394751121249; Thu, 13 Mar 2014 15:52:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp10382vck; Thu, 13 Mar 2014 15:52:00 -0700 (PDT) X-Received: by 10.66.156.4 with SMTP id wa4mr5405233pab.49.1394751113152; Thu, 13 Mar 2014 15:51:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pi6si3645128pbb.190.2014.03.13.15.51.52; Thu, 13 Mar 2014 15:51:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755386AbaCMWsN (ORCPT + 26 others); Thu, 13 Mar 2014 18:48:13 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:58763 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755309AbaCMWsF (ORCPT ); Thu, 13 Mar 2014 18:48:05 -0400 Received: by mail-wg0-f51.google.com with SMTP id k14so1479814wgh.10 for ; Thu, 13 Mar 2014 15:48:04 -0700 (PDT) X-Received: by 10.180.73.19 with SMTP id h19mr3601222wiv.40.1394750884085; Thu, 13 Mar 2014 15:48:04 -0700 (PDT) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by mx.google.com with ESMTPSA id dk9sm9072133wjb.4.2014.03.13.15.48.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Mar 2014 15:48:03 -0700 (PDT) From: Leif Lindholm To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, matt.fleming@intel.com Cc: msalter@redhat.com, roy.franz@linaro.org, Leif Lindholm Subject: [PATCH v2 03/15] efi: create memory map iteration helper Date: Thu, 13 Mar 2014 22:46:56 +0000 Message-Id: <1394750828-16351-4-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394750828-16351-1-git-send-email-leif.lindholm@linaro.org> References: <1394750828-16351-1-git-send-email-leif.lindholm@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mark Salter There are a lot of places in the kernel which iterate through an EFI memory map. Most of these places use essentially the same for-loop code. This patch adds a for_each_efi_memory_desc() helper to clean up all of the existing duplicate code and avoid more in the future. Signed-off-by: Mark Salter Signed-off-by: Leif Lindholm --- include/linux/efi.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/efi.h b/include/linux/efi.h index 64d532c..a3276da 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -622,6 +622,12 @@ extern int efi_set_rtc_mmss(const struct timespec *now); extern void efi_reserve_boot_services(void); extern struct efi_memory_map memmap; +/* Iterate through an efi_memory_map */ +#define for_each_efi_memory_desc(m, md) \ + for ((md) = (m)->map; \ + (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \ + (md) = (void *)(md) + (m)->desc_size) + /** * efi_range_is_wc - check the WC bit on an address range * @start: starting kvirt address