Skip to content

Commit

Permalink
PCI/AER: Reuse existing pcie_port_find_device() interface
Browse files Browse the repository at this point in the history
The port services driver already provides a method to find the pcie_device
for a service.  Export that function, use it from the aer_inject module,
and remove the duplicate functionality.

Signed-off-by: Keith Busch <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
  • Loading branch information
Keith Busch authored and bjorn-helgaas committed Oct 19, 2018
1 parent 369fd7b commit 0e98db2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
25 changes: 4 additions & 21 deletions drivers/pci/pcie/aer_inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,32 +303,13 @@ static int pci_bus_set_aer_ops(struct pci_bus *bus)
return 0;
}

static int find_aer_device_iter(struct device *device, void *data)
{
struct pcie_device **result = data;
struct pcie_device *pcie_dev;

if (device->bus == &pcie_port_bus_type) {
pcie_dev = to_pcie_device(device);
if (pcie_dev->service & PCIE_PORT_SERVICE_AER) {
*result = pcie_dev;
return 1;
}
}
return 0;
}

static int find_aer_device(struct pci_dev *dev, struct pcie_device **result)
{
return device_for_each_child(&dev->dev, result, find_aer_device_iter);
}

static int aer_inject(struct aer_error_inj *einj)
{
struct aer_error *err, *rperr;
struct aer_error *err_alloc = NULL, *rperr_alloc = NULL;
struct pci_dev *dev, *rpdev;
struct pcie_device *edev;
struct device *device;
unsigned long flags;
unsigned int devfn = PCI_DEVFN(einj->dev, einj->fn);
int pos_cap_err, rp_pos_cap_err;
Expand Down Expand Up @@ -464,7 +445,9 @@ static int aer_inject(struct aer_error_inj *einj)
if (ret)
goto out_put;

if (find_aer_device(rpdev, &edev)) {
device = pcie_port_find_device(rpdev, PCIE_PORT_SERVICE_AER);
if (device) {
edev = to_pcie_device(device);
if (!get_service_data(edev)) {
dev_warn(&edev->device,
"aer_inject: AER service is not initialized\n");
Expand Down
1 change: 1 addition & 0 deletions drivers/pci/pcie/portdrv_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ struct device *pcie_port_find_device(struct pci_dev *dev,
device = pdrvs.dev;
return device;
}
EXPORT_SYMBOL_GPL(pcie_port_find_device);

/**
* pcie_port_device_remove - unregister PCI Express port service devices
Expand Down

0 comments on commit 0e98db2

Please sign in to comment.