Skip to content

Commit 4d6dcd6

Browse files
keithbuschbjorn-helgaas
authored andcommitted
PCI: Move __pci_walk_bus() mutex to where we need it
Simplify __pci_walk_bus() by moving the pci_bus_sem mutex into pci_walk_bus(), the only place it is needed, and removing the parameter that told __pci_walk_bus() whether to acquire the mutex. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Keith Busch <[email protected]> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Davidlohr Bueso <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]>
1 parent e3f30d5 commit 4d6dcd6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/pci/bus.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,16 +390,14 @@ void pci_bus_add_devices(const struct pci_bus *bus)
390390
EXPORT_SYMBOL(pci_bus_add_devices);
391391

392392
static void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
393-
void *userdata, bool locked)
393+
void *userdata)
394394
{
395395
struct pci_dev *dev;
396396
struct pci_bus *bus;
397397
struct list_head *next;
398398
int retval;
399399

400400
bus = top;
401-
if (!locked)
402-
down_read(&pci_bus_sem);
403401
next = top->devices.next;
404402
for (;;) {
405403
if (next == &bus->devices) {
@@ -422,8 +420,6 @@ static void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void
422420
if (retval)
423421
break;
424422
}
425-
if (!locked)
426-
up_read(&pci_bus_sem);
427423
}
428424

429425
/**
@@ -441,15 +437,17 @@ static void __pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void
441437
*/
442438
void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), void *userdata)
443439
{
444-
__pci_walk_bus(top, cb, userdata, false);
440+
down_read(&pci_bus_sem);
441+
__pci_walk_bus(top, cb, userdata);
442+
up_read(&pci_bus_sem);
445443
}
446444
EXPORT_SYMBOL_GPL(pci_walk_bus);
447445

448446
void pci_walk_bus_locked(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), void *userdata)
449447
{
450448
lockdep_assert_held(&pci_bus_sem);
451449

452-
__pci_walk_bus(top, cb, userdata, true);
450+
__pci_walk_bus(top, cb, userdata);
453451
}
454452
EXPORT_SYMBOL_GPL(pci_walk_bus_locked);
455453

0 commit comments

Comments
 (0)