From patchwork Mon Oct 28 16:32:32 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: 1185536 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4720dC1jD8z9sPK for ; Tue, 29 Oct 2019 03:33:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732823AbfJ1QdC (ORCPT ); Mon, 28 Oct 2019 12:33:02 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:41389 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730772AbfJ1QdC (ORCPT ); Mon, 28 Oct 2019 12:33:02 -0400 Received: by mail-oi1-f194.google.com with SMTP id g81so6399413oib.8; Mon, 28 Oct 2019 09:33:01 -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=Ly9SwwfQU77PS/De9nePQz9/hgu0i/2+0AP8IGmXD3o=; b=E4EL88dFKu3hNE3PiY3hx79WoH+Zk7+YuRD5T8HVBKY1kJ1nuHVWPUfv+MaVgmJPCN DJ9TcdJ4uO0l2A4rLEPE7YNqasbSxkYM6n905MZW98Z91u80RIIzOigju8p8GxEysVFt jsztL2P0Ec/GMLJjKv8eaPKjdyCr1ewjCBov7pQf5s5t6rd+UndxNtmlQVUuENmls2qJ hyY05QP+hCePW6tIxYfhc3NUnh5GJIOpKAnz8IEuSnf1RT16dbofJeL/X4KQPRVnmg46 FbFWVA5IxIMbEhBiHqI1ccVMqXnb63pX9qSgL6ewt+I3DHKgMZd93qnfCzkvnPKN4k9a dlIA== X-Gm-Message-State: APjAAAXbU4Gvbc2zogzSmobIDxgL4hkOtI/lnPzDHomxawsAJS2Y7O4+ 7oVDXSEIiuB/g1H1i4S2iw== X-Google-Smtp-Source: APXvYqz7AvFVl42WcaIBsnF/FBWNvONUeq6ow/pzPzHbo/QsqT4JbiucFb+B7zhfVTYFjNW6To0vKg== X-Received: by 2002:aca:1e0c:: with SMTP id m12mr168280oic.18.1572280381198; Mon, 28 Oct 2019 09:33:01 -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 e186sm354991oia.47.2019.10.28.09.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:33:00 -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, Christoph Hellwig , 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 v3 01/25] resource: Add a resource_list_first_type helper Date: Mon, 28 Oct 2019 11:32:32 -0500 Message-Id: <20191028163256.8004-2-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028163256.8004-1-robh@kernel.org> References: <20191028163256.8004-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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_first_type() helper which implements this. Signed-off-by: Rob Herring --- v3: - Rename resource_list_get_entry_of_type to resource_list_first_type 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..ff0339df56af 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_first_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 */