[PATCH v1 2/3] PCI: Use to_pcie_link_speed() for link speed conversion

From: Hans Zhang

Date: Sun Mar 15 2026 - 12:01:19 EST


Replace direct array indexing with the to_pcie_link_speed() helper in
both the sysfs current_link_speed_show() function and the inline helper
__pcie_update_link_speed() in pci.h. This unifies link speed conversion
and prepares for hiding the pcie_link_speed array.

Signed-off-by: Hans Zhang <18255117159@xxxxxxx>
---
drivers/pci/pci-sysfs.c | 2 +-
drivers/pci/pci.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 16eaaf749ba9..c4231f3de5a6 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -235,7 +235,7 @@ static ssize_t current_link_speed_show(struct device *dev,
if (err)
return -EINVAL;

- speed = pcie_link_speed[linkstat & PCI_EXP_LNKSTA_CLS];
+ speed = to_pcie_link_speed(linkstat);

return sysfs_emit(buf, "%s\n", pci_speed_string(speed));
}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 409aca7d737a..053fc245a1e3 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -645,7 +645,7 @@ static inline void __pcie_update_link_speed(struct pci_bus *bus,
enum pcie_link_change_reason reason,
u16 linksta, u16 linksta2)
{
- bus->cur_bus_speed = pcie_link_speed[linksta & PCI_EXP_LNKSTA_CLS];
+ bus->cur_bus_speed = to_pcie_link_speed(linksta);
bus->flit_mode = (linksta2 & PCI_EXP_LNKSTA2_FLIT) ? 1 : 0;

trace_pcie_link_event(bus,
--
2.34.1