aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/msi.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 762bff18187d..d5b9b94a2ac5 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -459,12 +459,13 @@ static int msix_capability_init(struct pci_dev *dev,
459/** 459/**
460 * pci_msi_supported - check whether MSI may be enabled on device 460 * pci_msi_supported - check whether MSI may be enabled on device
461 * @dev: pointer to the pci_dev data structure of MSI device function 461 * @dev: pointer to the pci_dev data structure of MSI device function
462 * @type: are we checking for MSI or MSI-X ?
462 * 463 *
463 * Look at global flags, the device itself, and its parent busses 464 * Look at global flags, the device itself, and its parent busses
464 * to return 0 if MSI are supported for the device. 465 * to return 0 if MSI are supported for the device.
465 **/ 466 **/
466static 467static
467int pci_msi_supported(struct pci_dev * dev) 468int pci_msi_supported(struct pci_dev * dev, int type)
468{ 469{
469 struct pci_bus *bus; 470 struct pci_bus *bus;
470 471
@@ -482,6 +483,9 @@ int pci_msi_supported(struct pci_dev * dev)
482 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) 483 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
483 return -EINVAL; 484 return -EINVAL;
484 485
486 if (!pci_find_capability(dev, type))
487 return -EINVAL;
488
485 return 0; 489 return 0;
486} 490}
487 491
@@ -497,13 +501,9 @@ int pci_msi_supported(struct pci_dev * dev)
497 **/ 501 **/
498int pci_enable_msi(struct pci_dev* dev) 502int pci_enable_msi(struct pci_dev* dev)
499{ 503{
500 int pos, status; 504 int status;
501 505
502 if (pci_msi_supported(dev) < 0) 506 if (pci_msi_supported(dev, PCI_CAP_ID_MSI))
503 return -EINVAL;
504
505 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
506 if (!pos)
507 return -EINVAL; 507 return -EINVAL;
508 508
509 WARN_ON(!!dev->msi_enabled); 509 WARN_ON(!!dev->msi_enabled);
@@ -606,13 +606,10 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
606 int i, j; 606 int i, j;
607 u16 control; 607 u16 control;
608 608
609 if (!entries || pci_msi_supported(dev) < 0) 609 if (!entries || pci_msi_supported(dev, PCI_CAP_ID_MSIX))
610 return -EINVAL; 610 return -EINVAL;
611 611
612 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); 612 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
613 if (!pos)
614 return -EINVAL;
615
616 pci_read_config_word(dev, msi_control_reg(pos), &control); 613 pci_read_config_word(dev, msi_control_reg(pos), &control);
617 nr_entries = multi_msix_capable(control); 614 nr_entries = multi_msix_capable(control);
618 if (nvec > nr_entries) 615 if (nvec > nr_entries)