Use the new pcie_get_link_speed() helper to validate the value read from
the "max-link-speed" DT property. If the value is missing or invalid,
fall back to Gen2 (speed = 2). This prepares for the removal of the
range check in of_pci_get_max_link_speed().
Signed-off-by: Hans Zhang <18255117159@163.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260313165522.123518-4-18255117159@163.com
int ret;
link_speed = of_pci_get_max_link_speed(np);
- if (link_speed < 2)
+ if ((link_speed < 2) ||
+ (pcie_get_link_speed(link_speed) == PCI_SPEED_UNKNOWN))
link_speed = 2;
val = link_speed - 1;