]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/pci/pci.c
pci: implement "pci=noaer"
[mirror_ubuntu-artful-kernel.git] / drivers / pci / pci.c
index 03fd59e80fef5726c73a16f1582f4fd8dbf16836..2dd5c282fabe6a875ae9f6c55be6e9d0b57d6a90 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
+#include <linux/log2.h>
 #include <asm/dma.h>   /* isa_dma_bridge_buggy */
 #include "pci.h"
 
@@ -499,7 +500,7 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
        return 0;
 }
 
-int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
+pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
  
 /**
  * pci_choose_state - Choose the power state of a PCI device
@@ -513,15 +514,15 @@ int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
 
 pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
 {
-       int ret;
+       pci_power_t ret;
 
        if (!pci_find_capability(dev, PCI_CAP_ID_PM))
                return PCI_D0;
 
        if (platform_pci_choose_state) {
                ret = platform_pci_choose_state(dev, state);
-               if (ret >= 0)
-                       state.event = ret;
+               if (ret != PCI_POWER_ERROR)
+                       return ret;
        }
 
        switch (state.event) {
@@ -695,14 +696,13 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
 }
 
 /**
- * __pci_reenable_device - Resume abandoned device
+ * pci_reenable_device - Resume abandoned device
  * @dev: PCI device to be resumed
  *
  *  Note this function is a backend of pci_default_resume and is not supposed
  *  to be called by normal code, write proper resume handler and use it instead.
  */
-int
-__pci_reenable_device(struct pci_dev *dev)
+int pci_reenable_device(struct pci_dev *dev)
 {
        if (atomic_read(&dev->enable_cnt))
                return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1);
@@ -1455,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
        int cap, err = -EINVAL;
        u32 stat, cmd, v, o;
 
-       if (mmrbc < 512 || mmrbc > 4096 || (mmrbc & (mmrbc-1)))
+       if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
                goto out;
 
        v = ffs(mmrbc) - 10;
@@ -1517,7 +1517,7 @@ EXPORT_SYMBOL(pcie_get_readrq);
 /**
  * pcie_set_readrq - set PCI Express maximum memory read request
  * @dev: PCI device to query
- * @count: maximum memory read count in bytes
+ * @rq: maximum memory read count in bytes
  *    valid values are 128, 256, 512, 1024, 2048, 4096
  *
  * If possible sets maximum read byte count
@@ -1527,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
        int cap, err = -EINVAL;
        u16 ctl, v;
 
-       if (rq < 128 || rq > 4096 || (rq & (rq-1)))
+       if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
                goto out;
 
        v = (ffs(rq) - 8) << 12;
@@ -1586,6 +1586,8 @@ static int __devinit pci_setup(char *str)
                if (*str && (str = pcibios_setup(str)) && *str) {
                        if (!strcmp(str, "nomsi")) {
                                pci_no_msi();
+                       } else if (!strcmp(str, "noaer")) {
+                               pci_no_aer();
                        } else if (!strncmp(str, "cbiosize=", 9)) {
                                pci_cardbus_io_size = memparse(str + 9, &str);
                        } else if (!strncmp(str, "cbmemsize=", 10)) {
@@ -1604,6 +1606,7 @@ early_param("pci", pci_setup);
 device_initcall(pci_init);
 
 EXPORT_SYMBOL_GPL(pci_restore_bars);
+EXPORT_SYMBOL(pci_reenable_device);
 EXPORT_SYMBOL(pci_enable_device_bars);
 EXPORT_SYMBOL(pci_enable_device);
 EXPORT_SYMBOL(pcim_enable_device);