Re: [PATCH v1 3/3] PCI: Remove extern declaration of pcie_link_speed array

From: Manivannan Sadhasivam

Date: Sat Apr 04 2026 - 12:45:07 EST


On Mon, Mar 16, 2026 at 12:00:57AM +0800, Hans Zhang wrote:
> With all users of pcie_link_speed converted to use to_pcie_link_speed(),
> the external declaration in pci.h is no longer needed. Remove it to
> prevent new code from directly accessing the array and to reduce the
> global symbol footprint.
>
> Signed-off-by: Hans Zhang <18255117159@xxxxxxx>
> ---
> drivers/pci/pci.h | 1 -
> drivers/pci/probe.c | 1 -
> 2 files changed, 2 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 053fc245a1e3..b2f91409b439 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -107,7 +107,6 @@ struct pcie_tlp_log;
> #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \
> PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE)
>
> -extern const unsigned char pcie_link_speed[];

What about controller drivers using this array?

git grep -r "pcie_link_speed\[" drivers/pci/controller/
drivers/pci/controller/dwc/pcie-designware-host.c: enum pci_bus_speed speed = pcie_link_speed[pci->max_link_speed];
drivers/pci/controller/dwc/pcie-designware.c: switch (pcie_link_speed[pci->max_link_speed]) {
drivers/pci/controller/dwc/pcie-qcom-common.c: for (speed = PCIE_SPEED_8_0GT; speed <= pcie_link_speed[pci->max_link_speed]; speed++) {
drivers/pci/controller/dwc/pcie-qcom-ep.c: Mbps_to_icc(PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]))
drivers/pci/controller/dwc/pcie-qcom-ep.c: if (pcie_link_speed[pci->max_link_speed] == PCIE_SPEED_16_0GT)
drivers/pci/controller/dwc/pcie-qcom.c: Mbps_to_icc(PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]))
drivers/pci/controller/dwc/pcie-qcom.c: if (pcie_link_speed[pci->max_link_speed] == PCIE_SPEED_16_0GT)
drivers/pci/controller/dwc/pcie-qcom.c: freq_mbps = pcie_dev_speed_mbps(pcie_link_speed[speed]);
drivers/pci/controller/dwc/pcie-tegra194.c: val = width * PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]);
drivers/pci/controller/pcie-brcmstb.c: pci_speed_string(pcie_link_speed[cls]), nlw,
drivers/pci/controller/pcie-rzg3s-host.c: switch (pcie_link_speed[host->max_link_speed]) {

- Mani

--
மணிவண்ணன் சதாசிவம்