From: Hans Zhang <18255117159@163.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans Zhang <18255117159@163.com>
Subject: [PATCH v1 2/3] PCI: Use to_pcie_link_speed() for link speed conversion
Date: Mon, 16 Mar 2026 00:00:56 +0800 [thread overview]
Message-ID: <20260315160057.127639-3-18255117159@163.com> (raw)
In-Reply-To: <20260315160057.127639-1-18255117159@163.com>
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@163.com>
---
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
next prev parent reply other threads:[~2026-03-15 16:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 16:00 [PATCH v1 0/3] PCI: Encapsulate pcie_link_speed array access Hans Zhang
2026-03-15 16:00 ` [PATCH v1 1/3] PCI: Move to_pcie_link_speed() to probe.c and export it Hans Zhang
2026-03-15 16:00 ` Hans Zhang [this message]
2026-03-15 16:00 ` [PATCH v1 3/3] PCI: Remove extern declaration of pcie_link_speed array Hans Zhang
2026-04-04 16:41 ` Manivannan Sadhasivam
2026-04-06 2:28 ` Hans Zhang
2026-05-16 14:44 ` [PATCH v1 0/3] PCI: Encapsulate pcie_link_speed array access Hans Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260315160057.127639-3-18255117159@163.com \
--to=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).