From patchwork Wed Oct 16 20:06:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11194169 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5624F15AB for ; Wed, 16 Oct 2019 20:06:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3586E2064B for ; Wed, 16 Oct 2019 20:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571256414; bh=iRdvHWu7v03acRlkiMUsuC1DoIm4kv9ZAmUIimQqHVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bYeSFVkVgkcT7T/ukuqZvbD8OVYjT1SUoPMAN04d+Cc3Ol76PDXAOrcxVtjsdmfZP 6JLx+MPiNe5FrFM8bYWdE9aFRYi0ehXa/w29mZb4ebGJn/ueRwok8YsvExaDdG0ZZU RASV0AgucGjpAufsI7WqHdL+b6IkVQ3MWjINIyVk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730777AbfJPUGx (ORCPT ); Wed, 16 Oct 2019 16:06:53 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46432 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729308AbfJPUGx (ORCPT ); Wed, 16 Oct 2019 16:06:53 -0400 Received: by mail-oi1-f194.google.com with SMTP id k25so82498oiw.13; Wed, 16 Oct 2019 13:06:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A4I4vYKlrRjeCcvZ3gdAUf5OIh4K24Pgv1HRMaUxQSM=; b=oAIcbIUDBcpFNknn1Xh+VmdR6GC4vTCFyHxF9u7UHNExAUbCA/nRhDnbMJ01SXIuTj MPd8KJsrgWTSaFUOPsPO/+df2R49+uefoU0oF883HwyzSgNIfrxyQWVotx5oSvKzPcIy wO6rF5uNz45om98FGLZNWqlHgEGEUPj8zlLdvzieLUA00P3HWCRs/oAZn1AawW8JKnP+ gO891V2VlxRm2ocfcuxaBcTR2YQzRQnG5TqoeBgsXuXpjJDQ31iNZv1wyJm6oBd3F7pM jbTsD2qg2r9/KF5vs1JcnXY5aNZJwAIoS1W+6k80MMCvxeQzRpxHygNATMpqWu547RwO +Frg== X-Gm-Message-State: APjAAAUW0+PnEKSrlHczvafphXs+djTqfqx9lv9KLsHUFCrVhQXrxgi7 UWnvhVYp2p+GpNZ7eMTbGA== X-Google-Smtp-Source: APXvYqy2RgxqIowsn3RilHDMVL8ZYUZqVhZ4FNbcwDaYFpFY5yEQQz1OcvvwTVzq3lVosqWKYYObvw== X-Received: by 2002:aca:b9d7:: with SMTP id j206mr110297oif.112.1571256412390; Wed, 16 Oct 2019 13:06:52 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id a9sm7412463oie.7.2019.10.16.13.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 13:06:51 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v2 01/25] resource: Add a resource_list_get_entry_of_type helper Date: Wed, 16 Oct 2019 15:06:23 -0500 Message-Id: <20191016200647.32050-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191016200647.32050-1-robh@kernel.org> References: <20191016200647.32050-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org A common pattern is looping over a resource_list just to get a matching entry with a specific type. Add resource_list_get_entry_of_type() helper which implements this. Signed-off-by: Rob Herring --- v2: - New patch include/linux/resource_ext.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.20.1 diff --git a/include/linux/resource_ext.h b/include/linux/resource_ext.h index 06da59b23b79..9f52183fab8b 100644 --- a/include/linux/resource_ext.h +++ b/include/linux/resource_ext.h @@ -66,4 +66,16 @@ resource_list_destroy_entry(struct resource_entry *entry) #define resource_list_for_each_entry_safe(entry, tmp, list) \ list_for_each_entry_safe((entry), (tmp), (list), node) +static inline struct resource_entry *resource_list_get_entry_of_type(struct list_head *list, + unsigned long type) +{ + struct resource_entry *entry; + + resource_list_for_each_entry(entry, list) { + if (resource_type(entry->res) == type) + return entry; + } + return NULL; +} + #endif /* _LINUX_RESOURCE_EXT_H */