Skip to content

Commit 12a9da0

Browse files
Alex Chiangjbarnes993
authored andcommitted
PCI Hotplug: cpqphp: don't use pci_find_slot()
Convert uses of pci_find_slot to modern API. In the conversion sites, we end up calling pci_dev_put() right away. This may seem like it misses the entire point of doing something like pci_get_bus_and_slot(), since we drop the reference so soon, but it turns out we don't actually do much with the returned pci_dev. I plan on untangling cpqphp further, but clearly cpqphp never worried too much about a properly refcounted pci_dev anyway. For now, this conversion seems reasonable, as it gets rid of the last in-tree caller of pci_find_slot. Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent 6d1e87d commit 12a9da0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

drivers/pci/hotplug/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ config HOTPLUG_PCI_FAKE
4141

4242
config HOTPLUG_PCI_COMPAQ
4343
tristate "Compaq PCI Hotplug driver"
44-
depends on X86 && PCI_BIOS && PCI_LEGACY
44+
depends on X86 && PCI_BIOS
4545
help
4646
Say Y here if you have a motherboard with a Compaq PCI Hotplug
4747
controller.

drivers/pci/hotplug/cpqphp_pci.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
8888
int num;
8989

9090
if (func->pci_dev == NULL)
91-
func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
91+
func->pci_dev = pci_get_bus_and_slot(func->bus,PCI_DEVFN(func->device, func->function));
9292

9393
/* No pci device, we need to create it then */
9494
if (func->pci_dev == NULL) {
@@ -98,7 +98,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
9898
if (num)
9999
pci_bus_add_devices(ctrl->pci_dev->bus);
100100

101-
func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
101+
func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
102102
if (func->pci_dev == NULL) {
103103
dbg("ERROR: pci_dev still null\n");
104104
return 0;
@@ -111,6 +111,8 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
111111
pci_do_scan_bus(child);
112112
}
113113

114+
pci_dev_put(func->pci_dev);
115+
114116
return 0;
115117
}
116118

@@ -122,9 +124,11 @@ int cpqhp_unconfigure_device(struct pci_func* func)
122124
dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function);
123125

124126
for (j=0; j<8 ; j++) {
125-
struct pci_dev* temp = pci_find_slot(func->bus, PCI_DEVFN(func->device, j));
126-
if (temp)
127+
struct pci_dev* temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
128+
if (temp) {
129+
pci_dev_put(temp);
127130
pci_remove_bus_device(temp);
131+
}
128132
}
129133
return 0;
130134
}
@@ -406,14 +410,16 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
406410
new_slot->switch_save = 0x10;
407411
/* In case of unsupported board */
408412
new_slot->status = DevError;
409-
new_slot->pci_dev = pci_find_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
413+
new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
410414

411415
for (cloop = 0; cloop < 0x20; cloop++) {
412416
rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop]));
413417
if (rc)
414418
return rc;
415419
}
416420

421+
pci_dev_put(new_slot->pci_dev);
422+
417423
function++;
418424

419425
stop_it = 0;

0 commit comments

Comments
 (0)