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: 3829271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C593ABF540 for ; Thu, 13 Mar 2014 22:50:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 065FA202B4 for ; Thu, 13 Mar 2014 22:50:53 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AAB2200DF for ; Thu, 13 Mar 2014 22:50:52 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOERN-0001XN-W3; Thu, 13 Mar 2014 22:49:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOER2-0002Ct-UJ; Thu, 13 Mar 2014 22:49:08 +0000 Received: from mail-wg0-f52.google.com ([74.125.82.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOEQO-000245-C7 for linux-arm-kernel@lists.infradead.org; Thu, 13 Mar 2014 22:48:29 +0000 Received: by mail-wg0-f52.google.com with SMTP id k14so1447356wgh.23 for ; Thu, 13 Mar 2014 15:48:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AWuLDMfnBeMMLIxIUcnhAM7KzByZRkLOVpNkMpdP8IM=; b=djBFlaoDUxtuzilv+QRMFMKfYOEnKN8ZjN7/RrioCbwe5U6JCu9BZXHnGHMczT8FKX ugdvltV3wC3WJBANnweqfw6eVbOzNoOLEOPoStD7EJ8QiqVCUaXjM2aO6tSW+rWfFUBw uAPF4O6w/kHQLKE65fXIlfLgWavjPLzTbtgZCv3cGnBtO9ATt0biYurNlO5O8YBOLrk3 ffHQzTYIXQhKxiXOEZCwTApGYkpU2Aziv1jLFn1N69pgfo7BqHEG65iy3S3tw189Wr67 U4aX/M+0WPV3R6oLArbF/Vy/FtgpewosfsTZ0DApAKZU72F86vackwxZTDRqO50XPrkd xl9g== X-Gm-Message-State: ALoCoQnzICk5jwdvEq5Y4498AFKpF1L2JJcGJzWitGXXmQnw8K9TrKorH0FtZPyV5v4JPJ9XyxKz 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140313_184828_596197_9E94A2AA X-CRM114-Status: UNSURE ( 8.30 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) Cc: roy.franz@linaro.org, Leif Lindholm , msalter@redhat.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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