diff options
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index cb1dd5f4988c..1531f3a49879 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -2576,18 +2576,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function); | |||
2576 | */ | 2576 | */ |
2577 | int pcix_get_max_mmrbc(struct pci_dev *dev) | 2577 | int pcix_get_max_mmrbc(struct pci_dev *dev) |
2578 | { | 2578 | { |
2579 | int err, cap; | 2579 | int cap; |
2580 | u32 stat; | 2580 | u32 stat; |
2581 | 2581 | ||
2582 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); | 2582 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); |
2583 | if (!cap) | 2583 | if (!cap) |
2584 | return -EINVAL; | 2584 | return -EINVAL; |
2585 | 2585 | ||
2586 | err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat); | 2586 | if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat)) |
2587 | if (err) | ||
2588 | return -EINVAL; | 2587 | return -EINVAL; |
2589 | 2588 | ||
2590 | return (stat & PCI_X_STATUS_MAX_READ) >> 12; | 2589 | return 512 << ((stat & PCI_X_STATUS_MAX_READ) >> 21); |
2591 | } | 2590 | } |
2592 | EXPORT_SYMBOL(pcix_get_max_mmrbc); | 2591 | EXPORT_SYMBOL(pcix_get_max_mmrbc); |
2593 | 2592 | ||
@@ -2600,18 +2599,17 @@ EXPORT_SYMBOL(pcix_get_max_mmrbc); | |||
2600 | */ | 2599 | */ |
2601 | int pcix_get_mmrbc(struct pci_dev *dev) | 2600 | int pcix_get_mmrbc(struct pci_dev *dev) |
2602 | { | 2601 | { |
2603 | int ret, cap; | 2602 | int cap; |
2604 | u32 cmd; | 2603 | u16 cmd; |
2605 | 2604 | ||
2606 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); | 2605 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); |
2607 | if (!cap) | 2606 | if (!cap) |
2608 | return -EINVAL; | 2607 | return -EINVAL; |
2609 | 2608 | ||
2610 | ret = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd); | 2609 | if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd)) |
2611 | if (!ret) | 2610 | return -EINVAL; |
2612 | ret = 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2); | ||
2613 | 2611 | ||
2614 | return ret; | 2612 | return 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2); |
2615 | } | 2613 | } |
2616 | EXPORT_SYMBOL(pcix_get_mmrbc); | 2614 | EXPORT_SYMBOL(pcix_get_mmrbc); |
2617 | 2615 | ||
@@ -2626,28 +2624,27 @@ EXPORT_SYMBOL(pcix_get_mmrbc); | |||
2626 | */ | 2624 | */ |
2627 | int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc) | 2625 | int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc) |
2628 | { | 2626 | { |
2629 | int cap, err = -EINVAL; | 2627 | int cap; |
2630 | u32 stat, cmd, v, o; | 2628 | u32 stat, v, o; |
2629 | u16 cmd; | ||
2631 | 2630 | ||
2632 | if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc)) | 2631 | if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc)) |
2633 | goto out; | 2632 | return -EINVAL; |
2634 | 2633 | ||
2635 | v = ffs(mmrbc) - 10; | 2634 | v = ffs(mmrbc) - 10; |
2636 | 2635 | ||
2637 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); | 2636 | cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); |
2638 | if (!cap) | 2637 | if (!cap) |
2639 | goto out; | 2638 | return -EINVAL; |
2640 | 2639 | ||
2641 | err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat); | 2640 | if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat)) |
2642 | if (err) | 2641 | return -EINVAL; |
2643 | goto out; | ||
2644 | 2642 | ||
2645 | if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21) | 2643 | if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21) |
2646 | return -E2BIG; | 2644 | return -E2BIG; |
2647 | 2645 | ||
2648 | err = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd); | 2646 | if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd)) |
2649 | if (err) | 2647 | return -EINVAL; |
2650 | goto out; | ||
2651 | 2648 | ||
2652 | o = (cmd & PCI_X_CMD_MAX_READ) >> 2; | 2649 | o = (cmd & PCI_X_CMD_MAX_READ) >> 2; |
2653 | if (o != v) { | 2650 | if (o != v) { |
@@ -2657,10 +2654,10 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc) | |||
2657 | 2654 | ||
2658 | cmd &= ~PCI_X_CMD_MAX_READ; | 2655 | cmd &= ~PCI_X_CMD_MAX_READ; |
2659 | cmd |= v << 2; | 2656 | cmd |= v << 2; |
2660 | err = pci_write_config_dword(dev, cap + PCI_X_CMD, cmd); | 2657 | if (pci_write_config_word(dev, cap + PCI_X_CMD, cmd)) |
2658 | return -EIO; | ||
2661 | } | 2659 | } |
2662 | out: | 2660 | return 0; |
2663 | return err; | ||
2664 | } | 2661 | } |
2665 | EXPORT_SYMBOL(pcix_set_mmrbc); | 2662 | EXPORT_SYMBOL(pcix_set_mmrbc); |
2666 | 2663 | ||
@@ -3023,7 +3020,6 @@ EXPORT_SYMBOL(pcim_pin_device); | |||
3023 | EXPORT_SYMBOL(pci_disable_device); | 3020 | EXPORT_SYMBOL(pci_disable_device); |
3024 | EXPORT_SYMBOL(pci_find_capability); | 3021 | EXPORT_SYMBOL(pci_find_capability); |
3025 | EXPORT_SYMBOL(pci_bus_find_capability); | 3022 | EXPORT_SYMBOL(pci_bus_find_capability); |
3026 | EXPORT_SYMBOL(pci_register_set_vga_state); | ||
3027 | EXPORT_SYMBOL(pci_release_regions); | 3023 | EXPORT_SYMBOL(pci_release_regions); |
3028 | EXPORT_SYMBOL(pci_request_regions); | 3024 | EXPORT_SYMBOL(pci_request_regions); |
3029 | EXPORT_SYMBOL(pci_request_regions_exclusive); | 3025 | EXPORT_SYMBOL(pci_request_regions_exclusive); |