From nobody Fri May 17 06:54:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667494030; cv=none; d=zohomail.com; s=zohoarc; b=hXKVlTY4sjmHs8/T85PGA7F4q02wPdmx1lc7fQzHxI+2kiwnVR2MqyE8h/lAPRiKNxzIFMqoXEkjbhhs/IEaNoW7eIziTFocPNoq75AsnL4UUXoZQ6m5cX23L0WmfeUVWaFDVh3jr6FwcUFc7ronMuZRR67rgIDTacb6G6UQS3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667494030; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kon1yVFoK/gj7/7tZxAaZpaui/cV2ZCf52yzpIrnIkQ=; b=XLN6Gyr7mG+/VgI8QZtKCS6s8gMvSKRFuLDHeI7mcnVTmvc68Kq6f4rjtvC53t5FghOO2JoSug5IgA4I3PG6fYKQLyEzWgQRXOFOOKxq9aR0ZTi9MkbY3iuat2VFk4h+ryycgriPExDrulUjTQQXCKaicHeWJaO7PAJDhAg7HIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 166749403005434.396277042854535; Thu, 3 Nov 2022 09:47:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.436895.691112 (Exim 4.92) (envelope-from ) id 1oqdMc-0002He-M7; Thu, 03 Nov 2022 16:46:46 +0000 Received: by outflank-mailman (output) from mailman id 436895.691112; Thu, 03 Nov 2022 16:46:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdMc-0002HR-I6; Thu, 03 Nov 2022 16:46:46 +0000 Received: by outflank-mailman (input) for mailman id 436895; Thu, 03 Nov 2022 16:46:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdMa-000197-OP for xen-devel@lists.xenproject.org; Thu, 03 Nov 2022 16:46:45 +0000 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 18a401a8-5b97-11ed-91b5-6bf2151ebd3b; Thu, 03 Nov 2022 17:46:43 +0100 (CET) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 09:46:37 -0700 Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 03 Nov 2022 09:46:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9492D84; Thu, 3 Nov 2022 18:46:52 +0200 (EET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 18a401a8-5b97-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667494003; x=1699030003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7KOeu9S/6WwS70MbWmycrnSpR5o2Z9FEl6F8XDmROM0=; b=cWEU3n5oqQfsxlb0VcV7T6y/jnsjIJrVSlUQ4I59feLbCShG8pFK94kN ndsGfT8ea7HNEU+1fOj0WlNPXyGEvirBOKHmycd+JGb1p6S7tlkAD2D0L tncdoG/qX4GV22m9pcyhJ0tsRYB0Uob+CqGtAUAgSLd31D+cCcij/2Xk2 6bYN4zMPCHIMSCpQzputx5uEz2TanmIG9SvvlqbFgAbw37lOuy3B+vlru UmooJm5XxGkvMfRsvSA2lLvlNVb1qgzCc337sehyQfy7Tnd4WDVFpdaIS MJgYxJDHIIFceMsVEGO7X0xB1RApu00JdVcuiSoaOvTfpYFjFpJoPghNi w==; X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="309732836" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="309732836" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="629408023" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="629408023" From: Andy Shevchenko To: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Andy Shevchenko , Mika Westerberg , Michael Ellerman , Arnd Bergmann , Bjorn Helgaas , "Rafael J. Wysocki" , 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, sparclinux@vger.kernel.org, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Miguel Ojeda , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Thomas Bogendoerfer , Nicholas Piggin , Christophe Leroy , "David S. Miller" , Bjorn Helgaas , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v2 1/4] PCI: Introduce pci_dev_for_each_resource() Date: Thu, 3 Nov 2022 18:46:41 +0200 Message-Id: <20221103164644.70554-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> References: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1667494030947100005 Content-Type: text/plain; charset="utf-8" From: Mika Westerberg Instead of open-coding it everywhere introduce a tiny helper that can be used to iterate over each resource of a PCI device, and convert the most obvious users into it. While at it drop doubled empty line before pdev_sort_resources(). No functional changes intended. Suggested-by: Andy Shevchenko Signed-off-by: Mika Westerberg Signed-off-by: Andy Shevchenko --- .clang-format | 2 ++ arch/alpha/kernel/pci.c | 5 ++--- arch/arm/kernel/bios32.c | 16 +++++++--------- arch/mips/pci/pci-legacy.c | 3 +-- arch/powerpc/kernel/pci-common.c | 5 ++--- arch/sparc/kernel/leon_pci.c | 5 ++--- arch/sparc/kernel/pci.c | 10 ++++------ arch/sparc/kernel/pcic.c | 5 ++--- drivers/pci/remove.c | 5 ++--- drivers/pci/setup-bus.c | 26 ++++++++++---------------- drivers/pci/setup-res.c | 4 +--- drivers/pci/xen-pcifront.c | 4 +--- include/linux/pci.h | 11 +++++++++++ 13 files changed, 47 insertions(+), 54 deletions(-) diff --git a/.clang-format b/.clang-format index f98481a53ea8..08d579fea6cf 100644 --- a/.clang-format +++ b/.clang-format @@ -520,6 +520,8 @@ ForEachMacros: - 'of_property_for_each_string' - 'of_property_for_each_u32' - 'pci_bus_for_each_resource' + - 'pci_dev_for_each_resource' + - 'pci_dev_for_each_resource_p' - 'pci_doe_for_each_off' - 'pcl_for_each_chunk' - 'pcl_for_each_segment' diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 64fbfb0763b2..4458eb7f44f0 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c @@ -288,11 +288,10 @@ pcibios_claim_one_bus(struct pci_bus *b) struct pci_bus *child_bus; =20 list_for_each_entry(dev, &b->devices, bus_list) { + struct resource *r; int i; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r =3D &dev->resource[i]; - + pci_dev_for_each_resource(dev, r, i) { if (r->parent || !r->start || !r->flags) continue; if (pci_has_flag(PCI_PROBE_ONLY) || diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index e7ef2b5bea9c..5254734b23e6 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -142,15 +142,15 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND2, PCI_= DEVICE_ID_WINBOND2_89C940F, */ static void pci_fixup_dec21285(struct pci_dev *dev) { - int i; - if (dev->devfn =3D=3D 0) { + struct resource *r; + dev->class &=3D 0xff; dev->class |=3D PCI_CLASS_BRIDGE_HOST << 8; - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - dev->resource[i].start =3D 0; - dev->resource[i].end =3D 0; - dev->resource[i].flags =3D 0; + pci_dev_for_each_resource_p(dev, r) { + r->start =3D 0; + r->end =3D 0; + r->flags =3D 0; } } } @@ -162,13 +162,11 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_DEC, PCI_DEVIC= E_ID_DEC_21285, pci_fixup_d static void pci_fixup_ide_bases(struct pci_dev *dev) { struct resource *r; - int i; =20 if ((dev->class >> 8) !=3D PCI_CLASS_STORAGE_IDE) return; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - r =3D dev->resource + i; + pci_dev_for_each_resource_p(dev, r) { if ((r->start & ~0x80) =3D=3D 0x374) { r->start |=3D 2; r->end =3D r->start; diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index 468722c8a5c6..ec2567f8efd8 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c @@ -249,12 +249,11 @@ static int pcibios_enable_resources(struct pci_dev *d= ev, int mask) =20 pci_read_config_word(dev, PCI_COMMAND, &cmd); old_cmd =3D cmd; - for (idx =3D 0; idx < PCI_NUM_RESOURCES; idx++) { + pci_dev_for_each_resource(dev, r, idx) { /* Only set up the requested stuff */ if (!(mask & (1<resource[idx]; if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) continue; if ((idx =3D=3D PCI_ROM_RESOURCE) && diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-com= mon.c index d67cf79bf5d0..8ddcfa6bcb50 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1452,11 +1452,10 @@ void pcibios_claim_one_bus(struct pci_bus *bus) struct pci_bus *child_bus; =20 list_for_each_entry(dev, &bus->devices, bus_list) { + struct resource *r; int i; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r =3D &dev->resource[i]; - + pci_dev_for_each_resource(dev, r, i) { if (r->parent || !r->start || !r->flags) continue; =20 diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c index e5e5ff6b9a5c..b6663a3fbae9 100644 --- a/arch/sparc/kernel/leon_pci.c +++ b/arch/sparc/kernel/leon_pci.c @@ -62,15 +62,14 @@ void leon_pci_init(struct platform_device *ofdev, struc= t leon_pci_info *info) =20 int pcibios_enable_device(struct pci_dev *dev, int mask) { + struct resource *res; u16 cmd, oldcmd; int i; =20 pci_read_config_word(dev, PCI_COMMAND, &cmd); oldcmd =3D cmd; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *res =3D &dev->resource[i]; - + pci_dev_for_each_resource(dev, res, i) { /* Only set up the requested stuff */ if (!(mask & (1<devices, bus_list) { + struct resource *r; int i; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r =3D &dev->resource[i]; - + pci_dev_for_each_resource(dev, r, i) { if (r->parent || !r->start || !r->flags) continue; =20 @@ -724,15 +723,14 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info = *pbm, =20 int pcibios_enable_device(struct pci_dev *dev, int mask) { + struct resource *res; u16 cmd, oldcmd; int i; =20 pci_read_config_word(dev, PCI_COMMAND, &cmd); oldcmd =3D cmd; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *res =3D &dev->resource[i]; - + pci_dev_for_each_resource(dev, res, i) { /* Only set up the requested stuff */ if (!(mask & (1<resource[i]; - + pci_dev_for_each_resource(dev, res, i) { /* Only set up the requested stuff */ if (!(mask & (1<resource + i; + pci_dev_for_each_resource_p(dev, res) { if (res->parent) release_resource(res); } diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index e512f9ecb9d0..336d6e6ef76a 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -124,20 +124,17 @@ static resource_size_t get_res_add_align(struct list_= head *head, return dev_res ? dev_res->min_align : 0; } =20 - /* Sort resources by alignment */ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *hea= d) { + struct resource *r; int i; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r; + pci_dev_for_each_resource(dev, r, i) { struct pci_dev_resource *dev_res, *tmp; resource_size_t r_align; struct list_head *n; =20 - r =3D &dev->resource[i]; - if (r->flags & IORESOURCE_PCI_FIXED) continue; =20 @@ -895,10 +892,9 @@ static void pbus_size_io(struct pci_bus *bus, resource= _size_t min_size, =20 min_align =3D window_alignment(bus, IORESOURCE_IO); list_for_each_entry(dev, &bus->devices, bus_list) { - int i; + struct resource *r; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r =3D &dev->resource[i]; + pci_dev_for_each_resource_p(dev, r) { unsigned long r_size; =20 if (r->parent || !(r->flags & IORESOURCE_IO)) @@ -1014,10 +1010,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsig= ned long mask, size =3D 0; =20 list_for_each_entry(dev, &bus->devices, bus_list) { + struct resource *r; int i; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r =3D &dev->resource[i]; + pci_dev_for_each_resource(dev, r, i) { resource_size_t r_size; =20 if (r->parent || (r->flags & IORESOURCE_PCI_FIXED) || @@ -1358,11 +1354,10 @@ static void assign_fixed_resource_on_bus(struct pci= _bus *b, struct resource *r) */ static void pdev_assign_fixed_resources(struct pci_dev *dev) { - int i; + struct resource *r; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { + pci_dev_for_each_resource_p(dev, r) { struct pci_bus *b; - struct resource *r =3D &dev->resource[i]; =20 if (r->parent || !(r->flags & IORESOURCE_PCI_FIXED) || !(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) @@ -1845,7 +1840,7 @@ static void pci_bus_distribute_available_resources(st= ruct pci_bus *bus, * distributing the rest. */ list_for_each_entry(dev, &bus->devices, bus_list) { - int i; + struct resource *dev_res; =20 if (dev =3D=3D bridge) continue; @@ -1857,8 +1852,7 @@ static void pci_bus_distribute_available_resources(st= ruct pci_bus *bus, if (!dev->multifunction) return; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - const struct resource *dev_res =3D &dev->resource[i]; + pci_dev_for_each_resource_p(dev, dev_res) { resource_size_t dev_sz; struct resource *b_res; =20 diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index b492e67c3d87..967f9a758923 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -484,12 +484,10 @@ int pci_enable_resources(struct pci_dev *dev, int mas= k) pci_read_config_word(dev, PCI_COMMAND, &cmd); old_cmd =3D cmd; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { + pci_dev_for_each_resource(dev, r, i) { if (!(mask & (1 << i))) continue; =20 - r =3D &dev->resource[i]; - if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) continue; if ((i =3D=3D PCI_ROM_RESOURCE) && diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 7378e2f3e525..ce485ef59656 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -390,9 +390,7 @@ static int pcifront_claim_resource(struct pci_dev *dev,= void *data) int i; struct resource *r; =20 - for (i =3D 0; i < PCI_NUM_RESOURCES; i++) { - r =3D &dev->resource[i]; - + pci_dev_for_each_resource(dev, r, i) { if (!r->parent && r->start && r->flags) { dev_info(&pdev->xdev->dev, "claiming resource %s/%d\n", pci_name(dev), i); diff --git a/include/linux/pci.h b/include/linux/pci.h index 2bda4a4e47e8..3940435fa90a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1407,6 +1407,17 @@ int pci_request_selected_regions(struct pci_dev *, i= nt, const char *); int pci_request_selected_regions_exclusive(struct pci_dev *, int, const ch= ar *); void pci_release_selected_regions(struct pci_dev *, int); =20 +#define __pci_dev_for_each_resource(dev, res, __i, vartype) \ + for (vartype __i =3D 0; \ + res =3D &(dev)->resource[__i], __i < PCI_NUM_RESOURCES; \ + __i++) + +#define pci_dev_for_each_resource(dev, res, i) \ + __pci_dev_for_each_resource(dev, res, i, ) + +#define pci_dev_for_each_resource_p(dev, res) \ + __pci_dev_for_each_resource(dev, res, i, unsigned int) + /* drivers/pci/bus.c */ void pci_add_resource(struct list_head *resources, struct resource *res); void pci_add_resource_offset(struct list_head *resources, struct resource = *res, --=20 2.35.1 From nobody Fri May 17 06:54:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667494027; cv=none; d=zohomail.com; s=zohoarc; b=g/u2CUrJ2ms8nerm/ilrcfQStT1lw/hJX0me2eu/Aqhub3HPhTQxesMV36Xg/Sx9hF7A0DVZ0f2Uwv/Jgjc+fnMphZ50jhq5uU3Gy037DZE/Yp387DvRn1JtAYgIRkiIiCq5S+N22bPL4vhwVSPlLJdfe3pwFOpkvaZTkuffGiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667494027; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rf/Mt6oEbiMyExw3WJAgLVObcy3VwRrNHZNM0ZSdZuk=; b=ax8MvZi3JvF7BKb6dJ/CqibzjzbtEljxrz6D8WrRD/Nrq2L0zqTap7llyHjztbSym8v8OLQJbj+QdCxdeVFQXqelzutxgUH5PAF8sm/qVIFLcsWooVOA+mbaxWbS7uxQhSYWdEiFtym0TwGBEo7ddHaFZxbAXeVL1NJXkrkfTGI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1667494027390369.68744033157077; Thu, 3 Nov 2022 09:47:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.436894.691101 (Exim 4.92) (envelope-from ) id 1oqdMb-00021A-Er; Thu, 03 Nov 2022 16:46:45 +0000 Received: by outflank-mailman (output) from mailman id 436894.691101; Thu, 03 Nov 2022 16:46:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdMb-00020z-BD; Thu, 03 Nov 2022 16:46:45 +0000 Received: by outflank-mailman (input) for mailman id 436894; Thu, 03 Nov 2022 16:46:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdMZ-000197-8j for xen-devel@lists.xenproject.org; Thu, 03 Nov 2022 16:46:43 +0000 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17dbde70-5b97-11ed-91b5-6bf2151ebd3b; Thu, 03 Nov 2022 17:46:42 +0100 (CET) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 09:46:37 -0700 Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 03 Nov 2022 09:46:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AA5DF1E5; Thu, 3 Nov 2022 18:46:52 +0200 (EET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 17dbde70-5b97-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667494002; x=1699030002; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S2RJPvl3baq0S1jZ0H3vH8ZxE7YEfK7nHVPBJ+ytMMo=; b=b9zyzqy4nyQafoLSSALcjyBPGKY3fREchT6AelebUyev9oFblQH7KXQV 3i55+GvtyqJrrTvY5G+9e0VtyfOatVwmYFx0/hYY7nwL+5TMDWw5gC7Bs 8CkCYiSvoctKfWV4ZeryWgL4vhu2Ao3PyudurXF/CZz7j+1oIfWyDJ2LR xgbCu2MOOrgH7oxDnNFSyqy0rVNolfWy1pYs5ffjAOlhvYp20P9VKdIPw q3dkYIUnAPZ7Z1kErE782BUt+iTq53FYlmhGphQ0yBhkoy6O1OIEiidvI AoXqr496QBuXLPsHBBC9BrBoq1C8pvPlp0VWsWIukKBzZKKpY1Mz70Mg5 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="309732834" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="309732834" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="629408025" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="629408025" From: Andy Shevchenko To: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Andy Shevchenko , Mika Westerberg , Michael Ellerman , Arnd Bergmann , Bjorn Helgaas , "Rafael J. Wysocki" , 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, sparclinux@vger.kernel.org, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Miguel Ojeda , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Thomas Bogendoerfer , Nicholas Piggin , Christophe Leroy , "David S. Miller" , Bjorn Helgaas , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v2 2/4] PCI: Split pci_bus_for_each_resource_p() out of pci_bus_for_each_resource() Date: Thu, 3 Nov 2022 18:46:42 +0200 Message-Id: <20221103164644.70554-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> References: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1667494028994100003 Content-Type: text/plain; charset="utf-8" Refactor pci_bus_for_each_resource() in the same way as it's done in pci_dev_for_each_resource() case. This will allow to hide iterator inside the loop, where it's not used otherwise. No functional changes intended. Signed-off-by: Andy Shevchenko --- .clang-format | 1 + drivers/pci/bus.c | 7 +++---- drivers/pci/hotplug/shpchp_sysfs.c | 8 ++++---- drivers/pci/pci.c | 5 ++--- drivers/pci/probe.c | 2 +- drivers/pci/setup-bus.c | 10 ++++------ include/linux/pci.h | 14 ++++++++++---- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.clang-format b/.clang-format index 08d579fea6cf..b61fd8791346 100644 --- a/.clang-format +++ b/.clang-format @@ -520,6 +520,7 @@ ForEachMacros: - 'of_property_for_each_string' - 'of_property_for_each_u32' - 'pci_bus_for_each_resource' + - 'pci_bus_for_each_resource_p' - 'pci_dev_for_each_resource' - 'pci_dev_for_each_resource_p' - 'pci_doe_for_each_off' diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 3cef835b375f..fc8e9c11c5f2 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -161,13 +161,13 @@ static int pci_bus_alloc_from_region(struct pci_bus *= bus, struct resource *res, void *alignf_data, struct pci_bus_region *region) { - int i, ret; struct resource *r, avail; resource_size_t max; + int ret; =20 type_mask |=3D IORESOURCE_TYPE_BITS; =20 - pci_bus_for_each_resource(bus, r, i) { + pci_bus_for_each_resource_p(bus, r) { resource_size_t min_used =3D min; =20 if (!r) @@ -264,9 +264,8 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx) struct resource *res =3D &dev->resource[idx]; struct resource orig_res =3D *res; struct resource *r; - int i; =20 - pci_bus_for_each_resource(bus, r, i) { + pci_bus_for_each_resource_p(bus, r) { resource_size_t start, end; =20 if (!r) diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpch= p_sysfs.c index 64beed7a26be..ff04f0c5e7c3 100644 --- a/drivers/pci/hotplug/shpchp_sysfs.c +++ b/drivers/pci/hotplug/shpchp_sysfs.c @@ -24,16 +24,16 @@ static ssize_t show_ctrl(struct device *dev, struct device_attribute *attr= , char *buf) { struct pci_dev *pdev; - int index, busnr; struct resource *res; struct pci_bus *bus; size_t len =3D 0; + int busnr; =20 pdev =3D to_pci_dev(dev); bus =3D pdev->subordinate; =20 len +=3D sysfs_emit_at(buf, len, "Free resources: memory\n"); - pci_bus_for_each_resource(bus, res, index) { + pci_bus_for_each_resource_p(bus, res) { if (res && (res->flags & IORESOURCE_MEM) && !(res->flags & IORESOURCE_PREFETCH)) { len +=3D sysfs_emit_at(buf, len, @@ -43,7 +43,7 @@ static ssize_t show_ctrl(struct device *dev, struct devic= e_attribute *attr, char } } len +=3D sysfs_emit_at(buf, len, "Free resources: prefetchable memory\n"); - pci_bus_for_each_resource(bus, res, index) { + pci_bus_for_each_resource_p(bus, res) { if (res && (res->flags & IORESOURCE_MEM) && (res->flags & IORESOURCE_PREFETCH)) { len +=3D sysfs_emit_at(buf, len, @@ -53,7 +53,7 @@ static ssize_t show_ctrl(struct device *dev, struct devic= e_attribute *attr, char } } len +=3D sysfs_emit_at(buf, len, "Free resources: IO\n"); - pci_bus_for_each_resource(bus, res, index) { + pci_bus_for_each_resource_p(bus, res) { if (res && (res->flags & IORESOURCE_IO)) { len +=3D sysfs_emit_at(buf, len, "start =3D %8.8llx, length =3D %8.8llx\n", diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 2127aba3550b..ff5b34337dab 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -782,9 +782,8 @@ struct resource *pci_find_parent_resource(const struct = pci_dev *dev, { const struct pci_bus *bus =3D dev->bus; struct resource *r; - int i; =20 - pci_bus_for_each_resource(bus, r, i) { + pci_bus_for_each_resource_p(bus, r) { if (!r) continue; if (resource_contains(r, res)) { @@ -802,7 +801,7 @@ struct resource *pci_find_parent_resource(const struct = pci_dev *dev, * be both a positively-decoded aperture and a * subtractively-decoded region that contain the BAR. * We want the positively-decoded one, so this depends - * on pci_bus_for_each_resource() giving us those + * on pci_bus_for_each_resource_p() giving us those * first. */ return r; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b66fa42c4b1f..3662e867a124 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -533,7 +533,7 @@ void pci_read_bridge_bases(struct pci_bus *child) pci_read_bridge_mmio_pref(child); =20 if (dev->transparent) { - pci_bus_for_each_resource(child->parent, res, i) { + pci_bus_for_each_resource_p(child->parent, res) { if (res && res->flags) { pci_bus_add_resource(child, res, PCI_SUBTRACTIVE_DECODE); diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 336d6e6ef76a..83b2f308be7e 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -770,9 +770,8 @@ static struct resource *find_bus_resource_of_type(struc= t pci_bus *bus, unsigned long type) { struct resource *r, *r_assigned =3D NULL; - int i; =20 - pci_bus_for_each_resource(bus, r, i) { + pci_bus_for_each_resource_p(bus, r) { if (r =3D=3D &ioport_resource || r =3D=3D &iomem_resource) continue; if (r && (r->flags & type_mask) =3D=3D type && !r->parent) @@ -1204,7 +1203,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, stru= ct list_head *realloc_head) additional_mmio_pref_size =3D 0; struct resource *pref; struct pci_host_bridge *host; - int hdr_type, i, ret; + int hdr_type, ret; =20 list_for_each_entry(dev, &bus->devices, bus_list) { struct pci_bus *b =3D dev->subordinate; @@ -1228,7 +1227,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, stru= ct list_head *realloc_head) host =3D to_pci_host_bridge(bus->bridge); if (!host->size_windows) return; - pci_bus_for_each_resource(bus, pref, i) + pci_bus_for_each_resource_p(bus, pref) if (pref && (pref->flags & IORESOURCE_PREFETCH)) break; hdr_type =3D -1; /* Intentionally invalid - not a PCI device. */ @@ -1333,12 +1332,11 @@ EXPORT_SYMBOL(pci_bus_size_bridges); =20 static void assign_fixed_resource_on_bus(struct pci_bus *b, struct resourc= e *r) { - int i; struct resource *parent_r; unsigned long mask =3D IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH; =20 - pci_bus_for_each_resource(b, parent_r, i) { + pci_bus_for_each_resource_p(b, parent_r) { if (!parent_r) continue; =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index 3940435fa90a..165e4713360f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1433,10 +1433,16 @@ int devm_request_pci_bus_resources(struct device *d= ev, /* Temporary until new and working PCI SBR API in place */ int pci_bridge_secondary_bus_reset(struct pci_dev *dev); =20 -#define pci_bus_for_each_resource(bus, res, i) \ - for (i =3D 0; \ - (res =3D pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \ - i++) +#define __pci_bus_for_each_resource(bus, res, __i, vartype) \ + for (vartype __i =3D 0; \ + res =3D pci_bus_resource_n(bus, __i), __i < PCI_BRIDGE_RESOURCE_NUM;= \ + __i++) + +#define pci_bus_for_each_resource(bus, res, i) \ + __pci_bus_for_each_resource(bus, res, i, ) + +#define pci_bus_for_each_resource_p(bus, res) \ + __pci_bus_for_each_resource(bus, res, i, unsigned int) =20 int __must_check pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, resource_size_t size, --=20 2.35.1 From nobody Fri May 17 06:54:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667494059; cv=none; d=zohomail.com; s=zohoarc; b=etNjBwJgiRF9K6Kvls5xFpeKkUZTFETIjq9mX7ytyE3p73twZDz7exkjIh0LrHu1yeIQLYp3TmrKcE7EikRSL3IjVftxF03Y1NPZLhwer4LCjHNuO9sr9qL0KvVf99So1BneBgblKmIEg/CA9m9XDD0mA2DfCd7Pj/ixIfbfRQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667494059; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=116YKWMv0Jblpl2kyjcsnQYXUs42BfItz/V64WWeJUk=; b=dgb9uI83lTVbx51Y3tnzx3aiQmPxASfD+yiVASGSPf6zqzv/+eH5d6CZuUeBhx0czUDJOIaTGBZp3jxm2Qvp8/rNDCrW074r9vaw/uCZF42Y5xgoJYrVA6IiilGrBvMU9AYa+VN1F6bdU2A7pmixNOcXYSnQgStGVtzjYAAB86Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1667494059884907.7088434669545; Thu, 3 Nov 2022 09:47:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.436903.691123 (Exim 4.92) (envelope-from ) id 1oqdN7-0003Ln-2r; Thu, 03 Nov 2022 16:47:17 +0000 Received: by outflank-mailman (output) from mailman id 436903.691123; Thu, 03 Nov 2022 16:47:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdN6-0003Lg-V3; Thu, 03 Nov 2022 16:47:16 +0000 Received: by outflank-mailman (input) for mailman id 436903; Thu, 03 Nov 2022 16:47:16 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdN6-0002ih-1H for xen-devel@lists.xenproject.org; Thu, 03 Nov 2022 16:47:16 +0000 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 25b81a63-5b97-11ed-8fd0-01056ac49cbb; Thu, 03 Nov 2022 17:47:07 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 09:46:36 -0700 Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 03 Nov 2022 09:46:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B75E129D; Thu, 3 Nov 2022 18:46:52 +0200 (EET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 25b81a63-5b97-11ed-8fd0-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667494033; x=1699030033; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EaNuN468AX7oVVNzygbZKjeVdiuKUVO8jdpIxMpvwBE=; b=Voi+kRr9Zp10H+K4cuAxV1LmnyNY6gKw/G0DgaycWnXEatL6nDgX2Wzh RW+uPVvrCWpkbKi8jCYl79gAnuQgATfINATvUFE3Fdir0x4Wkt9qjWcRk KxFtBXStZnga813ivkRQqyE/1wMQ8Ns3FTNPT5q+OeiECCEsipFOIm9TW E1W1WSCqf4ChYPKHf/VWH97ZUb96kdzQAyXp7n/XAajpeFvZCwclpR7pE UIUFCQYNtwXF7hlRhGB5vrV3taGM7vuOGJDZBGIHMWAEPu3uukwM7bKIw 9s7Rj1Ua/JZCQQbVXCJuHfO1SbSkbm1HxTlg/lk18RSCfFiJRV488uCjP w==; X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="293061340" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="293061340" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="809735378" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="809735378" From: Andy Shevchenko To: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Andy Shevchenko , Mika Westerberg , Michael Ellerman , Arnd Bergmann , Bjorn Helgaas , "Rafael J. Wysocki" , 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, sparclinux@vger.kernel.org, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Miguel Ojeda , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Thomas Bogendoerfer , Nicholas Piggin , Christophe Leroy , "David S. Miller" , Bjorn Helgaas , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v2 3/4] EISA: Convert to use pci_bus_for_each_resource_p() Date: Thu, 3 Nov 2022 18:46:43 +0200 Message-Id: <20221103164644.70554-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> References: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1667494061454100001 Content-Type: text/plain; charset="utf-8" The pci_bus_for_each_resource_p() hides the iterator loop since it may be not used otherwise. With this, we may drop that iterator variable definition. Signed-off-by: Andy Shevchenko --- drivers/eisa/pci_eisa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eisa/pci_eisa.c b/drivers/eisa/pci_eisa.c index 930c2332c3c4..907b86384396 100644 --- a/drivers/eisa/pci_eisa.c +++ b/drivers/eisa/pci_eisa.c @@ -20,8 +20,8 @@ static struct eisa_root_device pci_eisa_root; =20 static int __init pci_eisa_init(struct pci_dev *pdev) { - int rc, i; struct resource *res, *bus_res =3D NULL; + int rc; =20 if ((rc =3D pci_enable_device (pdev))) { dev_err(&pdev->dev, "Could not enable device\n"); @@ -38,7 +38,7 @@ static int __init pci_eisa_init(struct pci_dev *pdev) * eisa_root_register() can only deal with a single io port resource, * so we use the first valid io port resource. */ - pci_bus_for_each_resource(pdev->bus, res, i) + pci_bus_for_each_resource_p(pdev->bus, res) if (res && (res->flags & IORESOURCE_IO)) { bus_res =3D res; break; --=20 2.35.1 From nobody Fri May 17 06:54:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667494059; cv=none; d=zohomail.com; s=zohoarc; b=Kj6tay5q1Dt8FM1KppdkqMCZnsimanJexk3T4W9Lys3UQMq2WgonHKfnJQqNvdCWpW/mVVYWhq1qMnBG8fzkXmh8Krlotfz+kD6ZocAfwoRxsKEdxToch+tC3JKHO9IL+WTaHCRzo6xNY/eU0qosEFh5LHsmJYdrnQJa4zyC3S4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667494059; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xUJEQ8B+yd3tSJ4o7EXAVL4R3IOmwYEqjSf2LeSEiDo=; b=VAW6zHCgoeNOwc/DXmrF573O7depdqQOD15C2dNAsHCiQyWPUBDsMj3VczCBavNeqDxALR5kE4QLlmwjhvkPbLvnZVCr+7lBbWmUyhyx4RSRFZUKFumFn1LFqdanZ+2+OMnr4NOzpj/U+H18kvEZvKQ8E66gkb8cqYMjpSjo1bc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1667494059740119.42715544822352; Thu, 3 Nov 2022 09:47:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.436904.691134 (Exim 4.92) (envelope-from ) id 1oqdN9-0003cc-9s; Thu, 03 Nov 2022 16:47:19 +0000 Received: by outflank-mailman (output) from mailman id 436904.691134; Thu, 03 Nov 2022 16:47:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdN9-0003cV-6B; Thu, 03 Nov 2022 16:47:19 +0000 Received: by outflank-mailman (input) for mailman id 436904; Thu, 03 Nov 2022 16:47:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdN7-0002ih-Dd for xen-devel@lists.xenproject.org; Thu, 03 Nov 2022 16:47:17 +0000 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 28ec424c-5b97-11ed-8fd0-01056ac49cbb; Thu, 03 Nov 2022 17:47:10 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2022 09:46:36 -0700 Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 03 Nov 2022 09:46:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C452A2B7; Thu, 3 Nov 2022 18:46:52 +0200 (EET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 28ec424c-5b97-11ed-8fd0-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667494036; x=1699030036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NhBC+PjScBp2IdaVXcj0juh1+PhjepKM9lxMzcbPhAU=; b=f0MSA++lXlrN/79oRNIleUmCvbHBUEKrQrS2JFURHFSrBDfNdMjLYAjr WFWU+w4WlaSDu4GSo97C9YYL35hch5P0bEPhhbPYl2abUFdVyqqBy2yAU rjfoA2q2RHvQ9T/bvFaCC90rWLUD1zD2hBwPtZHuTtN0AaCqlr9+BX+pF DqczfQhPxBV9cDyBYclP3x+dkAhgseB4c3H/a96YXz4jVNIAWobzrBPBO HEvEDWGIZ3NSnFFYVrSDfqprcFOPi514pETkxkvNQI8E2lX6qHozSqHVu u2GWIUapww7zIKUdk0b7RV3wdYXUtxH/Ca/f7cOjiBCyr8YR2Atpsx2wa Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="293061345" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="293061345" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10520"; a="809735385" X-IronPort-AV: E=Sophos;i="5.96,134,1665471600"; d="scan'208";a="809735385" From: Andy Shevchenko To: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Andy Shevchenko , Mika Westerberg , Michael Ellerman , Arnd Bergmann , Bjorn Helgaas , "Rafael J. Wysocki" , 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, sparclinux@vger.kernel.org, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org Cc: Miguel Ojeda , Richard Henderson , Ivan Kokshaysky , Matt Turner , Russell King , Thomas Bogendoerfer , Nicholas Piggin , Christophe Leroy , "David S. Miller" , Bjorn Helgaas , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v2 4/4] pcmcia: Convert to use pci_bus_for_each_resource_p() Date: Thu, 3 Nov 2022 18:46:44 +0200 Message-Id: <20221103164644.70554-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> References: <20221103164644.70554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1667494061459100002 Content-Type: text/plain; charset="utf-8" The pci_bus_for_each_resource_p() hides the iterator loop since it may be not used otherwise. With this, we may drop that iterator variable definition. Signed-off-by: Andy Shevchenko --- drivers/pcmcia/rsrc_nonstatic.c | 9 +++------ drivers/pcmcia/yenta_socket.c | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstati= c.c index ad1141fddb4c..9d92d4bb6239 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -934,7 +934,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned = int action, unsigned long static int nonstatic_autoadd_resources(struct pcmcia_socket *s) { struct resource *res; - int i, done =3D 0; + int done =3D 0; =20 if (!s->cb_dev || !s->cb_dev->bus) return -ENODEV; @@ -960,12 +960,9 @@ static int nonstatic_autoadd_resources(struct pcmcia_s= ocket *s) */ if (s->cb_dev->bus->number =3D=3D 0) return -EINVAL; - - for (i =3D 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) { - res =3D s->cb_dev->bus->resource[i]; -#else - pci_bus_for_each_resource(s->cb_dev->bus, res, i) { #endif + + pci_bus_for_each_resource_p(s->cb_dev->bus, res) { if (!res) continue; =20 diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 3966a6ceb1ac..b200f2b99a7a 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -673,9 +673,8 @@ static int yenta_search_res(struct yenta_socket *socket= , struct resource *res, u32 min) { struct resource *root; - int i; =20 - pci_bus_for_each_resource(socket->dev->bus, root, i) { + pci_bus_for_each_resource_p(socket->dev->bus, root) { if (!root) continue; =20 --=20 2.35.1