aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2010-04-22 20:08:44 -0400
committerJiri Kosina <jkosina@suse.cz>2010-04-22 20:08:44 -0400
commit6c9468e9eb1252eaefd94ce7f06e1be9b0b641b1 (patch)
tree797676a336b050bfa1ef879377c07e541b9075d6 /drivers/pci/pci.c
parent4cb3ca7cd7e2cae8d1daf5345ec99a1e8502cf3f (diff)
parentc81eddb0e3728661d1585fbc564449c94165cc36 (diff)
Merge branch 'master' into for-next
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ddd55dc927f7..9a3d3309f896 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/slab.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/spinlock.h> 17#include <linux/spinlock.h>
17#include <linux/string.h> 18#include <linux/string.h>
@@ -2576,18 +2577,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function);
2576 */ 2577 */
2577int pcix_get_max_mmrbc(struct pci_dev *dev) 2578int pcix_get_max_mmrbc(struct pci_dev *dev)
2578{ 2579{
2579 int err, cap; 2580 int cap;
2580 u32 stat; 2581 u32 stat;
2581 2582
2582 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); 2583 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
2583 if (!cap) 2584 if (!cap)
2584 return -EINVAL; 2585 return -EINVAL;
2585 2586
2586 err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat); 2587 if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
2587 if (err)
2588 return -EINVAL; 2588 return -EINVAL;
2589 2589
2590 return (stat & PCI_X_STATUS_MAX_READ) >> 12; 2590 return 512 << ((stat & PCI_X_STATUS_MAX_READ) >> 21);
2591} 2591}
2592EXPORT_SYMBOL(pcix_get_max_mmrbc); 2592EXPORT_SYMBOL(pcix_get_max_mmrbc);
2593 2593
@@ -2600,18 +2600,17 @@ EXPORT_SYMBOL(pcix_get_max_mmrbc);
2600 */ 2600 */
2601int pcix_get_mmrbc(struct pci_dev *dev) 2601int pcix_get_mmrbc(struct pci_dev *dev)
2602{ 2602{
2603 int ret, cap; 2603 int cap;
2604 u32 cmd; 2604 u16 cmd;
2605 2605
2606 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); 2606 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
2607 if (!cap) 2607 if (!cap)
2608 return -EINVAL; 2608 return -EINVAL;
2609 2609
2610 ret = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd); 2610 if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
2611 if (!ret) 2611 return -EINVAL;
2612 ret = 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
2613 2612
2614 return ret; 2613 return 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
2615} 2614}
2616EXPORT_SYMBOL(pcix_get_mmrbc); 2615EXPORT_SYMBOL(pcix_get_mmrbc);
2617 2616
@@ -2626,28 +2625,27 @@ EXPORT_SYMBOL(pcix_get_mmrbc);
2626 */ 2625 */
2627int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc) 2626int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
2628{ 2627{
2629 int cap, err = -EINVAL; 2628 int cap;
2630 u32 stat, cmd, v, o; 2629 u32 stat, v, o;
2630 u16 cmd;
2631 2631
2632 if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc)) 2632 if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
2633 goto out; 2633 return -EINVAL;
2634 2634
2635 v = ffs(mmrbc) - 10; 2635 v = ffs(mmrbc) - 10;
2636 2636
2637 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); 2637 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
2638 if (!cap) 2638 if (!cap)
2639 goto out; 2639 return -EINVAL;
2640 2640
2641 err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat); 2641 if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
2642 if (err) 2642 return -EINVAL;
2643 goto out;
2644 2643
2645 if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21) 2644 if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21)
2646 return -E2BIG; 2645 return -E2BIG;
2647 2646
2648 err = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd); 2647 if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
2649 if (err) 2648 return -EINVAL;
2650 goto out;
2651 2649
2652 o = (cmd & PCI_X_CMD_MAX_READ) >> 2; 2650 o = (cmd & PCI_X_CMD_MAX_READ) >> 2;
2653 if (o != v) { 2651 if (o != v) {
@@ -2657,10 +2655,10 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
2657 2655
2658 cmd &= ~PCI_X_CMD_MAX_READ; 2656 cmd &= ~PCI_X_CMD_MAX_READ;
2659 cmd |= v << 2; 2657 cmd |= v << 2;
2660 err = pci_write_config_dword(dev, cap + PCI_X_CMD, cmd); 2658 if (pci_write_config_word(dev, cap + PCI_X_CMD, cmd))
2659 return -EIO;
2661 } 2660 }
2662out: 2661 return 0;
2663 return err;
2664} 2662}
2665EXPORT_SYMBOL(pcix_set_mmrbc); 2663EXPORT_SYMBOL(pcix_set_mmrbc);
2666 2664
@@ -3023,7 +3021,6 @@ EXPORT_SYMBOL(pcim_pin_device);
3023EXPORT_SYMBOL(pci_disable_device); 3021EXPORT_SYMBOL(pci_disable_device);
3024EXPORT_SYMBOL(pci_find_capability); 3022EXPORT_SYMBOL(pci_find_capability);
3025EXPORT_SYMBOL(pci_bus_find_capability); 3023EXPORT_SYMBOL(pci_bus_find_capability);
3026EXPORT_SYMBOL(pci_register_set_vga_state);
3027EXPORT_SYMBOL(pci_release_regions); 3024EXPORT_SYMBOL(pci_release_regions);
3028EXPORT_SYMBOL(pci_request_regions); 3025EXPORT_SYMBOL(pci_request_regions);
3029EXPORT_SYMBOL(pci_request_regions_exclusive); 3026EXPORT_SYMBOL(pci_request_regions_exclusive);