From patchwork Fri Jan 10 22:29:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 23116 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1798C216DB for ; Fri, 10 Jan 2014 22:29:35 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id f12sf8211861vbg.8 for ; Fri, 10 Jan 2014 14:29:34 -0800 (PST) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=bQ+2A3tX7PVyVkT4TkihHTDcl9qNBEokn23Ka4rJtEc=; b=jQkxb1IFoMpweMOfXDsvLb8zR1PoKhNPG9NikNtx5IlAozXxvmKubSPGwzGqRCsOTa dy60rhVDGsTCPsQ7pOOBLVWQ7pA8eIeJTetOKbnXPINpoubg/epoGMGPSO9N6gplu8Cw mgJlVrke+f+wkLL6FEVhWu60/zsX1xfzKOVdQPYywETrhBElN8QgYEXnANTMYv+k26hu 8/Wfm4j60bN8zwxjMVtqYLOk90tbg03OpznHewmzSaR9bdfp7VpdINV47KhU0wp2G9Xn OT7sUVvXskfVNtljlBpSYv+5Tsu9ps6E6L55ex8mqn/42a7LyJjA7pgOGHc/TZ/EyAoj wvrQ== X-Gm-Message-State: ALoCoQntAGaBSO/nDPa8RbHJtk9jppBJHAegHwF2LiRPy6s7b9zq+ssJfJCzQ/rpWAsUR3UdpdIh X-Received: by 10.236.127.199 with SMTP id d47mr3592477yhi.29.1389392973763; Fri, 10 Jan 2014 14:29:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.50.196 with SMTP id e4ls1675809qeo.3.gmail; Fri, 10 Jan 2014 14:29:33 -0800 (PST) X-Received: by 10.52.109.105 with SMTP id hr9mr126998vdb.71.1389392973656; Fri, 10 Jan 2014 14:29:33 -0800 (PST) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id xb5si5728305vdc.81.2014.01.10.14.29.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Jan 2014 14:29:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id g10so3642467vbg.27 for ; Fri, 10 Jan 2014 14:29:33 -0800 (PST) X-Received: by 10.52.254.232 with SMTP id al8mr139149vdd.56.1389392973553; Fri, 10 Jan 2014 14:29:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp121814ved; Fri, 10 Jan 2014 14:29:33 -0800 (PST) X-Received: by 10.224.11.74 with SMTP id s10mr12400430qas.1.1389392973105; Fri, 10 Jan 2014 14:29:33 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTP id k3si1145116qaf.117.2014.01.10.14.29.32 for ; Fri, 10 Jan 2014 14:29:33 -0800 (PST) Received-SPF: pass (google.com: domain of msalter@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0AMTT5N003578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Jan 2014 17:29:29 -0500 Received: from deneb.redhat.com (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0AMTQfd004120; Fri, 10 Jan 2014 17:29:28 -0500 From: Mark Salter To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, Catalin Marinas , Will Deacon , matt.fleming@intel.com, Leif Lindholm , roy.franz@linaro.org, patches@linaro.org, Grant Likely , Mark Salter Subject: [PATCH 1/6] efi: create memory map iteration helper Date: Fri, 10 Jan 2014 17:29:05 -0500 Message-Id: <1389392950-22457-2-git-send-email-msalter@redhat.com> In-Reply-To: <1389392950-22457-1-git-send-email-msalter@redhat.com> References: <1389392950-22457-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.54 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- include/linux/efi.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/efi.h b/include/linux/efi.h index 11ce678..9dc5b05 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -618,6 +618,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