From 1ce76bc0497b9289d6f6195258d8bdc1c42eb91a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ilpo=20J=C3=A4rvinen?= Date: Fri, 29 Aug 2025 16:10:54 +0300 Subject: [PATCH] PCI: Refactor find_bus_resource_of_type() logic checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reorder the logic checks in find_bus_resource_of_type() to simplify them. Signed-off-by: Ilpo Järvinen Signed-off-by: Bjorn Helgaas Link: https://patch.msgid.link/20250829131113.36754-6-ilpo.jarvinen@linux.intel.com --- drivers/pci/setup-bus.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 4097d8703b8f1..c5fc4e2825be3 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -158,11 +158,15 @@ static struct resource *find_bus_resource_of_type(struct pci_bus *bus, struct resource *r, *r_assigned = NULL; pci_bus_for_each_resource(bus, r) { - if (r == &ioport_resource || r == &iomem_resource) + if (!r || r == &ioport_resource || r == &iomem_resource) continue; - if (r && (r->flags & type_mask) == type && !r->parent) + + if ((r->flags & type_mask) != type) + continue; + + if (!r->parent) return r; - if (r && (r->flags & type_mask) == type && !r_assigned) + if (!r_assigned) r_assigned = r; } return r_assigned; -- 2.47.3