On Mon, Apr 17, 2023 at 10:46 AM Lukas Wunner <lukas@xxxxxxxxx> wrote: > On Mon, Mar 06, 2023 at 04:10:11PM +0100, Niklas Schnelle wrote: ... > > +void pci_bus_remove_resource(struct pci_bus *bus, struct resource *res) > > +{ > > + struct pci_bus_resource *bus_res, *tmp; > > + int i; > > + > > + for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) { > > + if (bus->resource[i] == res) { > > + bus->resource[i] = NULL; > > + return; > > + } > > + } > > + > > + list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) { > > + if (bus_res->res == res) { > > + list_del(&bus_res->list); > > + kfree(bus_res); > > + return; > > + } > > + } > > +} > > I realize this has already been applied so s390.git/master, > but nevertheless would like to point out there's a handy > pci_bus_for_each_resource() helper which could have been > used here instead of the for-loop. Actually in this case it's not possible. The above code nullifies the matched resource or removes it from the list. We don't have any good iterator inside pci_bus_for_each_resource() to do the latter. There might be other places in the kernel code where something like above is used and we can split a separate helper exactly for matching cases, but with the above context I dunno we need to do anything right now. P.S. Thanks for Cc'ing me. -- With Best Regards, Andy Shevchenko