PCI: Make local functions static
[pandora-kernel.git] / drivers / pci / pci.c
index b127fbd..9ea3108 100644 (file)
@@ -198,7 +198,7 @@ static int __pci_bus_find_cap_start(struct pci_bus *bus,
 }
 
 /**
- * pci_find_capability - query for devices' capabilities 
+ * pci_find_capability - query for devices' capabilities
  * @dev: PCI device to query
  * @cap: capability code
  *
@@ -207,12 +207,12 @@ static int __pci_bus_find_cap_start(struct pci_bus *bus,
  * device's PCI configuration space or 0 in case the device does not
  * support it.  Possible values for @cap:
  *
- *  %PCI_CAP_ID_PM           Power Management 
- *  %PCI_CAP_ID_AGP          Accelerated Graphics Port 
- *  %PCI_CAP_ID_VPD          Vital Product Data 
- *  %PCI_CAP_ID_SLOTID       Slot Identification 
+ *  %PCI_CAP_ID_PM           Power Management
+ *  %PCI_CAP_ID_AGP          Accelerated Graphics Port
+ *  %PCI_CAP_ID_VPD          Vital Product Data
+ *  %PCI_CAP_ID_SLOTID       Slot Identification
  *  %PCI_CAP_ID_MSI          Message Signalled Interrupts
- *  %PCI_CAP_ID_CHSWP        CompactPCI HotSwap 
+ *  %PCI_CAP_ID_CHSWP        CompactPCI HotSwap
  *  %PCI_CAP_ID_PCIX         PCI-X
  *  %PCI_CAP_ID_EXP          PCI Express
  */
@@ -228,13 +228,13 @@ int pci_find_capability(struct pci_dev *dev, int cap)
 }
 
 /**
- * pci_bus_find_capability - query for devices' capabilities 
+ * pci_bus_find_capability - query for devices' capabilities
  * @bus:   the PCI bus to query
  * @devfn: PCI device to query
  * @cap:   capability code
  *
  * Like pci_find_capability() but works for pci devices that do not have a
- * pci_dev structure set up yet. 
+ * pci_dev structure set up yet.
  *
  * Returns the address of the requested capability structure within the
  * device's PCI configuration space or 0 in case the device does not
@@ -515,7 +515,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
                return -EINVAL;
 
        /* Validate current state:
-        * Can enter D0 from any state, but if we can only go deeper 
+        * Can enter D0 from any state, but if we can only go deeper
         * to sleep if we're already in a low power state
         */
        if (state != PCI_D0 && dev->current_state <= PCI_D3cold
@@ -656,6 +656,28 @@ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
        return error;
 }
 
+/**
+ * pci_wakeup - Wake up a PCI device
+ * @pci_dev: Device to handle.
+ * @ign: ignored parameter
+ */
+static int pci_wakeup(struct pci_dev *pci_dev, void *ign)
+{
+       pci_wakeup_event(pci_dev);
+       pm_request_resume(&pci_dev->dev);
+       return 0;
+}
+
+/**
+ * pci_wakeup_bus - Walk given bus and wake up devices on it
+ * @bus: Top bus of the subtree to walk.
+ */
+static void pci_wakeup_bus(struct pci_bus *bus)
+{
+       if (bus)
+               pci_walk_bus(bus, pci_wakeup, NULL);
+}
+
 /**
  * __pci_start_power_transition - Start power transition of a PCI device
  * @dev: PCI device to handle.
@@ -835,8 +857,8 @@ EXPORT_SYMBOL(pci_choose_state);
 #define PCI_EXP_SAVE_REGS      7
 
 
-static struct pci_cap_saved_state *pci_find_saved_cap(
-       struct pci_dev *pci_dev, char cap)
+static struct pci_cap_saved_state *pci_find_saved_cap(struct pci_dev *pci_dev,
+                                                     char cap)
 {
        struct pci_cap_saved_state *tmp;
 
@@ -998,7 +1020,7 @@ static void pci_restore_config_space(struct pci_dev *pdev)
        }
 }
 
-/** 
+/**
  * pci_restore_state - Restore the saved state of a PCI device
  * @dev: - PCI device that we're dealing with
  */
@@ -1030,7 +1052,7 @@ struct pci_saved_state {
  *                        the device saved state.
  * @dev: PCI device that we're dealing with
  *
- * Rerturn NULL if no state or error.
+ * Return NULL if no state or error.
  */
 struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev)
 {
@@ -1071,7 +1093,8 @@ EXPORT_SYMBOL_GPL(pci_store_saved_state);
  * @dev: PCI device that we're dealing with
  * @state: Saved state returned from pci_store_saved_state()
  */
-int pci_load_saved_state(struct pci_dev *dev, struct pci_saved_state *state)
+static int pci_load_saved_state(struct pci_dev *dev,
+                               struct pci_saved_state *state)
 {
        struct pci_cap_saved_data *cap;
 
@@ -1099,7 +1122,6 @@ int pci_load_saved_state(struct pci_dev *dev, struct pci_saved_state *state)
        dev->state_saved = true;
        return 0;
 }
-EXPORT_SYMBOL_GPL(pci_load_saved_state);
 
 /**
  * pci_load_and_free_saved_state - Reload the save state pointed to by state,
@@ -1531,27 +1553,6 @@ void pci_pme_wakeup_bus(struct pci_bus *bus)
                pci_walk_bus(bus, pci_pme_wakeup, (void *)true);
 }
 
-/**
- * pci_wakeup - Wake up a PCI device
- * @pci_dev: Device to handle.
- * @ign: ignored parameter
- */
-static int pci_wakeup(struct pci_dev *pci_dev, void *ign)
-{
-       pci_wakeup_event(pci_dev);
-       pm_request_resume(&pci_dev->dev);
-       return 0;
-}
-
-/**
- * pci_wakeup_bus - Walk given bus and wake up devices on it
- * @bus: Top bus of the subtree to walk.
- */
-void pci_wakeup_bus(struct pci_bus *bus)
-{
-       if (bus)
-               pci_walk_bus(bus, pci_wakeup, NULL);
-}
 
 /**
  * pci_pme_capable - check the capability of PCI device to generate PME#
@@ -1765,7 +1766,7 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable)
  * If the platform can't manage @dev, return the deepest state from which it
  * can generate wake events, based on any available PME info.
  */
-pci_power_t pci_target_state(struct pci_dev *dev)
+static pci_power_t pci_target_state(struct pci_dev *dev)
 {
        pci_power_t target_state = PCI_D3hot;
 
@@ -1880,7 +1881,7 @@ int pci_finish_runtime_suspend(struct pci_dev *dev)
  * pci_dev_run_wake - Check if device can generate run-time wake-up events.
  * @dev: Device to check.
  *
- * Return true if the device itself is cabable of generating wake-up events
+ * Return true if the device itself is capable of generating wake-up events
  * (through the platform or using the native PCIe PME) or if the device supports
  * PME and one of its upstream bridges can generate wake-up events.
  */
@@ -2110,242 +2111,6 @@ void pci_configure_ari(struct pci_dev *dev)
        }
 }
 
-/**
- * pci_enable_ido - enable ID-based Ordering on a device
- * @dev: the PCI device
- * @type: which types of IDO to enable
- *
- * Enable ID-based ordering on @dev.  @type can contain the bits
- * %PCI_EXP_IDO_REQUEST and/or %PCI_EXP_IDO_COMPLETION to indicate
- * which types of transactions are allowed to be re-ordered.
- */
-void pci_enable_ido(struct pci_dev *dev, unsigned long type)
-{
-       u16 ctrl = 0;
-
-       if (type & PCI_EXP_IDO_REQUEST)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_REQ_EN;
-       if (type & PCI_EXP_IDO_COMPLETION)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_CMP_EN;
-       if (ctrl)
-               pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, ctrl);
-}
-EXPORT_SYMBOL(pci_enable_ido);
-
-/**
- * pci_disable_ido - disable ID-based ordering on a device
- * @dev: the PCI device
- * @type: which types of IDO to disable
- */
-void pci_disable_ido(struct pci_dev *dev, unsigned long type)
-{
-       u16 ctrl = 0;
-
-       if (type & PCI_EXP_IDO_REQUEST)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_REQ_EN;
-       if (type & PCI_EXP_IDO_COMPLETION)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_CMP_EN;
-       if (ctrl)
-               pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, ctrl);
-}
-EXPORT_SYMBOL(pci_disable_ido);
-
-/**
- * pci_enable_obff - enable optimized buffer flush/fill
- * @dev: PCI device
- * @type: type of signaling to use
- *
- * Try to enable @type OBFF signaling on @dev.  It will try using WAKE#
- * signaling if possible, falling back to message signaling only if
- * WAKE# isn't supported.  @type should indicate whether the PCIe link
- * be brought out of L0s or L1 to send the message.  It should be either
- * %PCI_EXP_OBFF_SIGNAL_ALWAYS or %PCI_OBFF_SIGNAL_L0.
- *
- * If your device can benefit from receiving all messages, even at the
- * power cost of bringing the link back up from a low power state, use
- * %PCI_EXP_OBFF_SIGNAL_ALWAYS.  Otherwise, use %PCI_OBFF_SIGNAL_L0 (the
- * preferred type).
- *
- * RETURNS:
- * Zero on success, appropriate error number on failure.
- */
-int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type type)
-{
-       u32 cap;
-       u16 ctrl;
-       int ret;
-
-       pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);
-       if (!(cap & PCI_EXP_DEVCAP2_OBFF_MASK))
-               return -ENOTSUPP; /* no OBFF support at all */
-
-       /* Make sure the topology supports OBFF as well */
-       if (dev->bus->self) {
-               ret = pci_enable_obff(dev->bus->self, type);
-               if (ret)
-                       return ret;
-       }
-
-       pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &ctrl);
-       if (cap & PCI_EXP_DEVCAP2_OBFF_WAKE)
-               ctrl |= PCI_EXP_DEVCTL2_OBFF_WAKE_EN;
-       else {
-               switch (type) {
-               case PCI_EXP_OBFF_SIGNAL_L0:
-                       if (!(ctrl & PCI_EXP_DEVCTL2_OBFF_WAKE_EN))
-                               ctrl |= PCI_EXP_DEVCTL2_OBFF_MSGA_EN;
-                       break;
-               case PCI_EXP_OBFF_SIGNAL_ALWAYS:
-                       ctrl &= ~PCI_EXP_DEVCTL2_OBFF_WAKE_EN;
-                       ctrl |= PCI_EXP_DEVCTL2_OBFF_MSGB_EN;
-                       break;
-               default:
-                       WARN(1, "bad OBFF signal type\n");
-                       return -ENOTSUPP;
-               }
-       }
-       pcie_capability_write_word(dev, PCI_EXP_DEVCTL2, ctrl);
-
-       return 0;
-}
-EXPORT_SYMBOL(pci_enable_obff);
-
-/**
- * pci_disable_obff - disable optimized buffer flush/fill
- * @dev: PCI device
- *
- * Disable OBFF on @dev.
- */
-void pci_disable_obff(struct pci_dev *dev)
-{
-       pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2,
-                                  PCI_EXP_DEVCTL2_OBFF_WAKE_EN);
-}
-EXPORT_SYMBOL(pci_disable_obff);
-
-/**
- * pci_ltr_supported - check whether a device supports LTR
- * @dev: PCI device
- *
- * RETURNS:
- * True if @dev supports latency tolerance reporting, false otherwise.
- */
-static bool pci_ltr_supported(struct pci_dev *dev)
-{
-       u32 cap;
-
-       pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);
-
-       return cap & PCI_EXP_DEVCAP2_LTR;
-}
-
-/**
- * pci_enable_ltr - enable latency tolerance reporting
- * @dev: PCI device
- *
- * Enable LTR on @dev if possible, which means enabling it first on
- * upstream ports.
- *
- * RETURNS:
- * Zero on success, errno on failure.
- */
-int pci_enable_ltr(struct pci_dev *dev)
-{
-       int ret;
-
-       /* Only primary function can enable/disable LTR */
-       if (PCI_FUNC(dev->devfn) != 0)
-               return -EINVAL;
-
-       if (!pci_ltr_supported(dev))
-               return -ENOTSUPP;
-
-       /* Enable upstream ports first */
-       if (dev->bus->self) {
-               ret = pci_enable_ltr(dev->bus->self);
-               if (ret)
-                       return ret;
-       }
-
-       return pcie_capability_set_word(dev, PCI_EXP_DEVCTL2,
-                                       PCI_EXP_DEVCTL2_LTR_EN);
-}
-EXPORT_SYMBOL(pci_enable_ltr);
-
-/**
- * pci_disable_ltr - disable latency tolerance reporting
- * @dev: PCI device
- */
-void pci_disable_ltr(struct pci_dev *dev)
-{
-       /* Only primary function can enable/disable LTR */
-       if (PCI_FUNC(dev->devfn) != 0)
-               return;
-
-       if (!pci_ltr_supported(dev))
-               return;
-
-       pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2,
-                                  PCI_EXP_DEVCTL2_LTR_EN);
-}
-EXPORT_SYMBOL(pci_disable_ltr);
-
-static int __pci_ltr_scale(int *val)
-{
-       int scale = 0;
-
-       while (*val > 1023) {
-               *val = (*val + 31) / 32;
-               scale++;
-       }
-       return scale;
-}
-
-/**
- * pci_set_ltr - set LTR latency values
- * @dev: PCI device
- * @snoop_lat_ns: snoop latency in nanoseconds
- * @nosnoop_lat_ns: nosnoop latency in nanoseconds
- *
- * Figure out the scale and set the LTR values accordingly.
- */
-int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns)
-{
-       int pos, ret, snoop_scale, nosnoop_scale;
-       u16 val;
-
-       if (!pci_ltr_supported(dev))
-               return -ENOTSUPP;
-
-       snoop_scale = __pci_ltr_scale(&snoop_lat_ns);
-       nosnoop_scale = __pci_ltr_scale(&nosnoop_lat_ns);
-
-       if (snoop_lat_ns > PCI_LTR_VALUE_MASK ||
-           nosnoop_lat_ns > PCI_LTR_VALUE_MASK)
-               return -EINVAL;
-
-       if ((snoop_scale > (PCI_LTR_SCALE_MASK >> PCI_LTR_SCALE_SHIFT)) ||
-           (nosnoop_scale > (PCI_LTR_SCALE_MASK >> PCI_LTR_SCALE_SHIFT)))
-               return -EINVAL;
-
-       pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR);
-       if (!pos)
-               return -ENOTSUPP;
-
-       val = (snoop_scale << PCI_LTR_SCALE_SHIFT) | snoop_lat_ns;
-       ret = pci_write_config_word(dev, pos + PCI_LTR_MAX_SNOOP_LAT, val);
-       if (ret != 4)
-               return -EIO;
-
-       val = (nosnoop_scale << PCI_LTR_SCALE_SHIFT) | nosnoop_lat_ns;
-       ret = pci_write_config_word(dev, pos + PCI_LTR_MAX_NOSNOOP_LAT, val);
-       if (ret != 4)
-               return -EIO;
-
-       return 0;
-}
-EXPORT_SYMBOL(pci_set_ltr);
-
 static int pci_acs_enable;
 
 /**
@@ -2447,7 +2212,7 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
        switch (pci_pcie_type(pdev)) {
        /*
         * PCI/X-to-PCIe bridges are not specifically mentioned by the spec,
-        * but since their primary inteface is PCI/X, we conservatively
+        * but since their primary interface is PCI/X, we conservatively
         * handle them as we would a non-PCIe device.
         */
        case PCI_EXP_TYPE_PCIE_BRIDGE:
@@ -2471,7 +2236,7 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
        /*
         * PCIe 3.0, 6.12.1.2 specifies ACS capabilities that should be
         * implemented by the remaining PCIe types to indicate peer-to-peer
-        * capabilities, but only when they are part of a multifunciton
+        * capabilities, but only when they are part of a multifunction
         * device.  The footnote for section 6.12 indicates the specific
         * PCIe types included here.
         */
@@ -2486,7 +2251,7 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
        }
 
        /*
-        * PCIe 3.0, 6.12.1.3 specifies no ACS capabilties are applicable
+        * PCIe 3.0, 6.12.1.3 specifies no ACS capabilities are applicable
         * to single function devices with the exception of downstream ports.
         */
        return true;
@@ -2622,7 +2387,7 @@ void pci_release_region(struct pci_dev *pdev, int bar)
  *
  *     If @exclusive is set, then the region is marked so that userspace
  *     is explicitly not allowed to map the resource via /dev/mem or
- *     sysfs MMIO access.
+ *     sysfs MMIO access.
  *
  *     Returns 0 on success, or %EBUSY on error.  A warning
  *     message is also printed on failure.
@@ -2634,7 +2399,7 @@ static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_n
 
        if (pci_resource_len(pdev, bar) == 0)
                return 0;
-               
+
        if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) {
                if (!request_region(pci_resource_start(pdev, bar),
                            pci_resource_len(pdev, bar), res_name))
@@ -2694,7 +2459,7 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
  *
  *     The key difference that _exclusive makes it that userspace is
  *     explicitly not allowed to map the resource via /dev/mem or
- *     sysfs.
+ *     sysfs.
  */
 int pci_request_region_exclusive(struct pci_dev *pdev, int bar, const char *res_name)
 {
@@ -2799,7 +2564,7 @@ int pci_request_regions(struct pci_dev *pdev, const char *res_name)
  *     successfully.
  *
  *     pci_request_regions_exclusive() will mark the region so that
- *     /dev/mem and the sysfs MMIO access will not be allowed.
+ *     /dev/mem and the sysfs MMIO access will not be allowed.
  *
  *     Returns 0 on success, or %EBUSY on error.  A warning
  *     message is also printed on failure.
@@ -2967,7 +2732,7 @@ pci_set_mwi(struct pci_dev *dev)
                cmd |= PCI_COMMAND_INVALIDATE;
                pci_write_config_word(dev, PCI_COMMAND, cmd);
        }
-       
+
        return 0;
 }
 
@@ -3292,7 +3057,7 @@ clear:
  *
  * NOTE: This causes the caller to sleep for twice the device power transition
  * cooldown period, which for the D0->D3hot and D3hot->D0 transitions is 10 ms
- * by devault (i.e. unless the @dev's d3_delay field has a different value).
+ * by default (i.e. unless the @dev's d3_delay field has a different value).
  * Moreover, only devices in D0 can be reset by this function.
  */
 static int pci_pm_reset(struct pci_dev *dev, int probe)
@@ -3341,7 +3106,7 @@ void pci_reset_bridge_secondary_bus(struct pci_dev *dev)
        pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl);
        /*
         * PCI spec v3.0 7.6.4.2 requires minimum Trst of 1ms.  Double
-        * this to 2ms to ensure that we meet the minium requirement.
+        * this to 2ms to ensure that we meet the minimum requirement.
         */
        msleep(2);
 
@@ -3998,7 +3763,7 @@ int pcie_set_mps(struct pci_dev *dev, int mps)
                return -EINVAL;
 
        v = ffs(mps) - 8;
-       if (v > dev->pcie_mpss) 
+       if (v > dev->pcie_mpss)
                return -EINVAL;
        v <<= 5;
 
@@ -4442,7 +4207,6 @@ EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_pme_capable);
 EXPORT_SYMBOL(pci_pme_active);
 EXPORT_SYMBOL(pci_wake_from_d3);
-EXPORT_SYMBOL(pci_target_state);
 EXPORT_SYMBOL(pci_prepare_to_sleep);
 EXPORT_SYMBOL(pci_back_from_sleep);
 EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);