]> www.infradead.org Git - users/hch/misc.git/commitdiff
PCI: Move find_bus_resource_of_type() earlier
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 29 Aug 2025 13:10:53 +0000 (16:10 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 16 Sep 2025 16:18:55 +0000 (11:18 -0500)
Move find_bus_resource_of_type() earlier in setup-bus.c to be able to call
it in upcoming changes.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-5-ilpo.jarvinen@linux.intel.com
drivers/pci/setup-bus.c

index def29506700e40ddcc2c1309d46947bf7e0fc47a..4097d8703b8f174ca00e08fc88bab4c54b5392bb 100644 (file)
@@ -140,6 +140,34 @@ static void restore_dev_resource(struct pci_dev_resource *dev_res)
        res->flags = dev_res->flags;
 }
 
+/*
+ * Helper function for sizing routines.  Assigned resources have non-NULL
+ * parent resource.
+ *
+ * Return first unassigned resource of the correct type.  If there is none,
+ * return first assigned resource of the correct type.  If none of the
+ * above, return NULL.
+ *
+ * Returning an assigned resource of the correct type allows the caller to
+ * distinguish between already assigned and no resource of the correct type.
+ */
+static struct resource *find_bus_resource_of_type(struct pci_bus *bus,
+                                                 unsigned long type_mask,
+                                                 unsigned long type)
+{
+       struct resource *r, *r_assigned = NULL;
+
+       pci_bus_for_each_resource(bus, r) {
+               if (r == &ioport_resource || r == &iomem_resource)
+                       continue;
+               if (r && (r->flags & type_mask) == type && !r->parent)
+                       return r;
+               if (r && (r->flags & type_mask) == type && !r_assigned)
+                       r_assigned = r;
+       }
+       return r_assigned;
+}
+
 static bool pdev_resources_assignable(struct pci_dev *dev)
 {
        u16 class = dev->class >> 8, command;
@@ -876,34 +904,6 @@ static void pci_bridge_check_ranges(struct pci_bus *bus)
        }
 }
 
-/*
- * Helper function for sizing routines.  Assigned resources have non-NULL
- * parent resource.
- *
- * Return first unassigned resource of the correct type.  If there is none,
- * return first assigned resource of the correct type.  If none of the
- * above, return NULL.
- *
- * Returning an assigned resource of the correct type allows the caller to
- * distinguish between already assigned and no resource of the correct type.
- */
-static struct resource *find_bus_resource_of_type(struct pci_bus *bus,
-                                                 unsigned long type_mask,
-                                                 unsigned long type)
-{
-       struct resource *r, *r_assigned = NULL;
-
-       pci_bus_for_each_resource(bus, r) {
-               if (r == &ioport_resource || r == &iomem_resource)
-                       continue;
-               if (r && (r->flags & type_mask) == type && !r->parent)
-                       return r;
-               if (r && (r->flags & type_mask) == type && !r_assigned)
-                       r_assigned = r;
-       }
-       return r_assigned;
-}
-
 static resource_size_t calculate_iosize(resource_size_t size,
                                        resource_size_t min_size,
                                        resource_size_t size1,