The patch introduces additional parameter to pci_msi_check_device() to trace the address of MSI or MSI-X capability structure so that we needn't retrieve that again while enabling MSI or MSI-X based interrupts for specific PCI device. Signed-off-by: Gavin Shan <shangw@xxxxxxxxxxxxxxxxxx> --- drivers/pci/msi.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 00cc78c..05e9604 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -758,12 +758,14 @@ error: * @dev: pointer to the pci_dev data structure of MSI device function * @nvec: how many MSIs have been requested ? * @type: are we checking for MSI or MSI-X ? + * @pos: address of MSI or MSI-X capability structure * * Look at global flags, the device itself, and its parent busses * to determine if MSI/-X are supported for the device. If MSI/-X is * supported return 0, else return an error code. **/ -static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type) +static int pci_msi_check_device(struct pci_dev *dev, + int nvec, int type, int *pos) { struct pci_bus *bus; int ret; @@ -795,7 +797,8 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type) if (ret) return ret; - if (!pci_find_capability(dev, type)) + *pos = pci_find_capability(dev, type); + if (!*pos) return -EINVAL; return 0; @@ -816,7 +819,7 @@ static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type) */ int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec) { - int status, pos, maxvec; + int pos, status, maxvec; u16 msgctl; pos = pci_find_capability(dev, PCI_CAP_ID_MSI); @@ -827,7 +830,7 @@ int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec) if (nvec > maxvec) return maxvec; - status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI); + status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI, &pos); if (status) return status; @@ -945,13 +948,13 @@ int pci_msix_table_size(struct pci_dev *dev) **/ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) { - int status, nr_entries; + int pos, status, nr_entries; int i, j; if (!entries) return -EINVAL; - status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX); + status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX, &pos); if (status) return status; -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html