From patchwork Fri Apr 4 12:25:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 27810 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E7FA020369 for ; Fri, 4 Apr 2014 12:27:32 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id p10sf11004381pdj.7 for ; Fri, 04 Apr 2014 05:27:32 -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=7YBSPsR0Sd29YDGuOcKQHyCJH7NwsaCA4QMq3lszI58=; b=RlGcXYOs1B54RMQR35bXw4P8MKxZirUHODWpeIV34sOzQwQVYj+G2pNAL2tEZUB3lp xnRaZ63Cugv+CNgMhwb0hbx9Q5wqZmbyzH3r56C+mB0Lh/8qwatwQ32eESiZjQ/cJ9J+ ads6MvcBvUNBkADfCJs2KrOZg/XPR3pXC7iBMZ0oqdp1a+8tNcdZx4kOGgwtnQ7yt+Pk Uuxr7d4wuioWS0mKgCSQRbREkjeYNhDP1V2NNas/4mmuuzyM8OaLR38tzDTeSvODxX+b nHfHKDp1qPFzr7OuUwjR6DRvV5oda4FZN2IYXRvE/3EvyWb3vy5LjHk2/uDwDfELZaJ3 14NQ== X-Gm-Message-State: ALoCoQm9A733sM14gpzLs1j47QMyiKc45pFsdqUlndOgsERSJZAGk9cqiE3OPjdRBFHAZdPc47+G X-Received: by 10.66.137.8 with SMTP id qe8mr4701656pab.46.1396614452194; Fri, 04 Apr 2014 05:27:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.131 with SMTP id z3ls1001755qgd.59.gmail; Fri, 04 Apr 2014 05:27:32 -0700 (PDT) X-Received: by 10.52.130.225 with SMTP id oh1mr11059472vdb.8.1396614452072; Fri, 04 Apr 2014 05:27:32 -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 sq9si1758083vdc.53.2014.04.04.05.27.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Apr 2014 05:27:32 -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 sa20so1351931veb.36 for ; Fri, 04 Apr 2014 05:27:32 -0700 (PDT) X-Received: by 10.52.240.207 with SMTP id wc15mr11104643vdc.14.1396614452000; Fri, 04 Apr 2014 05:27:32 -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.12.8 with SMTP id v8csp109703vcv; Fri, 4 Apr 2014 05:27:31 -0700 (PDT) X-Received: by 10.66.161.69 with SMTP id xq5mr14570989pab.62.1396614451077; Fri, 04 Apr 2014 05:27:31 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ep2si4548992pbb.31.2014.04.04.05.27.30; Fri, 04 Apr 2014 05:27:30 -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 S1753056AbaDDM1C (ORCPT + 27 others); Fri, 4 Apr 2014 08:27:02 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:61211 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929AbaDDM0i (ORCPT ); Fri, 4 Apr 2014 08:26:38 -0400 Received: by mail-we0-f171.google.com with SMTP id t61so3384521wes.30 for ; Fri, 04 Apr 2014 05:26:37 -0700 (PDT) X-Received: by 10.180.89.211 with SMTP id bq19mr4129614wib.58.1396614396928; Fri, 04 Apr 2014 05:26:36 -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 u8sm855089wjq.1.2014.04.04.05.26.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Apr 2014 05:26:36 -0700 (PDT) From: Leif Lindholm To: linux-efi@vger.kernel.org, matt.fleming@intel.com Cc: linux-kernel@vger.kernel.org, Mark Salter , Leif Lindholm Subject: [PATCH 2/5] efi: create memory map iteration helper Date: Fri, 4 Apr 2014 13:25:47 +0100 Message-Id: <1396614350-20889-3-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396614350-20889-1-git-send-email-leif.lindholm@linaro.org> References: <1396614350-20889-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 6c100ff..82d0abb 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -863,6 +863,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