diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2007-03-22 06:51:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-05-02 22:02:36 -0400 |
commit | b1e2303dba021ee417c65a89e467a2b145ff9217 (patch) | |
tree | 2d13c436766be71a31c3209be46c9cade28028df /drivers/pci/msi.c | |
parent | 3e916c0503a34ba32202a69df1cfeb82f2c5749d (diff) |
MSI: Expand pci_msi_supported()
pci_enable_msi() and pci_enable_msix() both search for the MSI/MSI-X
capability, we can fold this into pci_msi_supported() by passing the
type in.
Update the code to match the comment for pci_msi_supported(). That is
it returns 0 on success, and anything else indicates an error.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r-- | drivers/pci/msi.c | 19 |
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 | **/ |
466 | static | 467 | static |
467 | int pci_msi_supported(struct pci_dev * dev) | 468 | int 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 | **/ |
498 | int pci_enable_msi(struct pci_dev* dev) | 502 | int 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) |