diff options
author | Krishna chaitanya chundru <quic_krichai@quicinc.com> | 2024-06-19 20:41:12 +0530 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2024-07-09 16:56:36 -0500 |
commit | 100ae5d77f07f9f046106e228778c7aa1c6d3af3 (patch) | |
tree | 8f2f8f8ffcfd45b7149b08ef778eff576170e87b /drivers/pci/pci.h | |
parent | 980136d1c2b95644b96df6c7ec00ca5d7c87f37f (diff) | |
download | lwn-100ae5d77f07f9f046106e228778c7aa1c6d3af3.tar.gz lwn-100ae5d77f07f9f046106e228778c7aa1c6d3af3.zip |
PCI: Bring the PCIe speed to MBps logic to new pcie_dev_speed_mbps()
Bring the switch case in pcie_link_speed_mbps() to new function to
the header file so that it can be used in other places like
in controller driver.
Link: https://lore.kernel.org/linux-pci/20240619-opp_support-v15-3-aa769a2173a3@quicinc.com
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Diffstat (limited to 'drivers/pci/pci.h')
-rw-r--r-- | drivers/pci/pci.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fd44565c4756..7e766dcba8fb 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -290,6 +290,28 @@ void pci_bus_put(struct pci_bus *bus); (speed) == PCIE_SPEED_2_5GT ? 2500*8/10 : \ 0) +static inline int pcie_dev_speed_mbps(enum pci_bus_speed speed) +{ + switch (speed) { + case PCIE_SPEED_2_5GT: + return 2500; + case PCIE_SPEED_5_0GT: + return 5000; + case PCIE_SPEED_8_0GT: + return 8000; + case PCIE_SPEED_16_0GT: + return 16000; + case PCIE_SPEED_32_0GT: + return 32000; + case PCIE_SPEED_64_0GT: + return 64000; + default: + break; + } + + return -EINVAL; +} + const char *pci_speed_string(enum pci_bus_speed speed); enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev); enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev); |