]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: of: Remove max-link-speed generation validation
authorHans Zhang <18255117159@163.com>
Fri, 13 Mar 2026 16:55:22 +0000 (00:55 +0800)
committerManivannan Sadhasivam <mani@kernel.org>
Thu, 26 Mar 2026 18:31:31 +0000 (00:01 +0530)
The of_pci_get_max_link_speed() function currently validates the
"max-link-speed" DT property to be in the range 1..4 (Gen1..Gen4).
This imposes a maintenance burden because each new PCIe generation
would require updating this validation.

Remove the range check so the function returns the raw property value
(or a negative error code if the property is missing or malformed).
Since the callers are now validating the returned speed against the
range they support, this check can now be safely removed.

Removing the validation from this common function also allows future PCIe
generations to be supported without modifying drivers/pci/of.c.

Signed-off-by: Hans Zhang <18255117159@163.com>
[mani: commit log and kernel doc fix]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260313165522.123518-6-18255117159@163.com
drivers/pci/of.c

index 9f8eb5df279ed28db7a3b2fd29c65da9975c2efa..c216701c75dd690b0cedd0a9c14e1570d6772a22 100644 (file)
@@ -875,24 +875,19 @@ EXPORT_SYMBOL_GPL(of_pci_supply_present);
  * of_pci_get_max_link_speed - Find the maximum link speed of the given device node.
  * @node: Device tree node with the maximum link speed information.
  *
- * This function will try to find the limitation of link speed by finding
- * a property called "max-link-speed" of the given device node.
+ * This function will try to read the "max-link-speed" property of the given
+ * device tree node. It does NOT validate the value of the property.
  *
- * Return:
- * * > 0       - On success, a maximum link speed.
- * * -EINVAL   - Invalid "max-link-speed" property value, or failure to access
- *               the property of the device tree node.
- *
- * Returns the associated max link speed from DT, or a negative value if the
- * required property is not found or is invalid.
+ * Return: Maximum link speed value on success, errno on failure.
  */
 int of_pci_get_max_link_speed(struct device_node *node)
 {
        u32 max_link_speed;
+       int ret;
 
-       if (of_property_read_u32(node, "max-link-speed", &max_link_speed) ||
-           max_link_speed == 0 || max_link_speed > 4)
-               return -EINVAL;
+       ret = of_property_read_u32(node, "max-link-speed", &max_link_speed);
+       if (ret)
+               return ret;
 
        return max_link_speed;
 }