From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD67EC77B62 for ; Thu, 30 Mar 2023 16:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0q3RQp4pyBOw2ZXUCsTagE7bKEBDODI0jTDMDz6fcoo=; b=aZWAVM61Rxn+KP 7S3j62lRUy7MHNX4xT1mcp3t5pU1PUzy0x0KnHboX89Z9QxQdvj11U84eQ8LQn4f3nmOgnO0kS4wj p0yOdJ2bhK3QW2/VQCNzRQ7BIRWb5fEl9Rc+io7GfUflt2JSQ6ZEah9xknUo1vTAzJylpZXlxvgf8 O8MuWiAHXnyR2ZxruCp0JH6Gk8lDk8PKpL/OtyB0rO+hjBxAijq5ZTf9OC+M9hLqKdK8CePSdiYok Yn7g2XmOMqzlnxHBuPZJrpG/LTe3OIhg451+p/uFS6NLWkj0AutFr14H4QfLRS6tkEp1WYC6R/H+b rp4uE+frJbANPQ9X9gPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phv8h-004Sj7-2y; Thu, 30 Mar 2023 16:28:39 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1phv8a-004Sbm-0c for linux-arm-kernel@lists.infradead.org; Thu, 30 Mar 2023 16:28:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680193712; x=1711729712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mMeyztJwnpsG6WpiZZE3Wzd++aYBpdo5TdtsAUuwHek=; b=UeetYP0z4KQE3eGjgEb1rZcZdEKa4Zt/lw25k6ICMVHP/gr5WLpuWQOv vHX230IkzboLjCyY0SQaC5V2mklJtqcbYRk2INBRiPU+nUZ2ThENiWsQl QjVZ5ibEfB6QA9H2UxZ8Z3lAFcYb+cVp+jJSkiiHMmVkMr1XHd/axlD3J 3JHxWBMqslYXAnMN15EbgPmZAp1alUykAZS6TnuASxRudTBpBTdr4LXG/ 0kqpNQWr3EUMkEcrs+OLeQYpHrCj5mOTQr8ShpTdUC6iUyfiIoVSwlr14 MPiOzkt1azTtcvTJEyW41A0oyLudH1otqOsj8j/Ds4aW4rMZ3DlizoKzE g==; X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="427496049" X-IronPort-AV: E=Sophos;i="5.98,305,1673942400"; d="scan'208";a="427496049" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 09:28:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10665"; a="684762351" X-IronPort-AV: E=Sophos;i="5.98,305,1673942400"; d="scan'208";a="684762351" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 30 Mar 2023 09:28:19 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 43047238; Thu, 30 Mar 2023 19:24:51 +0300 (EEST) From: Andy Shevchenko To: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Andy Shevchenko , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Mika Westerberg , Michael Ellerman , Randy Dunlap , Arnd Bergmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Niklas Schnelle , Bjorn Helgaas , "Rafael J. Wysocki" , =?UTF-8?q?Pali=20Roh=C3=A1r?= , "Maciej W. Rozycki" , Juergen Gross , Dominik Brodowski , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org Cc: Miguel Ojeda , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Thomas Bogendoerfer , Nicholas Piggin , Christophe Leroy , Anatolij Gustschin , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Bjorn Helgaas , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v8 4/7] PCI: Document pci_bus_for_each_resource() to avoid confusion Date: Thu, 30 Mar 2023 19:24:31 +0300 Message-Id: <20230330162434.35055-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230330162434.35055-1-andriy.shevchenko@linux.intel.com> References: <20230330162434.35055-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_092832_260006_05C23E8A X-CRM114-Status: GOOD ( 15.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There might be a confusion with the implementation of the pci_bus_for_each_resources() due to side effect of Logical OR. Document entire macro and explain how it works and why the conditional needs to be like that. Signed-off-by: Andy Shevchenko --- include/linux/pci.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 5cacd9e4c8cd..e3b3af606280 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1446,6 +1446,26 @@ int devm_request_pci_bus_resources(struct device *dev, /* Temporary until new and working PCI SBR API in place */ int pci_bridge_secondary_bus_reset(struct pci_dev *dev); +/** + * pci_bus_for_each_resource - iterate over PCI bus resources + * @bus: the PCI bus + * @res: a varible to keep a pointer to the current resource + * @i: a variable to keep the index of the current resource + * + * Iterate over PCI bus resources. The first part is to go over PCI bus + * resource array, which has at most the %PCI_BRIDGE_RESOURCE_NUM entries. + * After that continue with the separate list of the additional resources, + * if not empty. That's why the Logical OR is being used. + * + * Possible usage: + * + * struct pci_bus *bus = ...; + * struct resource *res; + * unsigned int i; + * + * pci_bus_for_each_resource(bus, res, i) + * pr_info("PCI bus resource[%u]: %pR\n", i, res); + */ #define pci_bus_for_each_resource(bus, res, i) \ for (i = 0; \ (res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \ -- 2.40.0.1.gaa8946217a0b _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel