Re: [PATCH v6 3/7] PCI: Add pci_lnkctl2_bus_speed() to convert lnkctl2speed to pci_bus_speed
From: Bjorn Helgaas
Date: Fri Nov 20 2026 - 12:11:09 EST
On Thu, Nov 19, 2026 at 06:26:35PM +0530, Krishna Chaitanya Chundru wrote:
> Add a exported function to convert lnkctl2speed to enum pci_bus_speed,
> so that other kernel drivers can use it.
>
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@xxxxxxxxxxxxxxxx>
Acked-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Nit below.
> ---
> drivers/pci/pci.c | 15 +++++++++++++++
> include/linux/pci.h | 1 +
> 2 files changed, 16 insertions(+)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7c6f2aba8144..a89955617bec 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6056,6 +6056,21 @@ int pcie_link_bandwidth_mbps(struct pci_dev *pdev)
> }
> EXPORT_SYMBOL(pcie_link_bandwidth_mbps);
>
> +/**
> + * pci_lnkctl2_bus_speed - convert Link Control 2 Target Link Speed to pci_bus_speed
> + * @speed: Target Link Speed (TLS) value from Link Control 2 register (0-4 for 2.5 GT/s - 32 GT/s)
> + *
> + * Convert the Target Link Speed (TLS) field value from the Link Control 2 register
> + * to the corresponding enum pci_bus_speed.
Wrap these to fit in 80 columns like the rest of the file.
> + * Return: pci_bus_speed corresponding to the TLS value
> + */
> +enum pci_bus_speed pci_lnkctl2_bus_speed(u32 speed)
> +{
> + return pcie_link_speed[speed];
> +}
> +EXPORT_SYMBOL(pci_lnkctl2_bus_speed);
> +
> /**
> * pcie_bandwidth_available - determine minimum link settings of a PCIe
> * device and its bandwidth limitation
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 352079393edb..d12875c95491 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1739,6 +1739,7 @@ int pci_cfg_space_size(struct pci_dev *dev);
> unsigned char pci_bus_max_busnr(struct pci_bus *bus);
> resource_size_t pcibios_window_alignment(struct pci_bus *bus,
> unsigned long type);
> +enum pci_bus_speed pci_lnkctl2_bus_speed(u32 speed);
>
> #define PCI_VGA_STATE_CHANGE_BRIDGE (1 << 0)
> #define PCI_VGA_STATE_CHANGE_DECODES (1 << 1)
>
> --
> 2.34.1
>